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

Closed
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
Showing 0 results