Multiple LineSeries with Two Y Axis and switching Y axis dynamically

6 posts, 0 answers
  1. N
    N avatar
    21 posts
    Member since:
    May 2012

    Posted 19 Sep 2012 Link to this post

    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,
  2. Yavor
    Admin
    Yavor avatar
    401 posts

    Posted 20 Sep 2012 Link to this post

    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.

  3. UI for WPF is Visual Studio 2017 Ready
  4. N
    N avatar
    21 posts
    Member since:
    May 2012

    Posted 20 Sep 2012 Link to this post

    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,
  5. Yavor
    Admin
    Yavor avatar
    401 posts

    Posted 24 Sep 2012 Link to this post

    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.

  6. Tim
    Tim avatar
    1 posts
    Member since:
    Mar 2015

    Posted 21 Aug in reply to Yavor Link to this post

    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

  7. Martin
    Admin
    Martin avatar
    1101 posts

    Posted 22 Aug Link to this post

    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.
Back to Top
UI for WPF is Visual Studio 2017 Ready