Can an additional y-axis share "0"

4 posts, 0 answers
  1. Jason
    Jason avatar
    19 posts
    Member since:
    Mar 2012

    Posted 21 Jun 2012 Link to this post

    Hello,
    Can an additional y-axis on the right be set up so that it's 0 value lines up with the standard y-axis 0 on the left? On the standard axis I am plotting something like profit vs. expenses with the yellow line displaying the net difference. On the additional y-axis I am displaying a grand total on a significantly larger scale. Since the grand total is never negative the additional y-axis has 0 at the bottom but ideally I would like it's 0 to line up with the standard axis 0. Thanks much in advance!
    Jason
  2. Rosko
    Admin
    Rosko avatar
    137 posts

    Posted 22 Jun 2012 Link to this post

    Hi Jason,

    To achieve the desired effect you need to set to both axes the same minimum and maximum values. In order to do so you need to set a couple of properties. Please refer to the online help topic and the code snippet below.
    additionalAxis.AutoRange = radChart.DefaultView.ChartArea.AxisY.AutoRange = false;
    additionalAxis.MinValue = radChart.DefaultView.ChartArea.AxisY.MinValue = -120;
    additionalAxis.MaxValue = radChart.DefaultView.ChartArea.AxisY.MaxValue = 120;
    additionalAxis.Step = 10;
    radChart.DefaultView.ChartArea.AxisY.Step = 10;

    You have to set for both axes the AutoRange property to false. Then the MinValue and MaxValue properties have to be the same, as well, so that the values on both axes are aligned. Have in mind that when you disable AutoRange, RadChart requires you to set the Step property. For the two axes, two different values can be set.


    Kind regards,
    Rosko
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. UI for WPF is Visual Studio 2017 Ready
  4. Jason
    Jason avatar
    19 posts
    Member since:
    Mar 2012

    Posted 22 Jun 2012 Link to this post

    Thanks for the reply Rosco!
    The issue is that I do not want the the minimum, maximum, and step values for both axis to be the same, that would not require an additional axis if I'm understanding correctly. My additional axis is on a much larger scale (values are ~10x larger than the values displayed on the standard axis) so it's min/max/step values will be dramatically larger. What I'm after is that the two axis 'share' a 0 value rather than having a different 0 on the left axis vs the right axis..
  5. Rosko
    Admin
    Rosko avatar
    137 posts

    Posted 26 Jun 2012 Link to this post

    Hello Jason,

    What you are saying is true. If scaling is the case, you can scale the axis as well. If for the default axis you are having Min =-120, Max = 120 and Step = 10, for the additional axis you can have the same but multiplied by 10, 100 or even 10000, as much as you would like. What you will get, you can see in the image that I have attached. I hope this helps.
    additionalAxis.AutoRange = radChart.DefaultView.ChartArea.AxisY.AutoRange = false;
    radChart.DefaultView.ChartArea.AxisY.MinValue = -120;
    radChart.DefaultView.ChartArea.AxisY.MaxValue = 120;
    radChart.DefaultView.ChartArea.AxisY.Step = 10;
    additionalAxis.MinValue = -12000;
    additionalAxis.MaxValue = 12000;
    additionalAxis.Step = 1000;


    Greetings,
    Rosko
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top