X-Axis labels on Bar-charts


Author
Message
Johan Carlsson
Johan Carlsson
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)
Group: Forum Members
Posts: 2, Visits: 1
Hello,

In your Bar-chart gallery you have an example chart with "Tomatoes", "Oranges", "Bananas" etc. etc.. The X-Axis of this chart displays 1, 2, 3.. I was wondering if it is possible to make the X-Axis display "Tomatoes", "Oranges" instead of numbers.. And if so, how do you do it?

Regards, Johan
Reply
David Huxtable
David Huxtable
Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)
Group: Forum Members
Posts: 13, Visits: 1
Good Morning Johan,

I believe All Examples -> Axes -> General -> Axes Labels contains what you are looking for.

Ensure you have set the AutoLabels property of your scale configurator to false.

Next execute your scaleconfigurator's Clear() method to ensure the labels of the x axis are removed and 1, 2, 3...etc are not displayed.

Finally add your desired x axis label values to your scale configurator's Labels enumeration.

For example:

// Create a linear scale configurator object and apply it to the primary x axis.
NLinearScaleConfigurator scaleXConfig = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator;

// Ensure all your x-axis labels are displayed in the chart.
scaleConfigX.MajorTickMode = MajorTickMode.AutoMaxCount;

// Disable auto labels (this creates your 1, 2, 3..etc as far as I understand).
scaleConfigX.AutoLabels = false;

// Add your custom labels.
scaleConfigX.Labels.Add("Tomatoes");
scaleConfigX.Labels.Add("Oranges");
scaleConfigX.Labels.Add("Bananas");

I hope this post has helped Johan,

David.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search