以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 图表 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=74170) |
-- 作者:cqlistone -- 发布时间:2015/9/5 10:34:00 -- 图表 你好 要从表A中获得数据生成图表,从DropDownBox下拉窗口目录树选择设备编号后能自动生成被选中设备最近12个月的耗时 x轴是最近12个月的月份(显示年月) Y轴是对应月份的设备时间统计 请帮忙写下XY轴代码
|
-- 作者:Hyphen -- 发布时间:2015/9/5 11:46:00 -- 麻烦上个测试例子 |
-- 作者:cqlistone -- 发布时间:2015/9/5 13:27:00 -- 希望X轴是最近12个月的月份,文本为年月,如本月2015-09,上月2015-08 Y轴是对应月的耗时 Dim Chart As WinForm.Chart Dim Series As WinForm.ChartSeries Dim tjcz As WinForm.DropDownBox = e.Form.Controls("机器号") Dim y As Integer = Date.Today.Year Dim m As Integer = Date.Today.Month Dim nym As new Date=Date.Today(y,m) Dim tbl As DataTable = DataTables("停机处置") Dim lst As List(Of String) = tbl.GetValues("机器号","机器号= \'" & tjcz.text & "\' And [耗时]> 0" ) Chart = e.Form.Controls("Chart1") Chart.ChartType = ChartTypeEnum.Bar Chart.SeriesList.Clear() \' Series = Chart.SeriesList.Add() Series.Length = 12 For i As Integer = m To m-11 Series.X(i) = i Series.Y(i) = tbl.Compute("Avg(耗时)","[机器号] = \'" & lst(i) & "\' and 机器号= \'" & tjcz.text & "\' And [耗时]> 0") Chart.AxisX.SetValueLabel(i, lst(i)) Next
|
-- 作者:Hyphen -- 发布时间:2015/9/5 15:37:00 -- Dim Chart As WinForm.Chart Dim Series As WinForm.ChartSeries Dim tjcz As WinForm.DropDownBox = e.Form.Controls("机器号") Dim y As Integer = Date.Today.Year Dim m As Integer = Date.Today.Month \'Dim nym As new Date=Date.Today(y,m) \'-------------- Dim mms() As Integer ={1,2,3,4,5,6,7,8,9,10,11,12} Dim mms2 As new List(Of String) For i1 As Integer = m To mms.Length - 1 mms2.Add(CStr(y-1) & "-" & mms(i1)) Next For i2 As Integer = 0 To m-1 mms2.Add( y & "-" & mms(i2)) Next \'-------------- Dim tbl As DataTable = DataTables("停机处置") Dim lst As List(Of String) = tbl.GetValues("机器号","机器号= \'" & tjcz.text & "\' And [耗时]> 0" ) Chart = e.Form.Controls("Chart1") Chart.ChartType = ChartTypeEnum.Bar Chart.SeriesList.Clear() \' Series = Chart.SeriesList.Add() Series.Length = 12 For i As Integer = 0 To mms2.Count- 1 Series.X(i) = i Series.Y(i) = tbl.Compute("Avg(耗时)","[机器号] = \'" & lst(i) & "\' and 机器号= \'" & tjcz.text & "\' And [耗时]> 0") Chart.AxisX.SetValueLabel(i, mms2(i)) Next Chart.AxisX.AnnoWithLabels = True
|
-- 作者:cqlistone -- 发布时间:2015/9/5 17:20:00 -- 你好! 这段代码报错:超索引范围
|
-- 作者:Hyphen -- 发布时间:2015/9/5 17:41:00 -- tbl.Compute("Avg(耗时)","[机器号] = \'" & lst(i) & "\' and 机器号= \'" & tjcz.text & "\' And [耗时]> 0") 这段根据你项目改动,我没有你那些表来测试
|
-- 作者:cqlistone -- 发布时间:2015/9/5 18:14:00 -- 你看能有帮助不 详细错误信息: 索引超出范围。必须为非负值并小于集合大小。 参数名: index |
-- 作者:大红袍 -- 发布时间:2015/9/6 9:42:00 -- 看不懂你的逻辑,请上传具体例子说明问题。 |
-- 作者:Hyphen -- 发布时间:2015/9/6 9:48:00 -- tbl.Compute("Avg(耗时)","[机器号] = \'" & tjcz.text & "\' And [耗时]> 0") 试试 |
-- 作者:cqlistone -- 发布时间:2015/9/6 16:58:00 -- 你好! 案例,表和窗口都有
|