Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How to use LabelType.CustomText on Axis of a LineChart? (Read 1755 times)
trbld21
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 4
Joined: Apr 18th, 2020
How to use LabelType.CustomText on Axis of a LineChart?
Apr 18th, 2020 at 8:31pm
Print Post  
Hi.
I'm trying to replace the LabelType.AutoScale parameter of an Axis, with my custom text. However it doesn't work. Probably I have not understood correctly something.

Thus I have the code:
Code (C++)
Select All
            Axis axis = new Axis();
            axis.MinValue = 0;
            axis.MaxValue = 288;
            axis.Interval = 1;
            axis.Tick = 1;
            axis.IntervalCount = 10;
            axis.LabelType = LabelType.CustomText;
            List<string> axisList = new List<string>();
            axisList.Add("1");
            axisList.Add("2");
            axisList.Add("3");
            axisList.Add("4");
            axisList.Add("5");
            axisList.Add("6");
            axisList.Add("7");
            axisList.Add("8");
            axisList.Add("9");
            axisList.Add("10");
            axis.Labels = axisList.AsReadOnly();
            lineChart.XAxes.Add(axis);
 


I would expect this code to add the numbers 1-10 in the axis, in 10 different positions equally spaced in-between them. Instead I don't get any label on the Axis of the LineChart.

What am I doing wrong?
How can I add values "1" to "10" in the Axis (while having values 0-288; thus replacing 0 with "1" and 288 with "10")?

Thanks.
  
Back to top
 
IP Logged
 
Forum Admin
YaBB Administrator
*****
Offline


Rock and Roll

Posts: 696
Joined: Apr 6th, 2003
Re: How to use LabelType.CustomText on Axis of a LineChart?
Reply #1 - Apr 19th, 2020 at 8:43am
Print Post  
Hi,

The AxisSettings.CustomLabelPositionhttps://www.mindfusion.eu/onlinehelp/wpfchart/index.htm?P_MindFusion_Charting_Wp... property is meant to be used when the label type is CustomLabels to tell the control if the custom labels will be rendered at data points or at the auto scale intervals.

In your case:

axis.CustomLabelPosition = CustomLabelPosition.AutoScalePoints;

Note that the chart is initialized with one axis in the XAxes collection. So, if you don't want "axis" to be added to the default one call:

lineChart.XAxes.Clear();

before adding your new "axis".

Let me know if that works.

Kind Regards,
Iva
  
Back to top
WWW  
IP Logged
 
trbld21
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 4
Joined: Apr 18th, 2020
Re: How to use LabelType.CustomText on Axis of a LineChart?
Reply #2 - Apr 19th, 2020 at 9:02am
Print Post  
I just added your proposed code:

Code (C++)
Select All
axis.CustomLabelPosition = CustomLabelPosition.AutoScalePoints; 



after my code line:
Code (C++)
Select All
axis.LabelType = LabelType.CustomText; 



And it did worked! Cheesy

Thanks a lot!
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint