Foxtable(狐表)用户栏目专家坐堂 → [求助]关于图表生成的数据源


  共有5788人关注过本帖平板打印复制链接

主题:[求助]关于图表生成的数据源

帅哥哟,离线,有人找我吗?
有点色
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/6/22 10:55:00 [只看该作者]

Dim dic1 As new SortedDictionary(Of Date, Double)
Dim dic2 As new SortedDictionary(Of Date, Double)
For Each r As Row In e.Form.controls("Table数据").Table.Rows
    If r.IsNull("date") = False Then
        If dic1.ContainsKey(r("date")) = False Then
            dic1.add(r("date"), r("value"))
            dic2.add(r("date"), 0)
        End If
    End If
Next
For Each r As Row In e.Form.controls("Table1").Table.Rows
    If r.IsNull("date") = False Then
        If dic1.ContainsKey(r("date")) = False Then
            dic1.add(r("date"), 0)
        End If
        If dic2.ContainsKey(r("date")) = False Then
            dic2.add(r("date"), r("value"))
        Else
            dic2(r("date")) = r("value")
        End If
    End If
Next

Dim Chart As WinForm.Chart '定义一个图表变量
Dim Series As WinForm.ChartSeries '定义一个图系变量
Chart= e.Form.Controls("Chart1") ' 引用窗口中的图表
Chart.SeriesList.Clear() '清除图表原来的图系
Chart.SeriesList2.Clear
Chart.AxisX.ClearValueLabel

Series = Chart.SeriesList.Add() '增加一个图系
Series.Length = dic1.Count '设置图系的长度
Dim i As Integer = 0
For Each key As Date In dic1.keys
If dic1(key) > 0 Then
    Series.X(i) = i '指定水平坐标
    Series.Y(i) = dic1(key) '指定垂直坐标
    Chart.AxisX.SetValueLabel(i, format(key, "yyyy-MM-dd")) '指定字符表示
End If
    i += 1
Next

Chart.AxisX.ClearValueLabel
Series = Chart.SeriesList2.Add() '增加一个图系
Series.Length = dic2.Count '设置图系的长度
i = 0
For Each key As Date In dic2.keys
If dic2(key) > 0 Then
    Series.X(i) = i '指定水平坐标
    Series.Y(i) = dic2(key) '指定垂直坐标
End If
    Chart.AxisX.SetValueLabel(i, format(key, "yyyy-MM-dd")) '指定字符表示
    i += 1
Next

Chart.AxisX.AnnoRotation = -45
Chart.AxisX.AnnoWithLabels = True '启用字符标示


 回到顶部
总数 55 1 2 3 4 5 6 下一页