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

Best Answer

Well, the webpage might have eaten the post but at least you’ll be pleased the fix is simple

See our Release Notes


  • SC-2436 Fixed the bug where RenderableSeries.Clear() caused wrong rendering (series left attached)

Let me know if this helps!

Best regards,

  • You must to post comments


Hi Andrew. The problem is simply that I don’t think the data is being properly cleared using this code and I can’t see why it shouldn’t work (and neither can anyone else here).

I have a chart defined in XAML. I add 3 series to the bar chart in stacked side-by-side mode using the test button. I then press the Clear button and the chart clears. I then add a new series to the blank chart – nothing is displayed. If you then drag the xaxis modifier the chart displays 4 series but still only 1 on the legend.

I’m having to create the series dynamically based on user choices so I’m not binding anything through XAML. I had a label provider but have removed this to keep everything as simple as possible.

Anyway – the XAML

<UserControl x:Class="MKSCharts.SummaryDrillDownCharting.MassScanAxisUserControl"
         d:DesignHeight="300" d:DesignWidth="600">

    <!-- <CreateMultiseriesChart:MassScanLabelProviderClass x:Key="MassScanLabelProvider"/> -->

        <RowDefinition x:Name="Button1Row" Height="Auto"/>
        <RowDefinition x:Name="Button2Row" Height="Auto"/>
        <RowDefinition x:Name="ChartRow" Height="*"/>

    <Button x:Name="Test" Content="Test Button" Grid.Row="0" Click="Test_Click" />
    <Button x:Name="Clear" Content="Clear Button" Grid.Row="1" Click="Clear_Click" />

    <s:SciChartSurface x:Name="MassScanSciChartSurface" s:ThemeManager.Theme="Chrome" Grid.Row="2">
            <s:NumericAxis AutoRange="Once" AutoTicks="True" MajorDelta="1" MinorDelta="1.0" />
            <!-- VisibleRangeLimit="1,20" LabelProvider="{StaticResource MassScanLabelProvider}"  -->

            <s:NumericAxis AutoRange="Always" AxisAlignment="Left" AxisTitle="Pressure" ScientificNotation="E" TextFormatting="#.#E+0" CursorTextFormatting="#.#E+0" GrowBy="0.0, 0.1"/>

                <s:RubberBandXyZoomModifier x:Name="rubberBandZoomModifier" IsEnabled="True" IsXAxisOnly="False" IsAnimated="True" ExecuteOn="MouseRightButton" ZoomExtentsY="False"/>
                <s:ZoomPanModifier x:Name="zoomPanModifier" ExecuteOn="MouseLeftButton" ZoomExtentsY="False" IsEnabled="True"/>
                <s:ZoomExtentsModifier x:Name="zoomExtentsModifier" ExecuteOn="MouseDoubleClick"/>
                <s:MouseWheelZoomModifier ActionType="Zoom" XyDirection="XYDirection"/>

                <!-- This activates "SCALING" (not zooming) on each axis -->
                <s:XAxisDragModifier x:Name="xAxisDragModifier" IsEnabled="True" ClipModeX="None" />
                <s:YAxisDragModifier x:Name="yAxisLeftDragmodifier" IsEnabled="True" />

                <s:LegendModifier x:Name="LegendModifier" Margin="5" VerticalAlignment="Stretch"  GetLegendDataFor="AllSeries" LegendPlacement="Right" ShowLegend="True" ShowVisibilityCheckboxes="True"/>



..and the code behind for the buttons:

        public void AddMassScanDataSeries()
        double[] someDataAsArray;

        List<double> someData = new List<double>();
        for (int x = 0; x < 5; x++)
            Random test = new Random();
            double rangeNumber = test.NextDouble();
        someDataAsArray = someData.ToArray();

        StackedColumnRenderableSeries newSeries = new StackedColumnRenderableSeries();
        newSeries.Name = "Series" + _chartNumber.ToString();
        newSeries.SeriesColor = ChartHelper.GetRandomColor();               // random colour from supporting component
        SolidColorBrush randomColorBrush = new SolidColorBrush();
        randomColorBrush.Color = newSeries.SeriesColor;
        newSeries.FillBrush = randomColorBrush;
        newSeries.DataPointWidth = 0.9;

        newSeries.StackedGroupId = "ID" + _chartNumber.ToString();
        var newDataSeries = new XyDataSeries<int, double> { SeriesName = newSeries.StackedGroupId };

        for (int x = 1; x < someDataAsArray.Count() - 1; x++)
            newDataSeries.Append(x, someDataAsArray[x]);
        newSeries.DataSeries = newDataSeries;
        MassScanSciChartSurface.XAxis.VisibleRange = new DoubleRange(1, someDataAsArray.Count());

        // increment the chart number so the next series has a different stackedGroupID

    private void Test_Click(object sender, RoutedEventArgs e)

    private void Clear_Click(object sender, RoutedEventArgs e)

I’m using v

  • Stuart McCullough
    Some people may notice that the data creation loop doesn't match the output i.e. 5 in the loop but 8 points in the image. - the loop was set at 10 when I was creating the image. :-)
  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.