Pre loader

Dynamic Series addition with respective X and Y Axes

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

0
0

Hello,

I am creating a chart which should add a series with its respective X and Y axes on a button click.

I am adding axes as follows:

private void AddYAxis(List<double> yValues)
    {
        var yAxis = new NumericAxis()
        {
            AxisAlignment = AxisAlignment.Left,
            AxisTitle = "Number of Samples (per Series)",
            Id = "first"
        };
        sciChart.YAxes.Add(yAxis);
    }

private void AddXAxis(List<DateTime> xValues)
    {
        var xAxis = new DateTimeAxis()
        {
            TextFormatting = "YYYY-MM-DD HH:mm:ss",
            AxisAlignment = AxisAlignment.Bottom,
            AxisTitle = "Bottom Axis",
            Id = "first"
        };
        sciChart.XAxes.Add(xAxis);
    }

Then, I am adding the renderable series:

 private void AddSeriesClick(List<DateTime> xValues, List<double> yValues)
    {
        var dataSeries = new XyDataSeries<DateTime, double>();
        dataSeries.Append(xValues, yValues);

        var renderSeries = new FastLineRenderableSeries
        {
            Stroke = Color.FromArgb(0xFF, 0x40, 0x83, 0xB7),
            DataSeries = dataSeries,
            StrokeThickness = 2,
        };
        renderSeries.XAxis = sciChart.XAxes.GetAxisById("first");
        renderSeries.YAxis = sciChart.YAxes.GetAxisById("first");
        sciChart.RenderableSeries.Add(renderSeries);
        sciChart.ZoomExtents();
    }

But, I am only able to see the Axis titles and nothing else is rendered in the chart.

Following exception is thrown:

SciChartSurface didn’t render, because an exception was thrown:
Message: AxisCollection.GetAxisById(‘DefaultAxisId’) returned no axis with ID=DefaultAxisId. Please check you have added an axis with this Id to the AxisCollection

Stack Trace: at SciChart.Charting.Model.AxisCollection.GetAxisById(String axisId, Boolean assertAxisExists)
at A.IJ.DB(AxisCollection D, IRenderableSeries I, RenderPassInfo J, IPointResamplerFactory M, IDataSeries& O, IndexRange& S, IPointSeries& T, Int32& AB)
at A.IJ.S(ISciChartSurface D, Size I)
at A.IJ.RenderLoop(IRenderContext2D renderContext)
at SciChart.Charting.Visuals.SciChartSurface.DoDrawingLoop()

The program ‘[17304] SciChart_MultipleXAxis.exe’ has exited with code 0 (0x0).

Can you kindly look into it.

Version
5.3.0.11954
  • You must to post comments
0
0

Hi Pradnya,

Did you figure it out? I saw that the questoin was marked as closed.

The answer to the question is: do not set RenderableSeries.XAxis or RenderableSeries.YAxis (these are set internally by ScIChart), but isntead please set RenderableSeries.XAxisId and RenderableSeries.YAxisId to match the Id of the X,Y axis you want to measure that series by.

For more information about multiple axis charts, please see our Multiple Axis tutorial.

Best regards
Andrew

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies