请教老师,下面两组代码的转换无法清除X轴的字符,同样的一个统计表XXX_Table1,如果第一次图表生成的X轴按年标示(2017 2018),第二次图表生成的X
轴按月份标示(1月 2月 3月),当第二次图表生成后,再返回点击第一次图表生成的按钮,X轴的字符就是 (2017月 2018月),实例代码如下:
第一组代码,X轴显示年,如2017 2018
Dim b1 As New SQLGroupTableBuilder("统计表00001","项目主表")
b1.C
b1.Groups.AddDef("日期", DateGroupEnum.Year, "年")
............
Dim Chart As WinForm.Chart '定义一个图表变量
Dim Series As WinForm.ChartSeries '定义一个图系变量
Chart = e.Form.Controls("Chart1") ' 引用窗口中的图表
Chart.VisualEffect = True '加上这一行,让你的图表更漂亮
Chart.ChartType = ChartTypeEnum.Bar '图表类型该为Bar(条形)
Chart.DataSource = "总分析_Table1" '设置绑定表
Chart.SeriesList.Clear() '清除图表原来的图系
Chart.AxisX.ClearValueLabel
Chart.AxisY.ClearValueLabel
Dim bchart = chart.BaseControl
bchart.ChartArea.AxisX.ForeColor = Color.Silver
bchart.ChartArea.AxisY.ForeColor = Color.Silver
Series = Chart.SeriesList.Add() '增加第一个图系
Series.Text = "投标数量"
Series.X.DataField = "年" 'X轴绑定到年列
Series.Y.DataField = "投标数量" 'Y轴绑定到数量列
Series.DataLabelText = "{#YVAL}"
Series = Chart.SeriesList.Add() '增加第二个图系
Series.Text = "任务数量"
Series.X.DataField = "年" 'X轴绑定到年列
Series.Y.DataField = "任务数量" 'Y轴绑定到数量列
Series.DataLabelText = "{#YVAL}"
第二组代码,X轴显示月,如1月,2月,3月....
Dim b1 As New SQLGroupTableBuilder("统计表00002","项目主表")
b1.C
b1.Groups.AddDef("日期", DateGroupEnum.Month, "月份")
.............
Dim Chart As WinForm.Chart '定义一个图表变量
Dim Series As WinForm.ChartSeries '定义一个图系变量
Chart = e.Form.Controls("Chart1") ' 引用窗口中的图表
Chart.VisualEffect = True '加上这一行,让你的图表更漂亮
Chart.ChartType = ChartTypeEnum.XYPlot '图表类型该为XYPlot(折线图)
Chart.DataSource = "总分析_Table1" '设置绑定表
Chart.SeriesList.Clear() '清除图表原来的图系
Chart.AxisX.ClearValueLabel
Chart.AxisY.ClearValueLabel
Chart.AxisX.AnnoFormatString = "0月"
Dim bchart = chart.BaseControl
bchart.ChartArea.AxisX.ForeColor = Color.Silver
bchart.ChartArea.AxisY.ForeColor = Color.Silver
Series = Chart.SeriesList.Add() '增加第一个图系
Series.Text = "投标数量"
Series.X.DataField = "月份" 'X轴绑定到月份列
Series.Y.DataField = "投标数量" 'Y轴绑定到数量列
Series.DataLabelText = "{#YVAL}"
Series = Chart.SeriesList.Add() '增加第二个图系
Series.Text = "任务数量"
Series.X.DataField = "月份" 'X轴绑定到月份列
Series.Y.DataField = "任务数量" 'Y轴绑定到数量列
Series.DataLabelText = "{#YVAL}"