To bind the data points of a certain series, you can use the Bind method, like shown in the following example:
Binding to NDataTable |
Copy Code
|
---|---|
// create a memory data table with some sample data NMemoryDataTable dataTable = new NMemoryDataTable( new NFieldInfo("Value", typeof(double), false), new NFieldInfo("XValue", typeof(double), false), new NFieldInfo("Label", typeof(string), false)); Random rnd = new Random(); for (int i = 0; i < 15; i++) { dataTable.AddRow( rnd.Next(0, 100), rnd.Next(0, 100), "Label: " + i.ToString()); } // create a point series to show the data source values NPointSeries pointSeries = new NPointSeries(); pointSeries.UseXValues = true; // bind line series pointSeries.DataPoints.Bind(new NDataSource(dataTable), new NKeyValuePair<string, string>("Value", "Value"), new NKeyValuePair<string, string>("XValue", "X"), new NKeyValuePair<string, string>("Label", "Label")); |
You can get the data source to which a NDataPointCollection is currently bound to via its DataSource property. If it is null, then the collection is currently not bound to any data source. You can unbind the collection by calling its Unbind method.