之前学习了逛逛老师的辅助线代码:http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&Id=55270
想增加一个“shuru"控件,动态定义上限,可以实现了,但是想请教一下,这句代码的X轴想用图表原来的轴坐标,不是固定的,怎么实现?
代码:
zxb.SetXY(New PointF(-0.5,pl),New PointF(11.5,pl))
,其中pl为定义的Y轴的值。
代码:
Dim Chart As WinForm.Chart '定义一个图表变量
Dim Series As WinForm.ChartSeries '定义一个图系变量
Dim t As Table = Tables("数据同步(西)_Table1") '定义一个变量t引用数据表
'Chart.ChartType = ChartTypeEnum.Bar '图表类型改为Bar(条形)
Chart= e.Form.Controls("Chart1") ' 引用窗口中的图表
Chart.ChartType = ChartTypeEnum.Bar '设置图表类型
Chart.SeriesList.Clear() '清除图表原来的图系
Series = Chart.SeriesList.Add() '增加一个图系
Chart.AxisX.DateType = True 'X轴是日期型
Chart.AxisX.AnnoFormatString = "yy-MM" '只显示日
Series.Length = t.Rows.Count '图系的数据点数等于表的行数
For i As Integer = 0 To t.Rows.Count - 1 '指定每个数据点的位置
Series.X(i) = t.Rows(i)("定检时间") '指定水平坐标
Series.Y(i) = t.Rows(i)("整机运行时间") '指定垂直坐标
Next
Series.DataLabelText = "{#YVAL}"
Series.TooltipText = "X = {#XVAL}, Y = {#YVAL}"
'增加上限,根据shuru1的值
Dim C1Cha As C1.Win.C1Chart.C1Chart = Chart.BaseControl
Dim zxb = New zxb柱状图标辅助线()
Dim tl As C1.Win.C1Chart.TrendLine = C1Cha.ChartGroups(0).ChartData.TrendsList.AddNewTrendLine()
Dim pl As Integer = e.Form.Controls("shuru1").Value
tl = C1Cha.ChartGroups(0).ChartData.TrendsList.AddNewTrendLine()
tl.LineStyle.Color = Color.BurlyWood
tl.LineStyle.Thickness = 2
tl.LineStyle.Pattern = 2
zxb = New zxb柱状图标辅助线()
zxb.SetXY(New PointF(1000,pl),New PointF(1000,pl))
zxb.SetText("上限")
tl.CustomTrendLine = zxb