SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & Android Chart Components

Welcome to the SciChart Community Forums!

Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy. We also have a tag=SciChart on Stackoverflow.com where you can earn rep for your questions!

Please note: SciChart team will only answer questions from customers with active support subscriptions. Expired support questions will be ignored. If your support status shows incorrectly, contact us and we will be glad to help.

0
0

I took your simple line chart quick start and am attempting to add a second series on a second Y axis. It works fine as long as both series are rendered on yAxis1 but as soon as I uncomment out the line chart1.YAxes.Add(yAxis2) I get a blank chart instead (doesn’t matter if lineSeries2.YAxis is set to yAxis1 or yAxis2 – same result). I can’t figure out what the problem is.

        var xAxis = new NumericAxis();
        chart1.XAxis = xAxis;

        var yAxis1 = new NumericAxis();
        yAxis1.AxisAlignment = AxisAlignment.Left;
        chart1.YAxes.Add(yAxis1);

        var yAxis2 = new NumericAxis();
        yAxis2.AxisAlignment = AxisAlignment.Right;
        //chart1.YAxes.Add(yAxis2);

        var series1 = new XyDataSeries<double, double>();
        series1.SeriesName = "Sinewave1";

        var series2 = new XyDataSeries<double, double>();
        series2.SeriesName = "Sinewave2";

        for (int i = 0; i < 1000; i++)
        {
            series1.Append(i, Math.Sin(2 * Math.PI * i / 1000));
            series2.Append(i, Math.Sin(2 * Math.PI * i / 500) * 2);
        }

        var lineSeries1 = new FastLineRenderableSeries();
        lineSeries1.DataSeries = series1;
        lineSeries1.YAxis = yAxis1;
        chart1.RenderableSeries.Add(lineSeries1);

        var lineSeries2 = new FastLineRenderableSeries();
        lineSeries2.DataSeries = series2;
        lineSeries2.YAxis = yAxis1;
        chart1.RenderableSeries.Add(lineSeries2);
  • You must to post comments
0
0

Ok, I figured it out. I have to set the YAxisId property on the line renderers instead of YAxis. Not sure why, I would expect either to work?

This code works:

        var xAxis = new NumericAxis();
        chart1.XAxis = xAxis;

        var yAxis1 = new NumericAxis();
        yAxis1.AxisAlignment = AxisAlignment.Left;
        yAxis1.Id = "yAxis1";
        chart1.YAxes.Add(yAxis1);

        var yAxis2 = new NumericAxis();
        yAxis2.AxisAlignment = AxisAlignment.Right;
        yAxis2.Id = "yAxis2";
        chart1.YAxes.Add(yAxis2);

        var series1 = new XyDataSeries<double, double>();
        series1.SeriesName = "Sinewave1";

        var series2 = new XyDataSeries<double, double>();
        series2.SeriesName = "Sinewave2";

        for (int i = 0; i < 1000; i++)
        {
            series1.Append(i, Math.Sin(2 * Math.PI * i / 1000));
            series2.Append(i, Math.Sin(2 * Math.PI * i / 500) * 2);
        }

        var lineSeries1 = new FastLineRenderableSeries();
        lineSeries1.DataSeries = series1;
        lineSeries1.YAxisId = "yAxis1";
        chart1.RenderableSeries.Add(lineSeries1);

        var lineSeries2 = new FastLineRenderableSeries();
        lineSeries2.DataSeries = series2;
        lineSeries2.YAxisId = "yAxis2";
        chart1.RenderableSeries.Add(lineSeries2);
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.