以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 咨询 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=97645) |
||||
-- 作者:cqli -- 发布时间:2017/3/16 10:06:00 -- 咨询 你好! 希望X轴显示月份和月份对应的列1内容,Y轴按X轴进行列2数据统计。帮忙修改下代码,谢谢! Dim Chart As WinForm.Chart Dim Series As WinForm.ChartSeries Dim y As Integer = Date.Today.Year Dim m As Integer = Date.Today.Month Dim tb As DataTable = DataTables("表A") Chart = e.Form.Controls("Chart1") Chart.ChartType = ChartTypeEnum.Bar Chart.SeriesList.Clear() Chart.AxisX.ClearValueLabel \'清除所有通过SetValueLabel设置的数值字符标示 Series = Chart.SeriesList.Add() Series.Length = 6 Dim td As Date = new Date(Date.Today.Year, Date.Today.Month, 1) For i As Integer = 0 To 5 Dim d As Date= td.AddMonths(-i) Dim lst As List(Of String) = tb.SQLGetValues("列1","日期 >= \'" & d & "\' and 日期 < \'"
& d.AddMonths(1) & "\'") Series.X(i) = i Series.Y(i) = val(tb.SQLCompute("Sum(列2)","日期 >= \'" & d & "\' and 日期 < \'"
& d.AddMonths(1) & "\' and [列1] = \'"
& lst(i) & "\'")) Chart.AxisX.SetValueLabel(i, Format(d, "yyyy-MM")) Chart.HeaderText="数量(件)" \'设置图表的上标题 Chart.AxisX.AnnoWithLabels = True
\'启用字符标示 \'Chart.LegendVisible = True \'Chart.LegendCompass= CompassEnum.South Series.DataLabelText
= "{#YVAL}" \'图中显示数据 Chart.VisualEffect = True \'图更漂亮 Chart.SeriesList(0).LineColor= Color.GreenYellow Next |
||||
-- 作者:有点色 -- 发布时间:2017/3/16 10:07:00 -- 上传实例说明。 |
||||
-- 作者:cqli -- 发布时间:2017/3/16 10:38:00 -- 你好! X轴按月显示的同时显示对应月份的类型
|
||||
-- 作者:有点色 -- 发布时间:2017/3/16 11:04:00 -- 上传具体实例测试。 |
||||
-- 作者:cqli -- 发布时间:2017/3/16 20:48:00 --
|
||||
-- 作者:有点色 -- 发布时间:2017/3/17 1:47:00 -- Dim Chart As WinForm.Chart Dim td As Date = new Date(Date.Today.Year, Date.Today.Month, 1) |