Dim Chart As WinForm.Chart '定义一个图表变量
Dim Series As WinForm.ChartSeries '定义一个图系变量
Dim t As Table = Tables("抽签入围台帐_Table01") '定义一个变量t引用数据表
Dim nms() As String = {"市内家数_比例","市外家数_比例"}
Chart = Forms("抽签入围台帐").Controls("Chart3") ' 引用窗口中的图表
Chart.AxisY.Min = 0 '指定Y轴的最小值
Chart.AxisY.Max = 100 '指定Y轴的最大值
Chart.HeaderText = "报名家数比例" '生成Chart总图名称
Chart.AxisX.ClearValueLabel '清除所有通过SetValueLabel设置的数值字符标示
Chart.SeriesList.Clear() '清除图表原来的图系
t.Sort = "抽签日期 DESC"
For Each c As String In nms
Series = Chart.SeriesList.Add() '增加一个图系
Series.Text = c '设置图系的标题
Series.Length = t.Rows.Count '设置图系的长度
Series.DataLabelText = "{#YVAL}%" '所有线条显示数据标示
Dim pval As Double = 0
For r As Integer = 0 To t.Rows.Count - 1
If t.Rows(r)(c) = 0 Then
For i As Integer = r+1 To t.Rows.count-1
If t.Rows(i)(c) > 0 Then
Series.X(r) = r
pval = pval+(t.Rows(i)(c)-pval)/(i-r+1)
Series.Y(r) = Round2(pval * 100,2)
Exit For
End If
Next
Else
pval = t.Rows(r)(c)
Series.X(r) = r
Series.Y(r) = Round2(pval * 100,2)
End If
Next
Series.FitType = FitTypeEnum.Spline '采用平滑线条
Next
For r As Integer = 0 To t.Rows.Count - 1
Chart.AxisX.SetValueLabel(r, Format(t.Rows(r)("抽签日期"),"MM-dd")) '指定字符表示
Next
Chart.AxisX.AnnoWithLabels = True '启用字符标示
'Chart.VisualEffect = True '加上这一行,让你的图表更漂亮
Chart.LegendVisible = True '显示图列
Chart.LegendCompass= CompassEnum.South '图列显示在南方(底端)
Chart.AxisX.AnnoRotation = - 45 'X轴标示逆时针旋转45度
Dim fnt As New Font("黑体",10)
Chart.AxisX.Font = fnt
Chart.AxisX.AnnoFormatString = "00.0%" '设置坐标轴的标示格式符号,指定日期标示格式