Hi,
Currently it is not possible to data bind the axis labels, but there is a relatively simple workaround. You can bind the Labels data series of the Bar series and copy the strings to the axis labels (after they are read from the data table). The following example demonstrated this approach:
void Form1_Load(object sender, EventArgs e)
{
dataTable = new DataTable("MyTable");
dataTable.Columns.Add("Value", typeof(double));
dataTable.Columns.Add("Name", typeof(string));
dataTable.Rows.Add(new object[] { 24, "George" });
dataTable.Rows.Add(new object[] { 19, "Larry" });
dataTable.Rows.Add(new object[] { 31, "Billy" });
dataTable.Rows.Add(new object[] { 29, "Stanley" });
dataTable.Rows.Add(new object[] { 25, "Michael" });
NChart chart = nChartControl1.Charts[0];
NBarSeries series = new NBarSeries();
series.DataLabelStyle.Format = "";
chart.Series.Add(series);
nChartControl1.DataBindingManager.AddBinding(0, 0, "Values", dataTable, "Value");
nChartControl1.DataBindingManager.AddBinding(0, 0, "Labels", dataTable, "Name");
dataTable.RowChanged += new DataRowChangeEventHandler(dataTable_RowChanged);
UpdateAxisLabels();
}
void dataTable_RowChanged(object sender, DataRowChangeEventArgs e)
{
UpdateAxisLabels();
}
void UpdateAxisLabels()
{
NChart chart = nChartControl1.Charts[0];
NBarSeries series = (NBarSeries)chart.Series[0];
NOrdinalScaleConfigurator scaleX = (NOrdinalScaleConfigurator)chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator;
scaleX.AutoLabels = false;
scaleX.Labels.Clear();
scaleX.Labels.AddRange(series.Labels);
nChartControl1.Refresh();
}
Best Regards,
Nevron Support Team