LineSeriesCursor and Z

A forum dedicated to WinForms version of LightningChart Ultimate.

Moderator: Arction_LasseP

Niels Decker
Posts: 1
Joined: Mon Nov 22, 2021 8:12 am

LineSeriesCursor and Z

Post by Niels Decker » Tue Nov 23, 2021 2:30 pm

Is it possible to assign an individual Z order to LineSeriesCursors, so that they run behind one graph but above another? I could only find the "behind" property that positions the LineSeriesCursor at the very front or at the very back.


Posts: 123
Joined: Wed Mar 27, 2019 1:05 pm

Re: LineSeriesCursor and Z

Post by Arction_LasseP » Wed Nov 24, 2021 8:44 am

Hello Niels,

This is currently not possible. As you already found out, LineSeriesCursor can be behind all series or in front of all series.

There is a workaround that could be used in some cases. You could set the cursor color to transparent and then add an additional line series to act as a cursor. Since line series such as PointLineSeries are rendered in the order they are in the respective series list, you can have the extra series on top of some series and behind some other series. You would still need to have the LineSeriesCursor as you cannot drag a line series. Here is a small example:

Code: Select all

LineSeriesCursor cursor = new LineSeriesCursor(_chart.ViewXY, axisX);
cursor.LineStyle.Color = Color.FromArgb(0, 255, 0, 0);  // Set transparent color. Visible = false would prevent dragging.
cursor.ValueAtXAxis = 5;
cursor.SnapToPoints = false;
cursor.PositionChanged += Cursor_PositionChanged;

PointLineSeries cursorSeries = new PointLineSeries(_chart.ViewXY, _chart.ViewXY.XAxes[0], _chart.ViewXY.YAxes[0]);
cursorSeries.AllowUserInteraction = false;
cursorSeries.PointsVisible = false;
cursorSeries.LineVisible = true;
cursorSeries.CursorTrackEnabled = false; // Don't let the cursor track this series
cursorSeries.LineStyle.Color = Color.Red;
SeriesPoint[] p = new SeriesPoint[2]
    new SeriesPoint(5, 0),
    new SeriesPoint(5, 100)
cursorSeries.Points = p;
cursorSeries.Title.Text = "Cursor";
_chart.ViewXY.PointLineSeries.Insert(2, cursorSeries);

        private void Cursor_PositionChanged(object sender, PositionChangedEventArgs e)
            foreach (var series in _chart.ViewXY.PointLineSeries)
                if (series.Title.Text == "Cursor") // Move the cursor series when LineSeriesCursor moves
                    series.Points[0].X = e.NewValue;
                    series.Points[1].X = e.NewValue;
In the above, if there were 4 series you want to track, the cursor appears on top of the first two series but behind the last two.

As mentioned this approach can be used in some cases. There are other workarounds such as using multiple axes, but this one is perhaps the easiest one to implement.

Best regards,