此主题相关图片如下:微信图片_20230810164130.png
按论坛的例子,显示不出线条,这是什么原因呀?代码如下:'设定图表数据,因为只是演示,所以数据只用人工设置
Dim i均值 As Integer = e.Form.Controls("TextBox1").Value
Dim i上限 As Integer = e.Form.Controls("TextBox2").Value
Dim i下限 As Integer = e.Form.Controls("TextBox3").Value
'计算区间条形
Dim d1 As Date = "2023-7-20"
Dim d2 As Date = "2023-7-28"
Dim t As TimeSpan = d2 - d1
Dim 线长度 As Integer = t.TotalDays
'生成图表
Dim i As Integer
Dim Chart As WinForm.Chart = e.Form.Controls("Chart1")
Dim C1Cha As C1.Win.C1Chart.C1Chart = Chart.BaseControl
Dim Series As WinForm.ChartSeries
Chart.VisualEffect = True
Chart.ChartType = ChartTypeEnum.Bar
Chart.DataSource = "A" '设置绑定表
Chart.SeriesList.Clear() '清除图表原来的图系
Chart.AxisY.Min = 0 '指定Y轴的最小值
Chart.AxisY.Max = 150 '指定Y轴的最大值
Chart.AxisY.Major = 20 '主刻度间隔值为5000
Series = Chart.SeriesList.Add() '增加一个图系
Series.X.DataField = "日期" 'X轴绑定到月份列
Series.Y.DataField = "数值" 'Y轴绑定到数量列
Series.Text = "数值"
'Chart.AxisX.AnnoWithLabels = True
Chart.AxisX.DateType = True '明确指定X轴是日期型
Chart.AxisX.AnnoFormatString = "yyyy-MM-dd"
Chart.AxisX.AnnoRotation = 45
Chart.LegendVisible = True
Chart.LegendCompass = CompassEnum.South
'增加均值
Dim tl As C1.Win.C1Chart.TrendLine = C1Cha.ChartGroups(0).ChartData.TrendsList.AddNewTrendLine()
tl.LineStyle.Color = Color.Gold '线条颜色
tl.LineStyle.Thickness = 2 '线宽
tl.LineStyle.Pattern = 0 '直线样式 0-5
Dim zxb = New TbszLine()
zxb.SetXY(New PointF( - 0.5, i均值), New PointF(线长度, i均值))
zxb.SetText("均线")
tl.CustomTrendLine = zxb
'增加下限
tl = C1Cha.ChartGroups(0).ChartData.TrendsList.AddNewTrendLine()
tl.LineStyle.Color = Color.red
tl.LineStyle.Thickness = 2
tl.LineStyle.Pattern = 2
zxb = New TbszLine()
zxb.SetXY(New PointF( - 0.5, i下限), New PointF(线长度, i下限))
zxb.SetText("下限")
tl.CustomTrendLine = zxb
'增加上限
tl = C1Cha.ChartGroups(0).ChartData.TrendsList.AddNewTrendLine()
tl.LineStyle.Color = Color.BurlyWood
tl.LineStyle.Thickness = 2
tl.LineStyle.Pattern = 2
zxb = New TbszLine()
zxb.SetXY(New PointF( - 0.5, i上限), New PointF(线长度, i上限))
zxb.SetText("上限")
tl.CustomTrendLine = zxb
改了还是不行
'设定图表数据,因为只是演示,所以数据只用人工设置
Dim i均值 As Integer = e.Form.Controls("TextBox1").Value
Dim i上限 As Integer = e.Form.Controls("TextBox2").Value
Dim i下限 As Integer = e.Form.Controls("TextBox3").Value
'计算区间条形
Dim d1 As Date = "2023-7-20"
Dim d2 As Date = "2023-7-28"
Dim t1 As TimeSpan = d2 - d1
Dim 线长度 As Integer = t1.TotalDays
'生成图表
'Dim i As Integer
Dim Chart As WinForm.Chart = e.Form.Controls("Chart1")
Dim C1Cha As C1.Win.C1Chart.C1Chart = Chart.BaseControl
Dim Series As WinForm.ChartSeries
Chart.VisualEffect = True
Chart.ChartType = ChartTypeEnum.Bar
Chart.SeriesList.Clear() '清除图表原来的图系
Chart.AxisY.Min = 0 '指定Y轴的最小值
Chart.AxisY.Max = 150 '指定Y轴的最大值
Chart.AxisY.Major = 20 '主刻度间隔值为5000
Dim t As Table = Tables("A") '定义一个变量t引用数据表
Series = Chart.SeriesList.Add() '增加一个图系
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
Chart.AxisX.DateType = True '明确指定X轴是日期型
Chart.AxisX.AnnoFormatString = "yyyy-MM-dd"
Chart.AxisX.AnnoRotation = 45
Chart.LegendVisible = True
Chart.LegendCompass = CompassEnum.South
'增加均值
Dim tl As C1.Win.C1Chart.TrendLine = C1Cha.ChartGroups(0).ChartData.TrendsList.AddNewTrendLine()
tl.LineStyle.Color = Color.Gold '线条颜色
tl.LineStyle.Thickness = 2 '线宽
tl.LineStyle.Pattern = 0 '直线样式 0-5
Dim zxb = New TbszLine()
zxb.SetXY(New PointF( - 0.5, i均值), New PointF(线长度, i均值))
zxb.SetText("均线")
tl.CustomTrendLine = zxb
'增加下限
tl = C1Cha.ChartGroups(0).ChartData.TrendsList.AddNewTrendLine()
tl.LineStyle.Color = Color.red
tl.LineStyle.Thickness = 2
tl.LineStyle.Pattern = 2
zxb = New TbszLine()
zxb.SetXY(New PointF( - 0.5, i下限), New PointF(线长度, i下限))
zxb.SetText("下限")
tl.CustomTrendLine = zxb
'增加上限
tl = C1Cha.ChartGroups(0).ChartData.TrendsList.AddNewTrendLine()
tl.LineStyle.Color = Color.BurlyWood
tl.LineStyle.Thickness = 2
tl.LineStyle.Pattern = 2
zxb = New TbszLine()
zxb.SetXY(New PointF( - 0.5, i上限), New PointF(线长度, i上限))
zxb.SetText("上限")
tl.CustomTrendLine = zxb
如何将辅助线的值显示出来,而且只显示一个其中一个数据点的值