Foxtable(狐表)用户栏目专家坐堂 → [求助]跨年月份数据的图表如何绘制


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

主题:[求助]跨年月份数据的图表如何绘制

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


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/5/26 16:41:00 [显示全部帖子]

参考代码

 

Dim y1 As String = "2014"
Dim m1 As String = "3"
Dim y2 As String = "2015"
Dim m2 As String = "9"

Dim Chart As WinForm.Chart '定义一个图表变量
Dim Series As WinForm.ChartSeries '定义一个图系变量
Chart= e.Form.Controls("Chart1") ' 引用窗口中的图表
Chart.SeriesList.Clear() '清除图表原来的图系
Chart.AxisX.ClearValueLabel
Series = Chart.SeriesList.Add() '每年一个图系
Dim dt As DataTable = DataTables("统计表1")
Dim d1 As Date = new Date(y1,m1,1)
Dim d2 As Date = new Date(y2,m2,1)
series.Length = DateDiff("m",d1,d2)+1

For i As Integer = 0 To series.Length-1
    Dim d As Date = d1.AddMonths(i)
    Series.X(i) = i '指定水平坐标
    Series.Y(i) = val(dt.Compute("sum(数量)", "年='" & d.year & "' and 月='" & d.month & "'"))
    Chart.AxisX.SetValueLabel(i, Format(d, "yyyy年-MM月")) '指定字符表示
Next
Chart.AxisX.AnnoWithLabels = True '启用字符标示
Chart.AxisX.AnnoRotation = - 45


 回到顶部