Applies to: Nevron Chart for .NET
How to assign custom labels to dimension (ordinal) axis?
You need to disable the automatic label generation for such an axis and manually pass the labels displayed by each category. The following code shows how to create a simple bar chart showing three bars with custom labels for the X axis.
[C#]
NChart chart = nChartControl1.Charts[0];
chart.Axis(StandardAxis.PrimaryX).DimensionScale.AutoLabels =
false
;
chart.Axis(StandardAxis.PrimaryX).Labels.Clear();
chart.Axis(StandardAxis.PrimaryX).Labels.Add(
"Jan"
);
chart.Axis(StandardAxis.PrimaryX).Labels.Add(
"Feb"
);
chart.Axis(StandardAxis.PrimaryX).Labels.Add(
"Mar"
);
NBarSeries bar = (NBarSeries)chart.Series.Add(SeriesType.Bar);
bar.Values.Add(10);
bar.Values.Add(20);
bar.Values.Add(24);
nChartControl1.Refresh();
[VB.NET]
Dim
chart
As
NChart = NChartControl1.Charts(0)
chart.Axis(StandardAxis.PrimaryX).DimensionScale.AutoLabels =
False
chart.Axis(StandardAxis.PrimaryX).Labels.Clear()
chart.Axis(StandardAxis.PrimaryX).Labels.Add(
"Jan"
)
chart.Axis(StandardAxis.PrimaryX).Labels.Add(
"Feb"
)
chart.Axis(StandardAxis.PrimaryX).Labels.Add(
"March"
)
Dim
bar
As
NBarSeries =
CType
(chart.Series.Add(SeriesType.Bar), NBarSeries)
bar.Values.Add(10)
bar.Values.Add(20)
bar.Values.Add(24)
NChartControl1.Refresh()
Article ID: 68, Created On: 10/6/2010, Modified: 11/15/2010