Dim dt1 As DataTable = DataTables("计划表_Smt统计表")
Dim dt As DataTable = DataTables("订单明细跟踪表")
Dim mind As Date = dt.Compute("min(SMT_开始生产_计划)", "")
Dim maxd As Date = dt.Compute("max(SMT_完成生产_计划)", "")
dt1.DeleteFor("")
Do While mind <= maxd
Dim nr As DataRow = dt1.AddNew
nr("日期") = mind
Dim sum As Double = 0
For Each dr As DataRow In dt.Select("SMT_开始生产_计划 <= #" & mind & "# and SMT_完成生产_计划 >= #" & mind & "#")
Dim sp1 As TimeSpan = dr("SMT_完成生产_计划") - dr("SMT_开始生产_计划")
Dim D1 As Integer = sp1.Days +1
sum += dr("SMT_欠数") /d1
'Dim sp2 As TimeSpan = cdate(dr("SMT_完成生产_计划")) - mind
'sum += dr("SMT_欠数") * (sp2.TotalDays / sp1.TotalDays)
Next
nr("欠数") = sum
mind = mind.AddDays(1)
Loop
Dim Chart As WinForm.Chart '定义一个图表变量
Dim Series As WinForm.ChartSeries '定义一个图系变量
Dim t As Table = Tables("计划表_Smt统计表") '定义一个变量t引用数据表
Chart= e.Form.Controls("ChartSmt") ' 引用窗口中的图表
Chart.SeriesList.Clear() '清除图表原来的图系
'Chart.AxisX.Min=0
'Chart.AxisX.Max = 31
'Chart.AxisX.Major=1
chart.AxisX.ClearValueLabel
'Chart.Axisy.Min=100
'Chart.Axisy.Max = 1000
'Chart.Axisy.Major=100
Chart.ChartType = ChartTypeEnum.Bar
Series = Chart.SeriesList.Add() '增加一个图系
Series.Length = t.Rows.Count '图系的数据点数等于表的行数
For i As Integer = 0 To t.Rows.Count - 1 '指定每个数据点的位置
Series.X(i) = i '指定水平坐标
Series.Y(i) = t.Rows(i)("欠数") '指定垂直坐标
Chart.AxisX.SetValueLabel(i, format(t.Rows(i)("日期"), "dd")) '指定字符表示
Next
Chart.AxisX.AnnoWithLabels = True '启用字符标示
Series.DataLabelText = "{#YVAL}"
series.DataLabelCompass = LabelCompassEnum.North