Series.Clear() after SampleDataSeries.Add(Series)

A forum dedicated to WPF version of LightningChart Ultimate.

Moderator: Arction_LasseP

Martin Schmidt
Posts: 6
Joined: Thu Aug 31, 2017 8:59 am

Series.Clear() after SampleDataSeries.Add(Series)

Post by Martin Schmidt » Mon Sep 18, 2017 9:53 am


first, I like your lightning chart a lot, I think, it's really great.
But maybe you can help me with one issue I have. I'm using V8.1.4. and Visual Studio 12.0.40629.

I have made the example below. I tried to strip down our real world project to the point, where I have two questions.

The example below works fine as it is. But then two things get strange:
  • When I remove the comments from the line
    // series.Clear();
    I don't see anything at all. The complete chart control disappears and I have a blank window. I don't understand this, looks for me like a bug?
  • Then I comment or remove the line
    SetMarker(series, "Label", samples[2] + 0.5, 0);
    and my chart control is visible again, but no data in it.
It's a simple example, it would be great if someone at Arction could try to reproduce this.

I would have expected no difference, if I make

Code: Select all

series = null;
or only

Code: Select all

series = null;
after adding a series to a view.

But everything I do with this variable still effects the chart. Is this intended to be so or do I make something wrong here?

In our real world project I have a crash at series = null; that I didn't have in V8.0. But there's a lot more going on in our project, so I was not able yet to reproduce this in a simple example.


Code: Select all

        xmlns:lcusb="" x:Class="LCTest.MainWindow"
        Title="MainWindow" Height="350" Width="525">
        <Grid x:Name="MainGrid" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
            <lcusb:LightningChartUltimate x:Name="chart" Content="LightningChartUltimate" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">

Code: Select all

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using Arction.Wpf.SemibindableCharting;
using Arction.Wpf.SemibindableCharting.Annotations;
using Arction.Wpf.SemibindableCharting.EventMarkers;
using Arction.Wpf.SemibindableCharting.SeriesXY;
using Arction.Wpf.SemibindableCharting.Views.ViewXY;
using Arction.Wpf.SemibindableCharting.Axes;
using Arction.Wpf.SemibindableCharting.Titles;
using Arction.Wpf.SemibindableCharting.ChartManager;

namespace LCTest
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
        public MainWindow()


        private void CreateChart()
            var samples = new double[] { 3, 4, 1, 6, 7, 3, 4, 1, 7, 2, 2 };

            for (int i = 0; i < 3; i++)
                var series = new SampleDataSeries(chart.ViewXY, chart.ViewXY.XAxes[0], chart.ViewXY.YAxes[0]);

                series.FirstSampleTimeStamp = 0;
                series.SamplingFrequency = 1;

                series.AddSamples(samples, true);

                SetMarker(series, "Label", samples[2] + 0.5, 0);

                // series.Clear();
                series = null;

                for (int j = 0; j < samples.Count(); j++) samples[j]++;

        private void SetMarker(SampleDataSeries series, string label, double x, double y = 0.0)
            if (series.GetType().Name == "SampleDataSeries")
                LineSeriesValueSolveResult result = ((SampleDataSeries)series).SolveYValueAtXValue(x);
                if (result.SolveStatus == LineSeriesSolveStatus.OK)
                    // PointLineSeries may have two or more points at same X value. If so, center it between min and max
                    y = (result.YMax + result.YMin) / 2.0;

            var seriesColor = Colors.Peru;

            SeriesEventMarker eventMarker = new SeriesEventMarker(series);

            eventMarker.Label.Color = seriesColor;
            eventMarker.Label.Text = label;

            eventMarker.Symbol.Shape = Arction.Wpf.SemibindableCharting.Shape.Circle;
            eventMarker.Symbol.Color1 = Colors.Transparent;
            eventMarker.Symbol.Height = 9;
            eventMarker.Symbol.Width = 9;
            eventMarker.Symbol.GradientFill = GradientFillPoint.Solid;
            eventMarker.Symbol.BorderWidth = 2;
            eventMarker.Symbol.BorderColor = seriesColor;

            eventMarker.XValue = x;
            eventMarker.YValue = y;
            eventMarker.HorizontalPosition = SeriesEventMarkerHorizontalPosition.SnapToPoints;
            eventMarker.VerticalPosition = SeriesEventMarkerVerticalPosition.TrackSeries;
            eventMarker.MouseInteraction = false;


User avatar
Posts: 38
Joined: Fri Feb 05, 2016 11:37 am
Location: Finland

Re: Series.Clear() after SampleDataSeries.Add(Series)

Post by ArctionNikolai » Tue Sep 19, 2017 9:19 am

Hello Martin,

Thank you for choosing our product. About your problem, if you want to clear the series with Clear() method, please make sure that SeriesEventMarkers.VerticalPosition are not configured to SeriesEventMarkerVerticalPosition.TrackSeries.
Markers logic cannot get the information about the trackable plot trying to solve the nearest data-point. However, there are no data points after applying the Clear method. Apply tracking series is not empty.

Code: Select all

series = null;
This block actually removes a reference to the specific line in chart.ViewXY.SampleDataSeries[x], it does not affect the chart or data amount.

Best regards,
Nikolai Arsenov
Software developer
Arction Ltd
Microkatu 1, 70210 Kuopio, Finland