Hello Simon,
The following example binds the X and Y values of a series to two columns of a data table. Please let us know if you have any questions or comments.
using System;
using System.Data;
using System.Windows.Forms;
using Nevron.Chart;
namespace SimpleDataBinding
{
public partial class Form1 : Form
{
DataSet m_DataSet;
public Form1()
{
InitializeComponent();
DataTable dataTable = new DataTable("MyTable");
dataTable.Columns.Add("Position", typeof(double));
dataTable.Columns.Add("Elevation", typeof(double));
dataTable.Rows.Add(new object[] { 13, 22 });
dataTable.Rows.Add(new object[] { 17, 42 });
dataTable.Rows.Add(new object[] { 21, 14 });
dataTable.Rows.Add(new object[] { 33, 24 });
dataTable.Rows.Add(new object[] { 36, 31 });
m_DataSet = new DataSet("MyDataSet");
m_DataSet.Tables.Add(dataTable);
}
private void Form1_Load(object sender, EventArgs e)
{
NChart chart = nChartControl1.Charts[0];
chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = new NLinearScaleConfigurator();
NLineSeries series = new NLineSeries();
series.UseXValues = true;
chart.Series.Add(series);
nChartControl1.DataBindingManager.AddBinding(0, 0, "XValues", m_DataSet, "MyTable.Position");
nChartControl1.DataBindingManager.AddBinding(0, 0, "Values", m_DataSet, "MyTable.Elevation");
}
}
}
Best Regards,
Nevron Support Team