Pre loader

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

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

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:

<s:SciChartSurface
        x:Name="SciChart"
        Grid.Column="0"
        Annotations="{Binding Annotations}"
        DebugWhyDoesntSciChartRender="True"
        GridLinesPanelStyle="{StaticResource GridLinesPanelStyle}"
        RenderableSeries="{s:SeriesBinding ChartSeries}"
        Style="{StaticResource SurfaceStyle}">

        <s:SciChartSurface.RenderSurface>
            <s:HighQualityRenderSurface />
        </s:SciChartSurface.RenderSurface>

        <s:SciChartSurface.XAxis>
            <s:NumericAxis
                AutoRange="Never"
                AutoTicks="False"
                AxisTitle="{Binding XAxis.Label}"
                DrawLabels="{Binding XAxis.ShowLabels}"
                DrawMajorGridLines="{Binding XAxis.MajorGridLines}"
                DrawMinorGridLines="{Binding XAxis.MinorGridLines}"
                DrawMinorTicks="True"
                LabelProvider="{Binding XAxisLabels}"
                MajorDelta="{Binding XAxis.MajorDelta}"
                MinorDelta="{Binding XAxis.MinorDelta}"
                Style="{StaticResource XAxisStyle}"
                TextFormatting="0.##"
                TickLabelStyle="{StaticResource XAxisLabelStyle}"
                TitleStyle="{StaticResource AxisTitleStyle}"
                VisibleRange="{Binding XAxis.DisplayRange.Value}" />
        </s:SciChartSurface.XAxis>

        <s:SciChartSurface.YAxis>
            <s:NumericAxis
                AutoRange="Never"
                AutoTicks="False"
                AxisAlignment="Left"
                AxisTitle="{Binding YAxis.Label}"
                DrawLabels="{Binding YAxis.ShowLabels}"
                DrawMajorGridLines="{Binding YAxis.MajorGridLines}"
                DrawMinorGridLines="{Binding YAxis.MinorGridLines}"
                DrawMinorTicks="True"
                MajorDelta="{Binding YAxis.MajorDelta}"
                MinorDelta="{Binding YAxis.MinorDelta}"
                LabelProvider="{Binding YAxisLabels}"
                Style="{StaticResource YAxisStyle}"
                TextFormatting="0.##"
                TickLabelStyle="{StaticResource AxisLabelStyle}"
                TitleStyle="{StaticResource AxisTitleStyle}"
                VisibleRange="{Binding YAxis.DisplayRange.Value}" />
        </s:SciChartSurface.YAxis>

        <s:SciChartSurface.ChartModifier>
            <s:ModifierGroup>
                <s:LegendModifier
                    x:Name="LegendModifier"
                    Margin="10"
                    HorizontalAlignment="Right"
                    GetLegendDataFor="AllSeries"
                    LegendTemplate="{StaticResource LegendTemplate}"
                    Orientation="Horizontal"
                    ShowLegend="{Binding ShowLegend}"
                    ShowVisibilityCheckboxes="False" />
                <s:RolloverModifier ShowAxisLabels="False">
                    <s:RolloverModifier.LineOverlayStyle>
                        <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"/>
                        </Style>
                    </s:RolloverModifier.LineOverlayStyle>
                </s:RolloverModifier>
                <s:SeriesSelectionModifier>
                    <s:SeriesSelectionModifier.SelectedSeriesStyle>
                        <!--  When a series is selected (on click), apply this style  -->
                        <Style TargetType="s:BaseRenderableSeries">
                            <Setter Property="Stroke" Value="DeepPink" />
                            <Setter Property="StrokeThickness" Value="3" />
                        </Style>
                    </s:SeriesSelectionModifier.SelectedSeriesStyle>
                </s:SeriesSelectionModifier>
            </s:ModifierGroup>

        </s:SciChartSurface.ChartModifier>
    </s:SciChartSurface>

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;
    }
Version
6.5
  • 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.