您的位置:首页 > 数据库

vs2010中对mschart控件使用的一些心得

2011-08-12 15:43 337 查看
一 在页面中先添加一个chart控件,不用做什么设置,把自动生成的那个series删除掉,只设置其大小和ID就可以了,其它的在代码中进行设置.

二 所绑定的数据是根据所选条件的不同查询数据后进行动态绑定的,以前认为这个比较复杂,原来也是很简单的,对数据进行表绑定和交叉表绑定很实用.getdata是一个自己写的函数,用于根据所填写的sql语句返回相应的数据集

三 关于tooltip的提示信息的绑定,这个目前为止还没有找到如何对其数据进行运算的方法,如果哪位找到了请留言,代码比较乱,大家凑和地看吧.

下面是代码:

 

Select Case lx
Case "销售台次"
sql = "select month(日期) as 月份,月台次 from 产值_销售 where year(日期)='" & year & "' and day(dateadd(""d"",1,日期))='1' and 所在店='" & szd & "' order by 日期"
CH_xs.DataBindTable(hr.GetData(sql), "月份")
CH_xs.Series(0).Label = "#VAL"
ch_xs1.DataBindTable(hr.GetData(sql), "月份")
ch_xs1.Series(0).Label = "#VAL"
Case ("售后产值")
sql = "select month(日期) as 月份,售后月产值 as 月产值 from 产值_售后 where year(日期)='" & year & "' and day(dateadd(""d"",1,日期))='1' and 所在店='" & szd & "' order by 日期"
CH_xs.DataBindTable(hr.GetData(sql), "月份")
ch_xs1.DataBindTable(hr.GetData(sql), "月份")
CH_xs.Series(0).Label = "#VAL"

CH_xs.Series(0).ToolTip = "本月产值:#VAL"
ch_xs1.Series(0).Label = "#VAL"
Case ("集团产值")
sql = "select month(日期) as 月份,所在店,(售后月产值/10000) as 月产值 from 产值_售后 where year(日期)='" & year & "' and day(dateadd(""d"",1,日期))='1' order by 日期"
CH_xs.DataBindCrossTable(hr.GetData(sql), "所在店", "月份", "月产值", "Label=月产值{C}")
ch_xs1.DataBindCrossTable(hr.GetData(sql), "所在店", "月份", "月产值", "Label=月产值{C}")
CH_xs.Series(0).Label = "#VAL"

'CH_xs.Series(0).ToolTip = "本月产值:#VAL"
ch_xs1.Series(0).Label = "#VAL"
CH_xs.Width = "1200"
ch_xs1.Width = "1200"
Case ("集团台次")
sql = "select month(日期) as 月份,所在店,月台次 from 产值_销售 where year(日期)='" & year & "' and day(dateadd(""d"",1,日期))='1' order by 日期"
CH_xs.DataBindCrossTable(hr.GetData(sql), "所在店", "月份", "月台次", "Label=月台次")
ch_xs1.DataBindCrossTable(hr.GetData(sql), "所在店", "月份", "月台次", "Label=月台次")
CH_xs.Series(0).Label = "#VAL"

'CH_xs.Series(0).ToolTip = "本月产值:#VAL"
ch_xs1.Series(0).Label = "#VAL"
CH_xs.Width = "1200"
ch_xs1.Width = "1200"
End Select
Dim i As Integer
For i = 0 To ch_xs1.Series.Count - 1
ch_xs1.Series(i).ChartType = DataVisualization.Charting.SeriesChartType.Line
ch_xs1.Series(i).MarkerStyle = DataVisualization.Charting.MarkerStyle.Circle
ch_xs1.Series(i).MarkerSize = 8
ch_xs1.Series(i).BorderWidth = "3"
ch_xs1.Series(i).ShadowColor = Drawing.Color.Black
ch_xs1.Series(i).BorderColor = Drawing.Color.Aqua
ch_xs1.Series(i).ShadowOffset = 2
ch_xs1.Series(i).YValueType = DataVisualization.Charting.ChartValueType.Double
ch_xs1.Series(i).XValueType = DataVisualization.Charting.ChartValueType.Double
Next

CH_xs.ChartAreas(0).Area3DStyle.IsClustered = True
CH_xs.ChartAreas(0).Area3DStyle.Enable3D = True
CH_xs.ChartAreas(0).Area3DStyle.LightStyle = DataVisualization.Charting.LightStyle.Realistic
For i = 0 To CH_xs.Series.Count - 1
CH_xs.Series(i).ChartType = DataVisualization.Charting.SeriesChartType.Column
CH_xs.Series(i).MarkerStyle = DataVisualization.Charting.MarkerStyle.None
CH_xs.Series(i).ShadowColor = Drawing.Color.Black
CH_xs.Series(i).ShadowOffset = 2
Next
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  2010 sql integer c