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

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

5 Answers 210 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Jason Xiao
Top achievements
Rank 1
Jason Xiao asked on 09 Jul 2010, 12:52 AM
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.

5 Answers, 1 is accepted

Sort by
0
Accepted
Ves
Telerik team
answered on 13 Jul 2010, 08:48 AM
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
0
Ralph
Top achievements
Rank 1
answered on 02 Sep 2010, 02:45 AM
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
0
Ves
Telerik team
answered on 06 Sep 2010, 12:17 PM
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
0
Stephanie
Top achievements
Rank 1
answered on 23 Apr 2015, 07:45 PM
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.
0
Petar Marchev
Telerik team
answered on 27 Apr 2015, 07:22 AM
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.

 
Tags
Chart
Asked by
Jason Xiao
Top achievements
Rank 1
Answers by
Ves
Telerik team
Ralph
Top achievements
Rank 1
Stephanie
Top achievements
Rank 1
Petar Marchev
Telerik team
Share this question
or