MScharts 图表:覆盖列/条形值
好吧,这可能是一个新问题,但我几天前才开始编程。 因此,我从 MScharts 中获取了一个示例图表,它是在运行时动态创建的图表,代码如下:
private void DynamicChartCreation_Load(object sender, System.EventArgs e)
{
// Create a Chart
Chart1 = new Chart();
// Create Chart Area
ChartArea chartArea1 = new ChartArea();
// Add Chart Area to the Chart
Chart1.ChartAreas.Add(chartArea1);
// Create a data series
Series series1 = new Series();
Series series2 = new Series();
// Add data points to the first series
series1.Points.Add(34);
// Add data points to the second series
series2.Points.Add(14);
// Add series to the chart
Chart1.Series.Add(series1);
Chart1.Series.Add(series2);
// Set chart control location
Chart1.Location = new System.Drawing.Point(16, 48);
// Set Chart control size
Chart1.Size = new System.Drawing.Size(360, 260);
// Add chart control to the form
this.Controls.AddRange(new System.Windows.Forms.Control[] { this.Chart1 });
}
它是一个柱形图,我希望能够通过组合框动态更改列值。 问题是如何覆盖现有的旧值?
我用 Series.point.add 尝试过,如下所示:
Chart1.Series["Series1"].Points.AddY(comboBox_value);
但它不是将值应用于第一个 series1 列,而是创建另一个列,并在其旁边添加新值。
任何帮助将不胜感激,谢谢。
Ok this might be a newb question but I've only been programming since a few days.
So I took an example chart from MScharts that is a dynamically created graph during run-time, code is as follows:
private void DynamicChartCreation_Load(object sender, System.EventArgs e)
{
// Create a Chart
Chart1 = new Chart();
// Create Chart Area
ChartArea chartArea1 = new ChartArea();
// Add Chart Area to the Chart
Chart1.ChartAreas.Add(chartArea1);
// Create a data series
Series series1 = new Series();
Series series2 = new Series();
// Add data points to the first series
series1.Points.Add(34);
// Add data points to the second series
series2.Points.Add(14);
// Add series to the chart
Chart1.Series.Add(series1);
Chart1.Series.Add(series2);
// Set chart control location
Chart1.Location = new System.Drawing.Point(16, 48);
// Set Chart control size
Chart1.Size = new System.Drawing.Size(360, 260);
// Add chart control to the form
this.Controls.AddRange(new System.Windows.Forms.Control[] { this.Chart1 });
}
It is a column chart and I want to be able to change the column values dynamically via a combobox.
The question is how do I overwrite the existing old values?
I tried it with Series.point.add like this:
Chart1.Series["Series1"].Points.AddY(comboBox_value);
But instead of applying the value to the first series1 column, it creates another column with the new value right next to it.
Any help would be appreciated, thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在我的项目中为axix“X”进行了自定义,我将代码粘贴到这里,供您参考......
它在我的环境中运行良好...请在您的环境中检查它。
I did customize in my project for axix "X", I paste code here, for your reference...
It's working fine in my environment... Please, check it in your environment.