嘿我的图表系列有问题
这是form.designer:
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series();
this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart();
chartArea1.Name = "ChartArea1";
this.chart1.ChartAreas.Add(chartArea1);
legend1.Name = "Legend1";
this.chart1.Legends.Add(legend1);
this.chart1.Location = new System.Drawing.Point(7, 17);
this.chart1.Name = "chart1";
series1.ChartArea = "ChartArea1";
series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
series1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
series1.IsXValueIndexed = true;
series1.Legend = "Legend1";
series1.MarkerColor = System.Drawing.Color.Red;
series1.MarkerSize = 6;
series1.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Diamond;
series1.Name = "SeriesBatchPoint";
this.chart1.Series.Add(series1);
this.chart1.Size = new System.Drawing.Size(1141, 323);
this.chart1.TabIndex = 3;
this.chart1.Text = "chart1";
在表格中我会说明一点
chart1.Series["SeriesBatchPoint"].Points.AddXY(BatchCount, aTempWeightMesure);
我收到此错误:
ArgumentException未处理
附加信息:名称为' SeriesBatchPoint'的图表元素无法在ChartAreaCollection'。
中找到
我做错了什么?
答案 0 :(得分:0)
试试这个:
var series1 = chart1.Series.Add("SeriesBatchPoint");
series1.ChartArea = "ChartArea1";
series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
// etc