Chart = e.Form.Controls("Chart2") ' 引用窗口中的图表
Chart.ChartType = ChartTypeEnum.Bar '设置图表类型
Chart.ChartType2 = ChartTypeEnum.XYPlot '图表2类型该为线形
Chart.SeriesList.Clear() '清除图表原来的图系
chart.AxisX.ClearValueLabel
chart.AxisY.ClearValueLabel
Series = Chart.SeriesList.Add() '增加一个图系
Dim b As Integer = b
Series.Length = lst4.Count '图系的数据点数等于表的行数
Series.Text = "平日加班"
For k As Integer = 0 To lst4.Count - 1 '指定每个数据点的位置
Series.X(k) = k '指定水平坐标
Dim dttr As DataRow
'dttr = dtt.Find("cus_xi = '" & lst3(k) & "' and bd >= '" & dt3 & "' And bd <= '" & dt4 & "'")
dttr = dt.Find("empname = '" & lst4(k) & "' and bd = '" & dt3 & "'") '=====个人平均加班
If dttr IsNot Nothing Then
Series.Y(k) = CInt(Format(dttr("平时加班"), "0"))
Else
Series.Y(k) = 0
End If
Chart.AxisX.SetValueLabel(k, lst4(k)) '指定字符表示
Next
Series.FillColor = Color.Green
series.MarkShape = MarkShapeEnum.None
Series.TooltipText = "{#YVAL}"
Series.DataLabelText = "{#YVAL}"
series.DataLabelForeColor = Color.blue
Series.DataLabelCompass = LabelCompassEnum.North
Series = Chart.SeriesList.Add() '给图表2增加一个图系
Series.Length = lst4.Count '图系的数据点数等于表的行数
Series.Text = "休出加班"
For ii As Integer = 0 To lst4.Count - 1 '指定每个数据点的位置
Series.X(ii) = ii '指定水平坐标
Dim dttr As DataRow
dttr = dt.Find("empname = '" & lst4(ii) & "' and bd = '" & dt3 & "'") '=====个人平均加班
If dttr IsNot Nothing Then
Series.Y(ii) = CInt(Format(dttr("休出加班") , "0"))
Else
Series.Y(ii) = 0
End If
Chart.AxisX.SetValueLabel(ii, lst4(ii)) '指定字符表示
Next
Series.FillColor = Color.LightBlue
Chart.Stacked = True
Series.TooltipText = "{#YVAL}"
Series.DataLabelText = "{#YVAL}"
Series.DataLabelCompass = LabelCompassEnum.North
Dim mm As Integer = Chart.AxisY.Max
Chart.SeriesList2.Clear() '清除图表原来的图系
Series = Chart.SeriesList2.Add() '给图表2增加一个图系
Series.Length = lst4.Count '图系的数据点数等于表的行数
Series.Text = "加班标志线"
For iii As Integer = 0 To lst4.Count - 1 '指定每个数据点的位置
Series.X(iii) = iii '指定水平坐标
Series.Y(iii) = 28
Next
Chart.AxisY.MinorTick = False 'Y轴不显示副刻度
Chart.AxisX.AnnoRotation = - 45
Chart.LegendVisible = True '显示图列
Chart.LegendCompass = CompassEnum.South '图列显示在南方(底端)
Chart.AxisX.AnnoWithLabels = True '启用字符标示
这个28是不固定