How to line up multi Y-axis' 0 level?

6 posts, 1 answers
  1. Jason Xiao
    Jason Xiao avatar
    2 posts
    Member since:
    Mar 2010

    Posted 08 Jul 2010 Link to this post

    We have 2 Y-axis on the same chart and we need to force the 0s lined up for these two Y-axis.  What's the best way to do this?

    Take a look the attached png file, you can see two Y-axis have 0 at different levels.
  2. Answer
    Ves
    Admin
    Ves avatar
    2879 posts

    Posted 13 Jul 2010 Link to this post

    Hello Jason Xiao,

    RadChart will not align the two Y axes automatically, so you will need to set their AutoRange properties to false and configure their range, so that the zeroes are aligned. Here is an example:

    RadChart1.DefaultView.ChartArea.AxisY.AutoRange = false;
    RadChart1.DefaultView.ChartArea.AdditionalYAxes[0].AutoRange = false;
    RadChart1.DefaultView.ChartArea.AxisY.AddRange(-10, 35, 5);
    RadChart1.DefaultView.ChartArea.AdditionalYAxes[0].AddRange(-400, 1400, 200);


    That is -- the additional Y axis' min, max and step are 40 times their counterparts in the main one.

    Kind regards,
    Ves
    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
  3. DevCraft banner
  4. Ralph
    Ralph avatar
    6 posts
    Member since:
    Aug 2007

    Posted 01 Sep 2010 Link to this post

    Good afternoon Ves

    I am having a similar problem using a second Y Axis. See attached image...

    Note that the tool tip for the line series is showing $0 which is the correct amount for that time point afetr the payment of $178.09 dollars has occurred as seen in the 'Payment Schedule' seen to the right in the picture.
    The chart is declared in the XAML as follows:

    <telerik:RadChart x:Name="myChart"
                      Width="300"
                      Margin="0 10 0 10"
                      Height="300"
                      UseDefaultLayout="False"
                      telerik:StyleManager.Theme="Windows7"
                      Visibility="Collapsed">
        <Grid ShowGridLines="False">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <telerik:ChartTitle Content="Payments and Balances"
                                Grid.Row="0"
                                telerik:StyleManager.Theme="Windows7" />
            <telerik:ChartArea x:Name="ChartArea1"
                               LegendName="ChartLegend1"
                               Grid.Row="1"
                               Padding="2 2 2 2"
                               Height="230"
                               Width="250"
                               telerik:StyleManager.Theme="Windows7" />
     
        </Grid>
    </telerik:RadChart>

    And populated by code as follows:
    Dim barSeries As DataSeries = GetPaymentSeriesForChart()
     
    barSeries.LegendLabel = "Payments"
    barSeries.Definition = New BarSeriesDefinition
    barSeries.Definition.ShowItemLabels = False
    barSeries.Definition.ShowItemToolTips = True
    barSeries.Definition.ItemToolTipFormat = "#Y{C0}"
     
    Dim lineSeries As DataSeries = GetBalanceSeriesForChart()
     
    lineSeries.LegendLabel = "Balance"
    lineSeries.Definition = New LineSeriesDefinition
    lineSeries.Definition.ShowItemLabels = False
    lineSeries.Definition.ShowItemToolTips = True
    lineSeries.Definition.ItemToolTipFormat = "#Y{C0}"
     
    lineSeries.Definition.AxisName = "Balance"
     
    ChartArea1.AxisX.AutoRange = True
    ChartArea1.AxisX.DefaultLabelFormat = "MMM-yy"
    ChartArea1.AxisX.LabelRotationAngle = -90
     
    ChartArea1.AxisY.AutoRange = False
    ChartArea1.AxisY.DefaultLabelFormat = "#VAL{C0}"
    ChartArea1.AxisY.LabelRotationAngle = -30
    ChartArea1.AxisY.AddRange(0, _paymentMax, GetYScale(_paymentMax, 5))
     
    ChartArea1.AdditionalYAxes.Clear()
    ChartArea1.AdditionalYAxes.Add(New AxisY())
    ChartArea1.AdditionalYAxes(0).AxisName = "Balance"
    ChartArea1.AdditionalYAxes(0).DefaultLabelFormat = "#VAL{C0}"
    ChartArea1.AdditionalYAxes(0).LabelRotationAngle = 30
    ChartArea1.AdditionalYAxes(0).AutoRange = False
    Try
        ChartArea1.AdditionalYAxes(0).AddRange(0, CDbl(txtBxAmntOwing.Text) * 1.1, GetYScale(CDbl(txtBxAmntOwing.Text) * 1.1, 5))
    Catch ex As Exception
     
    End Try
     
    ChartArea1.DataSeries.Clear()
    ChartArea1.DataSeries.Add(barSeries)
    ChartArea1.DataSeries.Add(lineSeries)

    Note that I am trying to have both Y-Axes have $0 as their starting minimum value. It would seem that the values on the chart are correct when checked by showing the tooltips for the datapoints but the additional Y-Axis (on the right) ends up with the wrong values.

    Any thoughts on what I am doing wrong would be most appreciated.

    Regards

    Ralph Price
  5. Ves
    Admin
    Ves avatar
    2879 posts

    Posted 06 Sep 2010 Link to this post

    Hello Ralph,

    Thanks for the details. I was able to reproduce the issue. I have logged it in our public issue tracking system, you can find it here.  The fix will be available in one of the next internal builds and in the next official version -- Q3 2010. I have updated your Telerik points.

    Best regards,
    Ves
    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
  6. Stephanie
    Stephanie avatar
    1 posts
    Member since:
    Feb 2015

    Posted 23 Apr 2015 in reply to Ves Link to this post

    I have this exact problem.  The proposed solution does work, but in my situation the calculations are anything but trivial.  Is the solution that was posted in 2010 still my only option five years later?  I have spent hours and hours and hours trying to solve this issue.
  7. Petar Marchev
    Admin
    Petar Marchev avatar
    968 posts

    Posted 27 Apr 2015 Link to this post

    Hi Stephanie,

    We do not have this range-sync feature in neither of our charts (nor the old RadChart, nor the new ChartView). You need to set a manual range for at least one of the axes, may be both.

    Regards,
    Petar Marchev
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
Back to Top
DevCraft banner