Secondary Y axis or no ?

3 posts, 0 answers
  1. scott
    scott avatar
    67 posts
    Member since:
    Jul 2010

    Posted 02 Oct 2012 Link to this post

    Telerik.WinControls.UI.ChartSeries series1 = new LineSeries();
    series1.DataPoints.Add(new CategoricalDataPoint(1, "9/24"));
    series1.DataPoints.Add(new CategoricalDataPoint(2, "9/25"));
    series1.DataPoints.Add(new CategoricalDataPoint(3, "9/26"));
    series1.DataPoints.Add(new CategoricalDataPoint(4, "9/27"));
     
    Telerik.WinControls.UI.ChartSeries series2 = new BarSeries();
    series2.DataPoints.Add(new CategoricalDataPoint(6, "9/24"));
    series2.DataPoints.Add(new CategoricalDataPoint(7, "9/25"));
    series2.DataPoints.Add(new CategoricalDataPoint(8, "9/26"));
    series2.DataPoints.Add(new CategoricalDataPoint(9, "9/27"));
     
    chart.Series.Add(series1);
    chart.Series.Add(series2);
    I'm trying to get a winforms application to use a secondary y axis.  A thread from 2008 seems to indicate this is possible, and a thread from 2011 seems to indicate that its not possible.

    Can I have a secondary Y axis in a winforms app?  If so, how...



    Thank you -
    Scott
  2. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 05 Oct 2012 Link to this post

    Hi Scott,

    Thank you for writing.

    I am not sure which threads are you referring too, however, both the obsolete RadChart and the new RadChartView controls support this functionality. I would suggest that you go with the RadChartView control. Here is how to implement second Y axis in it:
    public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
     
                LinearAxis vAxis1 = new LinearAxis();
                vAxis1.AxisType = AxisType.Second;
                vAxis1.HorizontalLocation = AxisHorizontalLocation.Left;
     
                LineSeries series1 = new LineSeries();
                series1.VerticalAxis = vAxis1;
                series1.DataPoints.Add(new CategoricalDataPoint(1, "9/24"));
                series1.DataPoints.Add(new CategoricalDataPoint(2, "9/25"));
                series1.DataPoints.Add(new CategoricalDataPoint(3, "9/26"));
                series1.DataPoints.Add(new CategoricalDataPoint(4, "9/27"));
     
                LinearAxis vAxis2 = new LinearAxis();
                vAxis2.HorizontalLocation = AxisHorizontalLocation.Left;
                vAxis2.AxisType = AxisType.Second;
     
                BarSeries series2 = new BarSeries();
                series2.VerticalAxis = vAxis2;
                series2.DataPoints.Add(new CategoricalDataPoint(6, "9/24"));
                series2.DataPoints.Add(new CategoricalDataPoint(7, "9/25"));
                series2.DataPoints.Add(new CategoricalDataPoint(8, "9/26"));
                series2.DataPoints.Add(new CategoricalDataPoint(9, "9/27"));
     
                this.radChartView1.Series.AddRange(series1, series2);
            }
        }
     
    Please note that it is important that you set up the axes prior adding the series to the control.

    I hope this helps.
     
    Regards,
    Stefan
    the Telerik team
    RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
  3. UI for WinForms is Visual Studio 2017 Ready
  4. scott
    scott avatar
    67 posts
    Member since:
    Jul 2010

    Posted 05 Oct 2012 Link to this post

    Thank you, Stefan...
Back to Top