1、这都代码看懂了没有?没有必要插入图表的啊,点击上一行下一行的时候,动态生成一个新的图表。
2、至于图表的内容,请自行编写代码得到。
Dim Chart As WinForm.Chart '定义一个图表变量
Dim Series As WinForm.ChartSeries '定义一个图系变量
Chart = e.Form.Controls("Chart1") ' 引用窗口中的图表
Chart.VisualEffect = True '加上这一行,让你的图表更漂亮
Chart.ChartType = ChartTypeEnum.Bar '图表类型该为Bar(条形)
Chart.SeriesList.Clear() '清除图表原来的图系
Chart.AxisX.ClearValueLabel
Dim t As Table = Tables("项目管理公司项目成本报表") '定义一个变量t引用数据表
Series = Chart.SeriesList.Add() '增加一个图系
Series.Text = "目标成本_计划总成本_人工费占比"
Series.Length = t.Rows.Count '设置图系的长度
For r As Integer = 0 To t.Rows.Count - 1
Series.X(r) = r
If t.Rows(r)("目标成本_计划总成本_人工费占比") <> Nothing Then
Series.Y(r) = t.Rows(r)("目标成本_计划总成本_人工费占比")
End If
Chart.AxisX.SetValueLabel(r, t.Rows(r)("工程名称简称")) '指定字符表示
Next
Series.DataLabelText = "{#YVAL:0.0%}"
Series = Chart.SeriesList.Add() '增加一个图系
Series.Text = "开工至今累计_实际成本_人工费占比"
Series.Length = t.Rows.Count '设置图系的长度
For r As Integer = 0 To t.Rows.Count - 1
Series.X(r) = r
If t.Rows(r)("开工至今累计_实际成本_人工费占比") <> Nothing
Series.Y(r) = t.Rows(r)("开工至今累计_实际成本_人工费占比")
End If
Next
Series.DataLabelText = "{#YVAL:0.0%}"
Chart.AxisX.AnnoRotation = 30'X轴标示逆时针旋转45度
Chart.LegendVisible = True '显示图列
Chart.LegendCompass= CompassEnum.South '图列显示在南方(底端)
Chart.AxisX.AnnoWithLabels = True '启用字符标示
Dim a As C1Chart.C1Chart = e.Form.Controls("Chart1").BaseControl
Dim b As C1Chart.ChartGroup = a.ChartGroups.Group0
'b.Use3D = True
a.ChartArea.Inverted = False
a.ChartArea.PlotArea.View3D.Depth = 40
a.ChartArea.PlotArea.View3D.Elevation = 20
a.ChartArea.PlotArea.View3D.Rotation = 8
a.ChartArea.PlotArea.View3D.Shading = 2
b.Bar.Appearance = 0
b.Bar.MultiRow = True
b.Use3D = True
b.Stacked = False