Chart / Import and Export / Import / Data Binding
In This Topic
    Data Binding
    In This Topic

    In NOV Chart, Data Binding is the ability to bind the data points of a certain series with the rows and values from a NDataSource (see Data Sources for more info). It is important to know that currently only one-way data binding is supported. This means that the chart data points and their values will change, when the data table to which they are bound is changed, but not the other way around.

     

     Binding to a Data Source

    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.