This is a migrated thread and some comments may be shown as answers.

Chart AxisX Integer Label Setting

2 Answers 50 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Indika
Top achievements
Rank 1
Indika asked on 05 May 2011, 01:11 AM
I have a chart where AxisX is a integer sequence that is updated programatically. The problem I am facing is, sometimes I get non integer values (such as 1.5, 2.5.... etc) as lables in addition to Integer labels. I do not want these non Integer labels to appear. How can I do this
1. Through C# code
2. Through XAML

The folowing is the basic code (validations removed) I am using,

 

private void SetXAxisSettings(RadChart chart, double axisMin, double axisMax)
{
 //Update the X Axis
 AxisX axisX = chart.DefaultView.ChartArea.AxisX;
 axisX.MinValue = axisMin;
 axisX.MaxValue = axisMax;
}

and, the following is the static settings I have in XAML

 

<telerik:AxisX LayoutMode="Between" LabelStep="1" Step="1" AutoRange="False" Title="Batch" />

2 Answers, 1 is accepted

Sort by
0
Indika
Top achievements
Rank 1
answered on 07 May 2011, 03:09 AM

Found a workaround,
But before that I should add that I was using a scrolbar which helped me display 8 bars in the Chart's visible area at a time (when I have more than 8 bars to display). I observed that the Minor Tick Count automatically increased as the number of bars increased.
I am not so happy about this workaround, but it works for me. So sharing with you,

private void SetXAxisSettings(RadChart chart, double axisMin, double axisMax)
{
    //Validation code removed
    //Define the X Axis
    AxisX axisX = chart.DefaultView.ChartArea.AxisX;
      
    double step = axisMax / 8 ; //Magic Number to demonstrate only, please read the description
    step = step > 0 ? step : 1 ; //Programatically define step to avoid an issue(?) in Telerik that duplicates xAxis labels
    axisX.AddRange(axisMin, axisMax, step);
}
0
Evgenia
Telerik team
answered on 10 May 2011, 08:12 AM
Hi Indika,

I'm glad that you was able to solve the issue on your own.
Also have in mind that when you set custom range for the axis , you should turn off AutoRange property so that the newly provided Step, MinValue and MaxValue are applied to the Axis. For more information you can refer to our help topic.

Kind regards,
Evgenia
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Chart
Asked by
Indika
Top achievements
Rank 1
Answers by
Indika
Top achievements
Rank 1
Evgenia
Telerik team
Share this question
or