以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  关联表图表生成  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=57271)

--  作者:lxhmax
--  发布时间:2014/9/22 11:36:00
--  关联表图表生成
请问下各位老师;
1,关联表的图表怎么生成?
2,我想在表A选择多个成员的时候图表可以显示出多条数据线?
3,横坐标动态显示近一个月的时间,即今天零点以20日开始,明天零点以21日开始,一次类推?
麻烦各位老师,谢谢~
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:条形图cmn.rar



--  作者:有点甜
--  发布时间:2014/9/22 12:21:00
--  

Dim Chart As WinForm.Chart \'定义一个图表变量
Dim Series As WinForm.ChartSeries \'定义一个图系变量
Dim dt1 As DataTable = DataTables("表A") \'定义一个变量t引用数据表
Dim dt2 As DataTable = DataTables("表B")
Chart = e.Form.Controls("Chart1") \' 引用窗口中的图表
Chart.ChartType = ChartTypeEnum.XYPlot
Chart.SeriesList.Clear() \'清除图表原来的图系
Dim filter As String = "日期 >= #" & Date.Today & "# and 日期 <= #" & Date.Today.AddMonths(1) & "#"
For Each dr As DataRow In dt1.Select("选择 = true")
    Series = Chart.SeriesList.Add() \'增加一个图系
    series.Text = dr("成员")
    Dim drs As List(Of DataRow) = dt2.Select("成员 = \'" & dr("成员") & "\' and " & filter)
    series.Length = drs.Count
    For i As Integer = 0 To drs.Count - 1
        Series.X(i) = i
        Series.Y(i) = drs(i)("体重")
    Next
Next
Dim r As Integer = 0
Do
    Chart.AxisX.SetValueLabel(r, Format(Date.Today.AddDays(r),"dd")) \'指定字符表示
    r+=1
Loop While Date.Today.AddDays(r) <= Date.Today.AddMonths(1)

Chart.AxisX.AnnoWithLabels = True \'启用字符标示
Chart.VisualEffect = True \'加上这一行,让你的图表更漂亮
Chart.LegendVisible = True \'显示图列
Chart.LegendCompass= CompassEnum.South \'图列显示在南方(底端)


--  作者:lxhmax
--  发布时间:2014/9/22 13:17:00
--  
非常感谢,还有个问题是,我想显示的区间是已有数据的最新的一天再往前推30天,而不是以操作的当天来计算!
--  作者:有点甜
--  发布时间:2014/9/22 14:30:00
--  

Dim Chart As WinForm.Chart \'定义一个图表变量
Dim Series As WinForm.ChartSeries \'定义一个图系变量
Dim dt1 As DataTable = DataTables("表A") \'定义一个变量t引用数据表
Dim dt2 As DataTable = DataTables("表B")
Chart = e.Form.Controls("Chart1") \' 引用窗口中的图表
Chart.ChartType = ChartTypeEnum.XYPlot
Chart.SeriesList.Clear() \'清除图表原来的图系
Dim filter As String = "成员 in (\'" & dt1.GetComboListString("成员", "选择 = true").Replace("|", "\',\'") & "\')"
Dim max As Date = dt2.Compute("max(日期)", filter)
For Each dr As DataRow In dt1.Select("选择 = true")
    Series = Chart.SeriesList.Add() \'增加一个图系
    series.Text = dr("成员")
    series.Length = 30
    For i As Integer = 0 To 29
        Dim fdr As DataRow = dt2.Find("成员 = \'" & dr("成员") & "\' and 日期 = #" & max.AddDays(i-29) & "#")
        If fdr IsNot Nothing Then
            Series.X(i) = i
            Series.Y(i) = fdr("体重")
        Else
            Series.X(i) = i
            Series.Y(i) = 0
        End If
    Next
Next

For i As Integer = 0 To 29
    Chart.AxisX.SetValueLabel(i, Format(max.AddDays(i-29),"dd")) \'指定字符表示
Next

Chart.AxisX.AnnoWithLabels = True \'启用字符标示
\'Chart.VisualEffect = True \'加上这一行,让你的图表更漂亮
Chart.LegendVisible = True \'显示图列
Chart.LegendCompass= CompassEnum.South \'图列显示在南方(底端)


--  作者:lxhmax
--  发布时间:2014/9/22 15:38:00
--  
老师,出现个小问题就是如果单选了两个成员之后再多选几个成员横坐标就会出现覆盖的情况,我折腾了一下搞不懂,麻烦老师再看一下~谢谢你!
--  作者:有点甜
--  发布时间:2014/9/22 15:42:00
--  

 

 

Dim Chart As WinForm.Chart \'定义一个图表变量
Dim Series As WinForm.ChartSeries \'定义一个图系变量
Dim dt1 As DataTable = DataTables("表A") \'定义一个变量t引用数据表
Dim dt2 As DataTable = DataTables("表B")
Chart = e.Form.Controls("Chart1") \' 引用窗口中的图表
Chart.ChartType = ChartTypeEnum.XYPlot
Chart.SeriesList.Clear() \'清除图表原来的图系

