We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Feeding Chart with collection data

I'm wanting to manually add bars to my chart using a generic.list.collection. How do I establish a like to the collection and what might the code look like that takes the collection item as adds it to the chart.

[code]
For Each item As MeteredProduction In MPCollection
If Trim(item.UniversalID) = UID Then
'Add chart bar Here

End If
Next

[/code]

thanks

1 Reply

JB Jaffersathick B Syncfusion Team June 7, 2010 12:43 PM UTC

Hi Rob Jones,

Thank you for using Syncfusion products.

We suggest you to use “ChartDataBindModel” and bind the List collection with it by providing the XName and YNames of it . Create a series and set the “seriesModel” property as the object of “ChartDataBindModel”. This will plot the data contains in the List collection. When you are using the String values to XValue means we suggest you to add YNames alone to the model and Bind it with the series.
You can customize the Axislabels using “ChartDataBindAxisLabelModel” object by giving the “LabelName” property.

Please refer the following code snippet:
[CS]
ChartSeries series = new ChartSeries("Populations");

//Bind the above list to the chart control.
ChartDataBindModel dataSeriesModel = new ChartDataBindModel(bindList);

// If ChartDataBindModel.XName is empty or null, X value is index of point.
dataSeriesModel.YNames = new string[] { "Population" };
series.SeriesModel = dataSeriesModel;

//Customizing the axis labels .

ChartDataBindAxisLabelModel dataLabelsModel = new ChartDataBindAxisLabelModel();
//Setup a datasource for chart axis and populate axis labels.
dataLabelsModel.DataSource = bindList;
dataLabelsModel.LabelName = "Name";
chartControl1.PrimaryXAxis.LabelsImpl = dataLabelsModel;

chartControl1.PrimaryXAxis.TickLabelsDrawingMode = ChartAxisTickLabelDrawingMode.UserMode;


Please refer the Document from the following link:

http://help.syncfusion.com/ug_82/WindowsFormsUI_Chart/ChartDataBindingWithIEnumerables.html


http://help.syncfusion.com/ug_82/WindowsFormsUI_Chart/ChartData.html

Let me know if you have any other concerns.

Regards,
Jaffer.B

Loader.
Live Chat Icon For mobile
Up arrow icon