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


  共有5765人关注过本帖树形打印复制链接

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

帅哥哟,离线,有人找我吗?
有点色
  41楼 | 信息 | 搜索 | 邮箱 | 主页 | 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 '启用字符标示


 回到顶部
帅哥哟,离线,有人找我吗?
sexbee
  42楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:125 积分:797 威望:0 精华:0 注册:2017/5/26 11:11:00
  发帖心情 Post By:2017/6/22 11:27:00 [只看该作者]

以下是引用sexbee在2017/6/22 10:42:00的发言:

理解老师的意思,就是其中一曲线有缺失值,只能用0替代,以统一坐标,但是可否不用0 ,而用空值,即这段曲线就不显示,即为断续曲线?

谢谢,果然解决坐标问题,那么最后一个想法:  这些断续的点不管其缺失值,各自直接相连可以实现吗?


 回到顶部
帅哥哟,离线,有人找我吗?
sexbee
  43楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:125 积分:797 威望:0 精华:0 注册:2017/5/26 11:11:00
  发帖心情 Post By:2017/6/22 11:46:00 [只看该作者]


 

加上判断的代码后,就互相切割变散点图了。

[此贴子已经被作者于2017/6/22 12:41:57编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
sexbee
  44楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:125 积分:797 威望:0 精华:0 注册:2017/5/26 11:11:00
  发帖心情 Post By:2017/6/22 12:14:00 [只看该作者]

色老师,说到底 还是两条曲线的各自缺失值问题,可否这样,某横坐标上,有缺失值,以前后值的和的1/2补充赋值给缺失值,以达到坐标统一?

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


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/6/22 12:17: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
Dim pkey As Date
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")) '指定字符表示
    ElseIf i > 0 Then
        Series.X(i) = i '指定水平坐标
        Series.Y(i) = dic1(pkey) '指定垂直坐标
        Chart.AxisX.SetValueLabel(i, format(key, "yyyy-MM-dd")) '指定字符表示
       
    End If
    i += 1
    pkey = key
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) '指定垂直坐标
    ElseIf i > 0
        Series.X(i) = i '指定水平坐标
        Series.Y(i) = dic2(pkey) '指定垂直坐标
    End If
    Chart.AxisX.SetValueLabel(i, format(key, "yyyy-MM-dd")) '指定字符表示
    i += 1
    pkey = key
Next

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


 回到顶部
帅哥哟,离线,有人找我吗?
sexbee
  46楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:125 积分:797 威望:0 精华:0 注册:2017/5/26 11:11:00
  发帖心情 Post By:2017/6/22 12:45:00 [只看该作者]

果然牛B!图片点击可在新窗口打开查看

 回到顶部
帅哥哟,离线,有人找我吗?
sexbee
  47楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:125 积分:797 威望:0 精华:0 注册:2017/5/26 11:11:00
  发帖心情 Post By:2017/6/23 9:46:00 [只看该作者]

老师,如果再增加一个图系,是这样加吗?

 

 

Dim dic1 As new SortedDictionary(Of Date, Double)
Dim dic2 As new SortedDictionary(Of Date, Double)

Dim dic3 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

 

For Each r As Row In e.Form.controls("Table3").Table.Rows
    If r.IsNull("date") = False Then
        If dic3.ContainsKey(r("date")) = False Then
            dic3.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
Dim pkey As Date
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")) '指定字符表示
    ElseIf i > 0 Then
        Series.X(i) = i '指定水平坐标
        Series.Y(i) = dic1(pkey) '指定垂直坐标
        Chart.AxisX.SetValueLabel(i, format(key, "yyyy-MM-dd")) '指定字符表示
       
    End If
    i += 1
    pkey = key
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) '指定垂直坐标
    ElseIf i > 0
        Series.X(i) = i '指定水平坐标
        Series.Y(i) = dic2(pkey) '指定垂直坐标
    End If
    Chart.AxisX.SetValueLabel(i, format(key, "yyyy-MM-dd")) '指定字符表示
    i += 1
    pkey = key
Next

 

Chart.AxisX.ClearValueLabel
Series = Chart.SeriesList3.Add() '增加一个图系
Series.Length = dic3.Count '设置图系的长度
i = 0

For Each key As Date In dic3.keys
    If dic3(key) > 0 Then
        Series.X(i) = i '指定水平坐标
        Series.Y(i) = dic3(key) '指定垂直坐标
    ElseIf i > 0
        Series.X(i) = i '指定水平坐标
        Series.Y(i) = dic3(pkey) '指定垂直坐标
    End If
    Chart.AxisX.SetValueLabel(i, format(key, "yyyy-MM-dd")) '指定字符表示
    i += 1
    pkey = key
Next

 

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


 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  48楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106242 积分:540333 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2017/6/23 9:54:00 [只看该作者]

做不到,最多只有2个图系

 回到顶部
帅哥哟,离线,有人找我吗?
sexbee
  49楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:125 积分:797 威望:0 精华:0 注册:2017/5/26 11:11:00
  发帖心情 Post By:2017/6/23 10:02:00 [只看该作者]

是fox控件的原因 ?如果是。net的控件能有三个图系吗?

 


 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  50楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106242 积分:540333 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2017/6/23 10:31:00 [只看该作者]

。net控件都不会有3个图系,一个平面也就放得下2个正的Y轴。

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