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

Y axis autorange with minvalue

2 Answers 129 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Michal
Top achievements
Rank 1
Michal asked on 18 Apr 2013, 01:22 PM
I can't get the desired with RadChart Control.

I want to make my Y-Axis autorange only in one direction - up.
The min value should be 0.

I can't achieve this anyway, because: (let me quote)
  • MinValue and MaxValue - use to set the minimal and maximal value of the axis. (AutoRange must be set to false for the Step to be regarded)
  • Step - indicates the step used when placing ticks along the axis. (AutoRange must be set to false for the Step to be regarded)
  • AutoRange - when True the axis will calculate its MinValue, MaxValue and Step automatically. When False, you have to manually set the appropriate values for each of these properties.

Should I enumerate my data items and get the max value of them and set to my y axis max value?

Axis-Y has property I think should resolve my problem, but its inconsistent with the previous quote:

AxisY.ExtendDirection is of type AxisExtendDirection and has the following options:

  • Up - when selected, the upper end of the axis will be extended.
  • Down - when selected, the lower end of the axis will be extended.
  • Both - when selected, the upper and the lower end of the axis will be extended.
  • Smart - when selected, the upper and the lower end of the axis will be extended unless 0 is set to MinValue or MaxValue. In this case the axis will not be extended in the respective direction.
  • None - when selected, the axis will not be extended.

Smart mode would be my solution, but its not working.

Screen to better illustrate my problem: http://screencast.com/t/oTo1V0Vf2Gl. I want max to be autorange and min 0, so bars starts from 0 value.

Any help appreciated

2 Answers, 1 is accepted

Sort by
0
Accepted
Petar Marchev
Telerik team
answered on 22 Apr 2013, 10:45 AM
Hi Michal,

We are sorry to hear that you are experiencing issues with our controls. I will try to briefly sum up and explain how the AutoRange and the ExtendDirection work.

The axis will work in either a auto mode or fully manual mode. If you set the AutoRange to true - you will have to set the min, max and step. It is not possible to set only the minimum and keep the automatic generated maximum (this is possible in the new ChartView).

The ExtendDirection has little to do with the range. If the axis is in automatic mode (AutoRange = true) the axis would have calculated the range before the ExtendDirection property was taken into consideration. Say that the min was calculated to be 0, the step 20 and the max was calculated to be 80 (if the maximum value in the data was 79). If the ExtendDirection is Up - then the range would be extended to 100 (a reason for this could be to make place for the label "79"). If the ExtendDirection is None, then the auto range would not be extended and it would be 80 (with data max being 79).

You can try to set the IsZeroBased property and see if you get the behavior that you desire:
this.radChart1.DefaultView.ChartArea.AxisY.IsZeroBased = true;

Alternatively you can iterate your data and find the data min and data max and build up the desired manual range. I hope this helps.

Greetings,
Petar Marchev
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Michal
Top achievements
Rank 1
answered on 23 Apr 2013, 11:51 AM
Thank you,

It solved my problem =]
Tags
Chart
Asked by
Michal
Top achievements
Rank 1
Answers by
Petar Marchev
Telerik team
Michal
Top achievements
Rank 1
Share this question
or