以下内容为程序代码:
1 \'----------------------绘图--------------------------
2 Dim Chart As WinForm.Chart \'定义一个图表变量
3 Dim Series As WinForm.ChartSeries \'定义一个图系变量
4 Chart= e.Form.Controls("Chart1") \' 引用窗口中的图表
5 Chart.ChartType = ChartTypeEnum.Bar \'设置图表类型
6 Chart.DataSource = "ATP储量产量表" \'设置绑定表
7 Chart.SeriesList.Clear() \'清除图表原来的图系
8 Series = Chart.SeriesList.Add() \'增加一个图系
9 Series.X.DataField = "ATP" \'X轴绑定到列
10 Series.Y.DataField = "可采储量_BCF" \'Y轴绑定到列
11
12 \'----------------------图表美化--------------------------
13 Chart.VisualEffect = True \'加上这一行,让图表更漂亮
14 Chart.LegendCompass= CompassEnum.South \'图列显示在底端
15 Chart.HeaderText = "各ATP储量柱状图"
16 Chart.AxisX.Text = "ATP"
17 Chart.AxisY.Text = "储量,BCF"
18 Series.DataLabelText = "{#YVAL}"
19 Series.DataLabelCompass =LabelCompassEnum.North
20 Chart.LegendVisible = False \'显示图列
以下内容为程序代码:
1 \'----------------------绘图--------------------------
2 Dim Chart As WinForm.Chart \'定义一个图表变量
3 Dim Series As WinForm.ChartSeries \'定义一个图系变量
4 Dim t As Table = Tables("ATP储量产量表") \'定义一个变量t引用数据表
5 Dim sm As Integer = t.Compute("Sum(可采储量_BCF)") \'计算总数量
6 Chart= Forms("ATP储量").Controls("Chart1") \' 引用窗口中的图表
7 Chart.ChartType = ChartTypeEnum.Pie \'图表1类型改为扇形
8 Chart.SeriesList.Clear() \'清除图表原来的图系
9 For Each r As Row In t.Rows
10 Series = Chart.SeriesList.Add() \'增加一个图系
11 Series.Length = 1 \'一个系列只能包括一个值
12 Series.Text = r("ATP") & "(" & r("可采储量_BCF") & ")" \'设置图系的标题
13 Series.Y(0) = r("可采储量_BCF") \'指定值
14 Series.DataLabelText = Math.Round(r("可采储量_BCF")*100/sm,2) & "%" \'计算百分比
15 Next
16 Chart.LegendVisible = True \'显示图列
17 Chart.LegendCompass= CompassEnum.East \'图列显示在右方
18 Chart.HeaderText = "各ATP储量扇形图"
19 Chart.VisualEffect = True \'加上这一行,让图表更漂亮