How to add data to the Chartcontrol in WinForms Chart?
After placing the ChartControl from the toolbar, the ChartSeries class must be declared, and points can be added to that series using the Add method. Finally, the series should be added to the ChartControl class. By default, a column chart is displayed in WinForms Chart.
C#
//Series 1 is populated using data from the ViewModel.
ChartSeries chartSeries1 = new ChartSeries("Series 1");
chartSeries1.CategoryModel = dataSeriesModel;
dataSeriesModel.CategoryName = "XValue";
dataSeriesModel.YNames = new string[] { "YValue" };
this.chartControl1.Series.Add(chartSeries1);
//Series 2 is populated using direct data points.
ChartSeries chartSeries2 = this.chartControl1.Model.NewSeries("Series 2");
chartSeries2.Points.Add(0, 70);
chartSeries2.Points.Add(1, 75);
chartSeries2.Points.Add(2, 80);
chartSeries2.Points.Add(3, 65);
chartSeries2.Points.Add(4, 90);
this.chartControl1.Series.Add(chartSeries2);
VB
'Series 1 is populated using data from the ViewModel.
Dim ChartSeries1 As ChartSeries = New ChartSeries("Series 1")
ChartDataBindModel1.CategoryName = "XValue"
ChartDataBindModel1.YNames = New String() {"YValue"}
ChartSeries1.CategoryModel = ChartDataBindModel1
columnChart.Series.Add(ChartSeries1)
'Series 2 is populated using direct data points.
Dim ChartSeries2 As ChartSeries = columnChart.Model.NewSeries("Series 2")
ChartSeries2.Points.Add(0, 70)
ChartSeries2.Points.Add(1, 75)
ChartSeries2.Points.Add(2, 80)
ChartSeries2.Points.Add(3, 65)
ChartSeries2.Points.Add(4, 90)
columnChart.Series.Add(ChartSeries2)
Conclusion
I hope you enjoyed learning about how to add data to the Chartcontrol in WinForms Chart.
You can refer to our WinForms Chart feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started with configuration specifications. You can also explore our WinForms Chart examples to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!