'---------------------------------生成统计表------------------
Dim g As New CrossTableBuilder("统计表1", DataTables("课程信息"))
g.HGroups.AddDef("培训时间", DateGroupEnum.Year, "年")
g.VGroups.AddDef("课程")
g.Totals.AddDef("实际人数", "实际人数")
g.Totals.AddDef("人天统计", "人天统计")
g.VerticalProportion = True
g.VerticalProportion Caption ="/实际人数" '论坛有Bug ,请将[g.VerticalProportion Caption]间的空格去掉
g.Build()
'-----------------------------------生成图表----------------------
Dim Chart As WinForm.Chart '定义一个图表变量
Dim Series As WinForm.ChartSeries '定义一个图系变量
Dim t As Table = Tables("统计表1") '定义一个变量t引用数据表
Chart = e.Form.Controls("Chart1") ' 引用窗口中的图表
Chart.SeriesList.Clear()
Chart.ChartType = ChartTypeEnum.Bar '图表类型改为Bar(条形)
Chart.DataSource = "统计表1" '设置绑定表
chart.AxisX.Major = 1
Chart.AxisY.Major = 100
Chart.AxisY.Min = 0 '指定Y轴的最小值
For Each c As Col In t.Cols
If c.Caption.Contains("实际人数/") Then
c.Visible = False
End If
c.DataCol.SetFormat("#,###")
Next
For Each r As Row In t.Rows
For Each c As Col In t.Cols
If c.Caption.Contains("人天统计/") Then
r(c.name) =t(r.Index,c.Index-1)/t(r.Index,c.Index-3)
End If
Next
Next
For Each c As Col In t.Cols
If c.Name <> "年" Then
If c.Visible = True Then
Series = Chart.SeriesList.Add() '增加一个图系
Series.Text = c.Caption 'Name '设置图系的标题
Series.X.DataField = "年" 'X轴绑定到产品列
Series.Y.DataField = c.Name '设置Y轴的绑定列
Series.DataLabelText = "{#YVAL}"
End If
End If
Next
'Chart.VisualEffect = True '加上这一行,让你的图表更漂亮
Chart.LegendVisible = True '显示图列
Chart.LegendCompass= CompassEnum.South '图列显示在南方(底端)
ChaRT.HeaderText = "课程分析-人天统计"
Chart.AxisX.Text = "年份"
[此贴子已经被作者于2013-3-25 22:26:37编辑过]