Pre loader

StackedColumnRenderableSeries and using RenderableSeries.Clear()

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

Best Answer
1
0

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

See our Release Notes

v3.3.2.6024

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

Let me know if this helps!

Best regards,
Andrew

  • You must to post comments
0
0

Re-Posting:

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"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         xmlns:s="http://schemas.abtsoftware.co.uk/scichart"
         xmlns:ChartUserControls="clr-namespace:MKSCharts.SummaryDrillDownCharting"
         xmlns:CreateMultiseriesChart="clr-namespace:MKSCharts.SummaryDrillDownCharting"  
         mc:Ignorable="d" 
         d:DesignHeight="300" d:DesignWidth="600">

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

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

    <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:SciChartSurface.XAxis>
            <s:NumericAxis AutoRange="Once" AutoTicks="True" MajorDelta="1" MinorDelta="1.0" />
            <!-- VisibleRangeLimit="1,20" LabelProvider="{StaticResource MassScanLabelProvider}"  -->
        </s:SciChartSurface.XAxis>

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

        <s:SciChartSurface.ChartModifier>
            <s:ModifierGroup>
                <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"/>

            </s:ModifierGroup>

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

..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();
            someData.Add(rangeNumber);
        }
        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.RenderableSeries.Add(newSeries);
        MassScanSciChartSurface.XAxis.VisibleRange = new DoubleRange(1, someDataAsArray.Count());

        // increment the chart number so the next series has a different stackedGroupID
        _chartNumber++;
    }

    private void Test_Click(object sender, RoutedEventArgs e)
    {
        AddMassScanDataSeries();
    }

    private void Clear_Click(object sender, RoutedEventArgs e)
    {
        MassScanSciChartSurface.RenderableSeries.Clear();
    }

I’m using v 3.3.0.5909

Images
  • 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.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies