Pre loader

Line graph disappears when I change the X-Axis range.


I’m encountering some odd behaviour when I rescale my graph to modify the range of the X axis. For certain data series, the line disappears from the chart.

e.g. I have a data series that’s 2899 points long, with X values ranging from -6.17 to 22.81, so I change my X axis range to be from -8 to 24 to fit it all in. When I change the VisibleRange of the SciChartSurface.XAxis, then the line disappears. If I don’t rescale the visible range then the portion that would be visible is rendered fine.

The funny thing about it is, if I remove the last point from the series before adding to the chart, it draws fine, even after I rescale the visible range! The same goes for if I add another point to the end (e.g. even if that point is identical to the existing last point).

Now if I hover the mouse (Rollover) over the chart, the spot to highlight the point in the line still appears as if the graph was still there. It’s like it’s there but invisible.

I’ve tried setting DebugWhyDoesntSciChartRender to true, but this fires only when the chart is initially drawn and no series’ have been added yet, so I get

SciChartSurface didn’t render, RendererErrorCode: [RendererErrorCode: [Because the SciChartSurface.RenderableSeries collection is null or empty. Please ensure that you have set some RenderableSeries with RenderableSeries.DataSeries assigned, or you have set Axis.VisibleRange for all axes in order to view a blank chart.]
RendererErrorCode: [Because none of the SciChartSurface.RenderableSeries has a DataSeries assigned]

However I add the DataSeries’ after this, and when I do that, or rescale the axis, no error is reported.

Here is my XAML code to show the chart:

        Annotations="{Binding Annotations}"
        GridLinesPanelStyle="{StaticResource GridLinesPanelStyle}"
        RenderableSeries="{s:SeriesBinding ChartSeries}"
        Style="{StaticResource SurfaceStyle}">

            <s:HighQualityRenderSurface />

                AxisTitle="{Binding XAxis.Label}"
                DrawLabels="{Binding XAxis.ShowLabels}"
                DrawMajorGridLines="{Binding XAxis.MajorGridLines}"
                DrawMinorGridLines="{Binding XAxis.MinorGridLines}"
                LabelProvider="{Binding XAxisLabels}"
                MajorDelta="{Binding XAxis.MajorDelta}"
                MinorDelta="{Binding XAxis.MinorDelta}"
                Style="{StaticResource XAxisStyle}"
                TickLabelStyle="{StaticResource XAxisLabelStyle}"
                TitleStyle="{StaticResource AxisTitleStyle}"
                VisibleRange="{Binding XAxis.DisplayRange.Value}" />

                AxisTitle="{Binding YAxis.Label}"
                DrawLabels="{Binding YAxis.ShowLabels}"
                DrawMajorGridLines="{Binding YAxis.MajorGridLines}"
                DrawMinorGridLines="{Binding YAxis.MinorGridLines}"
                MajorDelta="{Binding YAxis.MajorDelta}"
                MinorDelta="{Binding YAxis.MinorDelta}"
                LabelProvider="{Binding YAxisLabels}"
                Style="{StaticResource YAxisStyle}"
                TickLabelStyle="{StaticResource AxisLabelStyle}"
                TitleStyle="{StaticResource AxisTitleStyle}"
                VisibleRange="{Binding YAxis.DisplayRange.Value}" />

                    LegendTemplate="{StaticResource LegendTemplate}"
                    ShowLegend="{Binding ShowLegend}"
                    ShowVisibilityCheckboxes="False" />
                <s:RolloverModifier ShowAxisLabels="False">
                        <Style TargetType="Line">
                            <Setter Property="Stroke" Value="{StaticResource VitalCyanBrush}"/>
                            <Setter Property="StrokeThickness" Value="16"/>
                            <Setter Property="Opacity" Value=".2"/>
                            <Setter Property="IsHitTestVisible" Value="False"/>
                            <Setter Property="UseLayoutRounding" Value="True"/>
                        <!--  When a series is selected (on click), apply this style  -->
                        <Style TargetType="s:BaseRenderableSeries">
                            <Setter Property="Stroke" Value="DeepPink" />
                            <Setter Property="StrokeThickness" Value="3" />


and here is the code to change the Axis visible range. (In the ViewModel). Note that while this changes both the X Axis and the Y Axis scale, only the X Axis change causes this problem.

        protected override void ScaleAxes(double xaxisLowerValue, double xaxisUpperValue, double yaxisLowerValue, double yaxisUpperValue)
        var xAxisRange = new AxisRange(0, 0);
        var yAxisRange = new AxisRange(0, 0);

        //Resolve time axis
        yAxisRange.MaxValue = CalculateUpperBoundary(yaxisUpperValue, (double)_graphIndicators.BarChartMaxIndicator, YAxis.UpperPadding, YAxis.MajorDelta);
        yAxisRange.MinValue = CalculateLowerBoundary(yaxisLowerValue, (double)_graphIndicators.BarChartMinIndicator, YAxis.LowerPadding, YAxis.MajorDelta);

        //Resolve Volume Axis
        xAxisRange.MaxValue = CalculateUpperBoundary(xaxisUpperValue, xaxisUpperValue, XAxis.UpperPadding, XAxis.MajorDelta);
        xAxisRange.MinValue = CalculateLowerBoundary(xaxisLowerValue, xaxisLowerValue, XAxis.LowerPadding, XAxis.MajorDelta);

        //ensure max and min range have not exceeded the boundary range.
        xAxisRange = EnsureRangeIsWithinBounds(ref xAxisRange, XAxis.BoundingRange);
        yAxisRange = EnsureRangeIsWithinBounds(ref yAxisRange, YAxis.BoundingRange);

        //ensure max and min range are within optimal range.
        xAxisRange = EnsureRangeIsWithinOptimal(ref xAxisRange, XAxis.OptimalRange);
        yAxisRange = EnsureRangeIsWithinOptimal(ref yAxisRange, YAxis.OptimalRange);

        //update the display range
        XAxis.DisplayRange = xAxisRange;
        YAxis.DisplayRange = yAxisRange;
  • Colm de Cleir
    My current “workaround” is to always add another copy of the last point of the series onto the end. This is a bit of a hack however, and while it’s fixed any of the charts that have not worked so far (and not broken the ones that do), I can’t be certain that it has completely fixed the problem.
  • Andrew Burnett-Thompson
    Hi Colm, I can’t off the top of my head think of a reason why this is happening. The code you’ve posted isn’t enough to reproduce an issue and at first glance looks OK. I suggest extracting the above into a stand alone project and trying to isolate the issue. At that point we’ll have something we can test with version 6 and 7 of SciChart WPF
  • You must to post comments
Showing 0 results
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