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

Secondary Y axis or no ?

2 Answers 82 Views
Chart (obsolete as of Q1 2013)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
scott
Top achievements
Rank 1
scott asked on 02 Oct 2012, 09:01 PM
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 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 05 Oct 2012, 02:01 PM
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 >>
0
scott
Top achievements
Rank 1
answered on 05 Oct 2012, 02:14 PM
Thank you, Stefan...
Tags
Chart (obsolete as of Q1 2013)
Asked by
scott
Top achievements
Rank 1
Answers by
Stefan
Telerik team
scott
Top achievements
Rank 1
Share this question
or