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

Multiple LineSeries with Two Y Axis and switching Y axis dynamically

5 Answers 176 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
N
Top achievements
Rank 1
N asked on 19 Sep 2012, 02:19 PM
Hi,
Can you provide example where it has multiple lineseries with maximum of two vertical axes, sharing X axis.
And having the ability to dynamically switch axes for line series. 
For example Three lineSeries A,B and C.
All A,B,C have veritcal axes default location set as Left.
I have button on my UI that lets user change axes location --from Left and Right. and Right to Left for each series.

Could not find any sample in Teleriks forum that does something similar. I tried to do this, but I seem to change the axes one time, second time it does not work. 
I created two axis one default 

<

 

 

telerik1:RadCartesianChart.VerticalAxis>

 

 

 

 

<telerik1:LinearAxis Name="LeftAxis" ElementBrush="DarkGreen"/>

 

 

 

 

</telerik1:RadCartesianChart.VerticalAxis>
and one additional axis as in sample

 

 

<

 

 

telerik1:RadCartesianChart.Resources>

 

 

 

 

<telerik1:LinearAxis HorizontalLocation="Right" Name="RightAxis" x:Key="additionalVerticalAxis" ElementBrush="Blue" FontWeight="Bold" />

 

 

 

 

</telerik1:RadCartesianChart.Resources>

 


In the code behind I try to switch a linerseries vertical axis back and forth using

 

 

if(yAxisType == YAxisType.Left){ //User picked left

 

lineSeries.VerticalAxis.Name =

 

string.Empty; //To pick the default one?

 

}

 

 

if(yAxisType == YAxisType.Right){//User picked right

 

lineSeries.VerticalAxis = View.TryFindResource("additionalVerticalAxis");

 

// _rightLinearAxis;

 

}


Problem seems to be that Line series A has range of 0-3, B has range of 90-100, if both are on vertical axis and Left Y Axis is ranging from 0-100. If I make B to right axis then Left axis is still from 0-100 instead of 0-3.
Same situation with Y axis also.

Any sample of dynamically swtiching Y axes would be perfect.

Thanks,

5 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 20 Sep 2012, 02:53 PM
Hi,

I have prepared for you a small demo project that has 3 line series, sharing one categorical axis and 2 vertical axes. I have added 2 buttons: the first one changes the location of each axis, and the second one changes the axis <-> series association.

Greetings,
Yavor
the Telerik team

Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

0
N
Top achievements
Rank 1
answered on 20 Sep 2012, 04:01 PM
Hi Yavor,

Thank you for your reply,
Button1: Change Location: is not what I am looking for. 
Button 2: Gives Error.

I was looking for an example where I have 2 Line series on Vertical Left axis and then can change "each" line series to left and right axis dynamically. Please choose different ranges 0-3 and 90-100 for each line series.
What I noticed in my example that Axis does not adjust automatically when line series are switched

How to set a series vertical axis to the default vertical axis?
Thanks,
0
Yavor
Telerik team
answered on 24 Sep 2012, 11:02 AM
Hello,

In my test demo the first button only changes the location of each axis. The second button changes the Series <-> Axis association. When the axis is connected to new series, its data range is automatically recalculated, as it is visible in my demo. The range of the data can be 0-3, or 0-300 and is of no significance to the axis - series association.

You can reset the vertical axis of the series to the default one (the primary vertical axis) by clearing the value of the dependency property. Here is some code:

CartesianSeries series = this.chart1.Series[0];
series.ClearValue(CartesianSeries.VerticalAxisProperty);

I have attached a modified version of the demo project I sent to you previously clearing all additional axes and reverting to the primary axis.

If you have any other question regarding RadChartView I will be happy to assist you.

All the best,
Yavor
the Telerik team

Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

0
Tim
Top achievements
Rank 1
answered on 22 Aug 2016, 04:40 AM

I know this is an old post, but is their any chance of an example of this using "Ui for Asp.net Ajax" ?

Am interested in having multiple line series graphs each with their own Y axis..

regards

The Timp

0
Martin Ivanov
Telerik team
answered on 22 Aug 2016, 07:25 AM
Hello Tim,

I recommend you to post your question in the UI for ASP.NET forum section where you could receive relevant information on the matter.  

Regards,
Martin
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
ChartView
Asked by
N
Top achievements
Rank 1
Answers by
Yavor
Telerik team
N
Top achievements
Rank 1
Tim
Top achievements
Rank 1
Martin Ivanov
Telerik team
Share this question
or