Profile Picture

Wrong Custom Labels Axis

Posted By Siocnarf 12 Years Ago
Author
Message
Siocnarf
biggrin Posted 12 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: Forum Members
Last Active: 11 Years Ago
Posts: 3, Visits: 1
Hello,

I am trying to set a Custom Label X Axis with values 1, 2, 3, 4, 5, 20. When I set that by code, the ticks labels showed on the axis are 2,3,4,5,20. And everything is offset, so tick 1 get the label text 2, tick 2 gets the label text 3, and the last label is empty.

What I am doing wrong? Here is the code :



var numericScale = (NNumericScaleConfigurator)Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator;
numericScale.AutoLabels = false;

List maturityLabelAxis = new List {1, 2, 3, 4, 5, 20};

var axisView = (NRangeAxisView)Chart.Axis(StandardAxis.PrimaryX).View;
axisView.Range = new NRange1DD(maturityLabelAxis.First(), maturityLabelAxis.Last());

// Set major tick et labels
numericScale.CustomMajorTicks.Clear();
numericScale.Labels.Clear();
numericScale.MajorTickMode = MajorTickMode.CustomTicks;
numericScale.Origin = maturityLabelAxis.First();

foreach (double maturityLabelInYears in maturityLabelAxis)
{
numericScale.CustomMajorTicks.Add(maturityLabelInYears);
numericScale.Labels.Add(string.Format("{0}", maturityLabelInYears));
}

Thanks for your help.


Siocnarf
Posted 12 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: Forum Members
Last Active: 11 Years Ago
Posts: 3, Visits: 1
OK. I've solved my problem.

I use numericScale.CustomLabels instead of numericScale.Labels and this solved my problem.

Nevron Support
Posted 12 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009

Hi Francois,

Most likely the problem with the initial approach is that you use a custom origin value - that way the value of 1 maps to the second label (not the first one). Anyway going with custom numeric labels is better as it ensures that you decorate the values correctly. Let us know if you meet any problems or have any questions.



Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic