Foxtable(狐表)用户栏目专家坐堂 → 如何在图表中划一条横线?


  共有3196人关注过本帖树形打印复制链接

主题:如何在图表中划一条横线?

帅哥哟,离线,有人找我吗?
hbfnmxb
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:二尾狐 帖子:559 积分:6288 威望:0 精华:0 注册:2008/9/7 20:15:00
  发帖心情 Post By:2021/2/27 19:57:00 [显示全部帖子]

柱状图_AfterLoad

 

'

'设定图表数据,因为只是演示,所以数据只用人工设置

'

Dim a() As  Integer = {100,90,80,85,70,80,101,105,75,66,88,110} 

Dim i均值 As Integer = 87.5

Dim i上限 As Integer = 100

Dim i下限 As Integer = 80

'

'生成图表

'

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()

Series = Chart.SeriesList.Add()

Series.Length = 12

Series.Text = "金额"

For i = 0 To 11

    Series.X(i) = i

    Series.Y(i) = a(i)

    Chart.AxisX.SetValueLabel(i, i+1 & "月")

Next

Chart.AxisX.AnnoWithLabels = True

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 zxb柱状图标辅助线()

zxb.SetXY(New PointF(-0.5,87.5),New PointF(11.5,87.5))

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 zxb柱状图标辅助线()

zxb.SetXY(New PointF(-0.5,80),New PointF(11.5,80))

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 zxb柱状图标辅助线()

zxb.SetXY(New PointF(-0.5,i上限),New PointF(11.5,i上限))

zxb.SetText("上限")

tl.CustomTrendLine = zxb


 回到顶部