Chart.AxisX.ClearValueLabel
Dim filter As String = "成员 in (\'" & dt1.GetComboListString("成员", "选择 = true").Replace("|", "\',\'") & "\')"
Dim max As Date = dt2.Compute("max(日期)", filter)
For Each dr As DataRow In dt1.Select("选择 = true")
    Series = Chart.SeriesList.Add() \'增加一个图系
    series.Text = dr("成员")
    series.Length = 30
    For i As Integer = 0 To 29
        Dim fdr As DataRow = dt2.Find("成员 = \'" & dr("成员") & "\' and 日期 = #" & max.AddDays(i-29) & "#")
        If fdr IsNot Nothing Then
            Series.X(i) = i
            Series.Y(i) = fdr("体重")
        Else
            Series.X(i) = i
            Series.Y(i) = 0
        End If
    Next
Next

For i As Integer = 0 To 29
    Chart.AxisX.SetValueLabel(i, Format(max.AddDays(i-29),"dd")) \'指定字符表示
Next

Chart.AxisX.AnnoWithLabels = True \'启用字符标示
\'Chart.VisualEffect = True \'加上这一行,让你的图表更漂亮
Chart.LegendVisible = True \'显示图列
Chart.LegendCompass= CompassEnum.South \'图列显示在南方(底端)


--  作者:lxhmax
--  发布时间:2014/9/22 15:55:00
--  

图片点击可在新窗口打开查看此主题相关图片如下:1554593868832010424b885b5e7383fb22e614db508b90a9.tmp.jpg
图片点击可在新窗口打开查看

[此贴子已经被作者于2014-9-22 15:55:51编辑过]

--  作者:有点甜
--  发布时间:2014/9/22 16:02:00
--  

 留空

 

Dim Chart As WinForm.Chart \'定义一个图表变量
Dim Series As WinForm.ChartSeries \'定义一个图系变量
Dim dt1 As DataTable = DataTables("表A") \'定义一个变量t引用数据表
Dim dt2 As DataTable = DataTables("表B")
Chart = e.Form.Controls("Chart1") \' 引用窗口中的图表
Chart.ChartType = ChartTypeEnum.XYPlot
Chart.SeriesList.Clear() \'清除图表原来的图系

Chart.AxisX.ClearValueLabel
Dim filter As String = "成员 in (\'" & dt1.GetComboListString("成员", "选择 = true").Replace("|", "\',\'") & "\')"
Dim max As Date = dt2.Compute("max(日期)", filter)
For Each dr As DataRow In dt1.Select("选择 = true")
    Series = Chart.SeriesList.Add() \'增加一个图系
    series.Text = dr("成员")
    series.Length = 30
    For i As Integer = 0 To 29
        Dim fdr As DataRow = dt2.Find("成员 = \'" & dr("成员") & "\' and 日期 = #" & max.AddDays(i-29) & "#")
        If fdr IsNot Nothing Then
            Series.X(i) = i
            Series.Y(i) = fdr("体重")
        Else
            \'Series.X(i) = i
            \'Series.Y(i) = 0
        End If
    Next
Next

For i As Integer = 0 To 29
    Chart.AxisX.SetValueLabel(i, Format(max.AddDays(i-29),"dd")) \'指定字符表示
Next

Chart.AxisX.AnnoWithLabels = True \'启用字符标示
\'Chart.VisualEffect = True \'加上这一行,让你的图表更漂亮
Chart.LegendVisible = True \'显示图列
Chart.LegendCompass= CompassEnum.South \'图列显示在南方(底端)

 

 


--  作者:有点甜
--  发布时间:2014/9/22 16:04:00
--  

平行

 

Dim Chart As WinForm.Chart \'定义一个图表变量
Dim Series As WinForm.ChartSeries \'定义一个图系变量
Dim dt1 As DataTable = DataTables("表A") \'定义一个变量t引用数据表
Dim dt2 As DataTable = DataTables("表B")
Chart = e.Form.Controls("Chart1") \' 引用窗口中的图表
Chart.ChartType = ChartTypeEnum.XYPlot
Chart.SeriesList.Clear() \'清除图表原来的图系

Chart.AxisX.ClearValueLabel
Dim filter As String = "成员 in (\'" & dt1.GetComboListString("成员", "选择 = true").Replace("|", "\',\'") & "\')"
Dim max As Date = dt2.Compute("max(日期)", filter)
For Each dr As DataRow In dt1.Select("选择 = true")
    Series = Chart.SeriesList.Add() \'增加一个图系
    series.Text = dr("成员")
    series.Length = 30
    For i As Integer = 0 To 29
        Dim fdr As DataRow = dt2.Find("成员 = \'" & dr("成员") & "\' and 日期 = #" & max.AddDays(i-29) & "#")
        If fdr IsNot Nothing Then
            Series.X(i) = i
            Series.Y(i) = fdr("体重")
           
        Else
            Series.X(i) = i
            If i = 0 Then
                Series.Y(i) = 0
            Else
                Series.Y(i) = Series.Y(i-1)
            End If
        End If
    Next
Next

For i As Integer = 0 To 29
    Chart.AxisX.SetValueLabel(i, Format(max.AddDays(i-29),"dd")) \'指定字符表示
Next

Chart.AxisX.AnnoWithLabels = True \'启用字符标示
\'Chart.VisualEffect = True \'加上这一行,让你的图表更漂亮
Chart.LegendVisible = True \'显示图列
Chart.LegendCompass= CompassEnum.South \'图列显示在南方(底端)


--  作者:lxhmax
--  发布时间:2014/9/22 16:06:00
--  
老师,只能留空不能连接上去吗?