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.
- PRADNYA NAIKWADI asked 5 years ago
- You must login to post comments
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
- Andrew Burnett-Thompson answered 5 years ago
- You must login to post comments
Please login first to submit.