.NET-logo

.NET Data VisualizationWhich LightningChart XY line-series is best for an application?

ArticleLightningChart .NET features 10 line series. Get to know which one best fits your application requirements.

LightningChart XY Line Series

For those, not yet familiar with LightningChart .NET components, it offers a wide range of 2D (ViewXY) charts and for each type of data, one or more Series may be used.

In particular, the line series type of chart/plot has a very broad selection of Series.

The purpose of this article is to explain why a particular line series type should be used, what are the tradeoffs and what are the assumptions for each line series.

In LightningChart .NET v.10.3.1, three new line series have been released and the list expanded to a total of 10 series, including:

  • AreaSeries
  • DigitalLineSeries
  • FreeformPointLineSeries
  • HighLowSeries
  • LiteFreeformLineSeries
  • LiteLineSeries
  • PointLineSeries
  • SampleDataBlockSeries
  • SampleDataSeries
  • LineCollection.
XY-LineSeries-Features

Assumption about order of X-value in data array

One of the primary criteria for the selection of optimal line series is the order of X-values in the data array. If X-values are in progressively increasing order at a fixed interval, then SampleDataBlockSeries and SampleDataSeries should be used.

This is generally used in real-time Digital signal processing (DSP) applications. The digital signal would be represented as a sequence of numbers that sample a continuous variable in time or space.

Both series types are made for fixed-interval data monitoring, used typically in waveform visualization, e.g., medical monitoring (ECG/EKG, EEG, EMG, ExG), vibration monitoring, telemetric and data logger systems, and the audio engineering industry.

Use the series SamplingFrequency property (1 / sample interval) to set the fixed sample interval. To set the X value (timestamp) where the samples begin, set the FirstSampleTimeStamp property.

When the assumption of fixed interval progressive X-Value order is met, the user should use SampleDataBlockSeries or SampleDataSeries, because those are the fastest series and use less memory.

However, if data is progressive but not at a fixed interval, then the user should choose the second best (performing series) – LiteLineSeries or PointLineSeries. Other series, which require at least progressive X-Value order are AreaSeries, HighLowSeries, and DigitalLineSeries.

The only series which does not have an assumption about point order are LiteFreeformLineSeries, FreeformPointLineSeries, and LineCollection. Those Series allow drawing line points to any direction from the previous point.

However, those series will have reduced performance as compared to other line series (with more strict assumptions).

One of the primary criteria for the selection of optimal line series is the order of X-values in the data array.

If X-values are in progressively increasing order at a fixed interval, then SampleDataBlockSeries and SampleDataSeries should be used.

This is generally used in real-time Digital signal processing (DSP) applications.

The digital signal would be represented as a sequence of numbers that sample a continuous variable in time or space.

Both series types are made for fixed-interval data monitoring, used typically in waveform visualization, e.g., medical monitoring (ECG/EKG, EEG, EMG, ExG), vibration monitoring, telemetric and data logger systems, and the audio engineering industry.

Use the series SamplingFrequency property (1 / sample interval) to set the fixed sample interval.

To set the X value (timestamp) where the samples begin, set the FirstSampleTimeStamp property.

When the assumption of fixed interval progressive X-Value order is met, the user should use SampleDataBlockSeries or SampleDataSeries, because those are the fastest series and use less memory.

However, if data is progressive but not at a fixed interval, then the user should choose the second best (performing series) – LiteLineSeries or PointLineSeries.

Other series, which require at least progressive X-Value order are AreaSeries, HighLowSeries, and DigitalLineSeries.

The only series which does not have an assumption about point order are LiteFreeformLineSeries, FreeformPointLineSeries, and LineCollection.

Those Series allow drawing line points to any direction from the previous point.

However, those series will have reduced performance as compared to other line series (with more strict assumptions).

LightningChart-XY-LineSeries-Features-Demonstration
Figure 1. Only 3 series don’t have progressive x-value requirement/assumption (arrow).

Optimize memory and GC usage

In general, LightningChart .NET performance is excellent for all series. Especially if the point count is low (e.g. less than 1000 points). If a user is building a very demanding real-time application with millions/billions of points to visualize, this feature (optimized memory and .NET garbage collector (GC) usage) becomes critical.

More and more data are generated every day, and hence more points should be handled by the user application. This puts a lot of pressure on memory and GC. To address this issue (i.e., lower the pressure) we added several new series relatively recently. SampleDataBlockSeries was added in library version 10.1, and LiteLineSeries, LiteFreeformLineSeries, and DigitalLineSeries were added in version 10.3.

The first three are counterparts to older series: SampleDataSeries, PointLineSeries, and FreeformPointLineSeries. The new series can handle (chart can render) at least 10 times more points with the same RAM usage and smoothness of sweeping/scrolling of the X-axis.

The tradeoff for greatly improved performance (especially for more than a million points) is the reduced number of features supported by the new series.

In general, LightningChart .NET performance is excellent for all series. Especially if the point count is low (e.g. less than 1000 points).

If a user is building a very demanding real-time application with millions/billions of points to visualize, this feature (optimized memory and .NET garbage collector (GC) usage) becomes critical.

More and more data are generated every day, and hence more points should be handled by the user application. This puts a lot of pressure on memory and GC.

To address this issue (i.e., lower the pressure) we added several new series relatively recently.

SampleDataBlockSeries was added in library version 10.1, and LiteLineSeries, LiteFreeformLineSeries, and DigitalLineSeries were added in version 10.3.

The first three are counterparts to older series: SampleDataSeries, PointLineSeries, and FreeformPointLineSeries.

The new series can handle (chart can render) at least 10 times more points with the same RAM usage and smoothness of sweeping/scrolling of the X-axis.

The tradeoff for greatly improved performance (especially for more than a million points) is the reduced number of features supported by the new series.

Points Visible feature

While a line connecting two data points could be drawn for all line series types (controlled by the LineVisible or Visible properties), only half of the series could draw a symbol/point. Series which could draw symbols/points (controlled by the PointsVisible property) are SampleDataSeries, PointLineSeries, FreeformPointLineSeries, AreaSeries, and HighLowSeries.

You can alter the point style by setting PointStyle (PointStyleHigh or PointStyleLow) properties. Select the shape from many pre-defined styles from PointStyle.Shape. One of the shape styles is Bitmap, which allows drawing any bitmap image in the point location.

While a line connecting two data points could be drawn for all line series types (controlled by the LineVisible or Visible properties), only half of the series could draw a symbol/point.

Series which could draw symbols/points (controlled by the PointsVisible property) are SampleDataSeries, PointLineSeries, FreeformPointLineSeries, AreaSeries, and HighLowSeries.

You can alter the point style by setting PointStyle (PointStyleHigh or PointStyleLow) properties.

Select the shape from many pre-defined styles from PointStyle.Shape.

One of the shape styles is Bitmap, which allows drawing any bitmap image in the point location.

Coloring points individually

Starting from v.7.2, the PointLineSeries, FreeformPointLineSeries, AreaSeries, and HighLowSeries have the PointColor field in the data point structures.

To enable individual point coloring, set IndividualPointColoring to Color1, Color2, Color3, or BorderColor setting.

To disable individual point coloring, set IndividualPointColoring = Off. The color settings correspond to that color in the PointStyle property (see User Manual chapter 6.6.3 Coloring points individually).

XY-LineSeries-Coloring-Points-Individually
Figure 2.  Only PointLineSeries, FreeformPointLineSeries, AreaSeries, and HighLowSeries could have point-symbol. And those points could have individual colors. SampleDataSeries could show points, but all with the same style.

Y-value precision

Only SampleDataBlockSeries and SampleDataSeries support single precision sample Y values. While for SampleDataBlockSeries it is the only option, the SampleDataSeries supports single and double precision.

Using single precision values is recommended when keeping the memory reserving as low as possible. Select the sample format with the SampleFormat property. Note, that SampleDataSeries has 2 separate properties/arrays to keep different precision data (SamplesSingle and SamplesDouble respectively).

Only SampleDataBlockSeries and SampleDataSeries support single precision sample Y values.

While for SampleDataBlockSeries it is the only option, the SampleDataSeries supports single and double precision.

Using single precision values is recommended when keeping the memory reserving as low as possible.

Select the sample format with the SampleFormat property.

Note, that SampleDataSeries has 2 separate properties/arrays to keep different precision data (SamplesSingle and SamplesDouble respectively).

Y-value based coloring of line or fill

By enabling the UsePalette property of SampleDataSeries, PointLineSeries, FreeformPointLineSeries, AreaSeries, or HighLowSeries the coloring of the line (or Fill for the last two) is applied by the ValueRangePalette property.

ValueRangePalette contains Y values and color pairs. ValueRangePalette.Type sets the Gradient or Uniform steps palette (see User Manual chapters 6.14.1  and 6.15.3).

Y-value-based-coloring-of-line-or-fill
Figure 3.  Only SampleDataSeries, PointLineSeries, FreeformPointLineSeries, AreaSeries, or HighLowSeries could be colorized with ValueRangePalette (Y-value-based color).

CustomLinePointColoringAndShaping event

Custom coloring and coordinate adjustments can be made with the CustomLinePointColoringAndShaping event, which is called just before entering the rendering stage of the chart.

Customized coloring and coordinate adjustment could be done only for SampleDataSeries, PointLineSeries, and FreeformPointLineSeries (see User Manual chapter 6.14.21).

CustomLinePointColoringAndShaping-event
Figure 4.  Only SampleDataSeries, PointLineSeries, or FreeformPointLineSeries could have a CustomLinePointColoringAndShaping event handler, where the color can be modified before final rendering.

X-Axis ScaleBreaks

ScaleBreaks allow excluding specific X ranges. For example, inactive trading hours/dates or machinery off-production hours. All the series, that have been assigned to the specified X-axis, are clipped, including the axis and labels themselves.

There are limitations to when ScaleBreaks can be used: ScrollMode must be set to ‘None’ and ScaleType to ‘Linear’. Specify the range of the break with Begin and End, they are given as axis values, not DateTimes.

Use axis.DateTimeToAxisValue method to convert them if using DateTimes. Gap style could be configured. PointLineSeries, AreaSeries, and HighLowSeries have ContinuousOverScaleBreak properties.

By enabling it, a connecting line will be rendered over the gap. (for more information see User Manual chapter 6.3.2).

ScaleBreaks allow excluding specific X ranges. For example, inactive trading hours/dates or machinery off-production hours.

All the series, that have been assigned to the specified X-axis, are clipped, including the axis and labels themselves.

There are limitations to when ScaleBreaks can be used: ScrollMode must be set to ‘None’ and ScaleType to ‘Linear’.

Specify the range of the break with Begin and End, they are given as axis values, not DateTimes.

Use axis.DateTimeToAxisValue method to convert them if using DateTimes. Gap style could be configured.

PointLineSeries, AreaSeries, and HighLowSeries have ContinuousOverScaleBreak properties.

By enabling it, a connecting line will be rendered over the gap. (for more information see User Manual chapter 6.3.2).

X-Axis-ScaleBreaks
Figure 5. ScaleBreaks allows excluding specific X ranges (here 5-10). All the series, that have been assigned to the specified X-axis, are clipped, including the axis and labels themselves.

DataBreaking by NaN or other value

LightningChart skips rendering data points that match with specified breaking Value. For all the other values, it renders normally. Only PointLineSeriesBase class series support data breaking: SampleDataSeries, PointLineSeries, FreeformPointLineSeries, AreaSeries, or HighLowSeries.

The feature is enabled by enabling  Series.DataBreaking.Enabled property and setting desired value (Series.DataBreaking.Value default NaN) (see User Manual chapter 6.28). Note! When DataBreaking.Enabled = True, it will cause significant extra overhead and is not recommended for solutions needing very high real-time data rates. Consider using ClipAreas.

LightningChart skips rendering data points that match with specified breaking Value. For all the other values, it renders normally.

Only PointLineSeriesBase class series support data breaking: SampleDataSeries, PointLineSeries, FreeformPointLineSeries, AreaSeries, or HighLowSeries.

The feature is enabled by enabling  Series.DataBreaking.Enabled property and setting desired value (Series.DataBreaking.Value default NaN) (see User Manual chapter 6.28).

Note! When DataBreaking.Enabled = True, it will cause significant extra overhead and is not recommended for solutions needing very high real-time data rates. Consider using ClipAreas.

DataBreaking-by-NaN
Figure 6. DataBreaking by NaN or other value. SampleDataSeries, PointLineSeries, FreeformPointLineSeries, AreaSeries, or HighLowSeries may have specific values (X or Y), which indicated that line rendering should be broken (point/segment ignored).

ClipAreas

Like DataBreaking, ClipAreas can be used to prevent part of the series data from rendering. They can be used to filter out bad data ranges, out-of-range data by Y value, etc. The ClipArea applies to the series (applicable for all XY series) that it has been assigned to. Note that this is a rendering-stage clipping and mouse operations will respond to series when placed over the ClipArea if there’s actual data under it.

Using ClipAreas is the performance-wise preferred way to break a line into several data segments instead of using the DataBreaking feature. (see User Manual chapter 6.29).

Like DataBreaking, ClipAreas can be used to prevent part of the series data from rendering.

They can be used to filter out bad data ranges, out-of-range data by Y value, etc.

The ClipArea applies to the series (applicable for all XY series) that it has been assigned to.

Note that this is a rendering-stage clipping and mouse operations will respond to series when placed over the ClipArea if there’s actual data under it.

Using ClipAreas is the performance-wise preferred way to break a line into several data segments instead of using the DataBreaking feature. (see User Manual chapter 6.29).

ClipAreas
Figure 7. ClipAreas can be used to prevent part of the series data from rendering. Here ‘clip band’ between XAxis {3,5} and between YAxis {-2,2}. Clipping is applied for all series.

Tracking Y-value with LineSeriesCursors

Line series cursors allow tracking of many line series at once by tracking the Y-values at the X coordinate. Series values can only be resolved with series implementing ITrackable interfaces (SampleDataSeries, SampleDataBlockSeries, PointLineSeries, LiteLineSeries, DigitalLineSeries, AreaSeries, HighLowSeries).

LineSeriesCursors, can snap-to-points or show interpolated value (SnapToPoints property). In addition, it has several styles: PointTracking (configurable shape and size of tracking point), HairCrossTracking (thick and thin-hair, coloring mixing, etc.), and VerticalNoTracking (no tracking point or line just vertical line). (see User Manual chapter 6.34).

Line series cursors allow tracking of many line series at once by tracking the Y-values at the X coordinate.

Series values can only be resolved with series implementing ITrackable interfaces (SampleDataSeries, SampleDataBlockSeries, PointLineSeries, LiteLineSeries, DigitalLineSeries, AreaSeries, HighLowSeries).

LineSeriesCursors, can snap-to-points or show interpolated value (SnapToPoints property).

In addition, it has several styles: PointTracking (configurable shape and size of tracking point), HairCrossTracking (thick and thin-hair, coloring mixing, etc.), and VerticalNoTracking (no tracking point or line just vertical line). (see User Manual chapter 6.34).

Tracking-Y-value-with-LineSeriesCursors
Figure 8. LineSeriesCursor tracks the Y-values at X coordinate for all ‘progressive’ line-series (all but LiteFreeformLineSeries, FreeformPointLineSeries, and LineCollection). Here is HairCrossTracking style is shown, although various style markers could be used instead.

Tracking with DataCursors

Starting from version 10.4 new type of DataCursor is added. DataCursor tracks all XY series, including line-series discussed here. It finds the closest data point to the mouse cursor and shows it X-Y values, series titles, and other relevant information in the ‘Result table’.

Hair Cross’ lines (vertical and horizontal) could be shown. ‘Labels’ with the point’s x/y value are shown on the axis Series is assigned to. The style and visibility of each DataCursor item (‘Tracking Point’, ‘Result table’, ‘Hair Cross’, ‘Labels’) could be configurated.

The ‘Result table’ header and ‘Labels’ box fill’s color are defined by line-series color, bar-series color, or heatmap pixel color. The ‘Result table’ text color is defined by the series title color. (see User Manual chapter 6.35).

Starting from version 10.4 new type of DataCursor is added. DataCursor tracks all XY series, including line-series discussed here.

It finds the closest data point to the mouse cursor and shows it X-Y values, series titles, and other relevant information in the ‘Result table’.

Hair Cross’ lines (vertical and horizontal) could be shown. ‘Labels’ with the point’s x/y value are shown on the axis Series is assigned to.

The style and visibility of each DataCursor item (‘Tracking Point’, ‘Result table’, ‘Hair Cross’, ‘Labels’) could be configurated.

The ‘Result table’ header and ‘Labels’ box fill’s color are defined by line-series color, bar-series color, or heatmap pixel color.

The ‘Result table’ text color is defined by the series title color. (see User Manual chapter 6.35).

Tracking-With-DataCursor
Figure 9.  Data points of all series could be tracked with DataCursor. The series title, point color, and values of the closest point to mouse-cursor is shown.

Polynomial regression

Only PointLineSeries has properties/features to do regression fitting for data points. Regression fitting, utilizing RegressionFitting and RegressionPolyOrder properties of PointLineSeries. When RegressionFitting is set other than the None option, lines, and points are replaced with a fitted curve.

For other series, it is possible to use MathRoutines.PolynomialRegression() method and replace data with fitted points. (see User Manual chapter 6.15).

Only PointLineSeries has properties/features to do regression fitting for data points.

Regression fitting, utilizing RegressionFitting and RegressionPolyOrder properties of PointLineSeries.

When RegressionFitting is set other than the None option, lines, and points are replaced with a fitted curve.

For other series, it is possible to use MathRoutines.PolynomialRegression() method and replace data with fitted points. (see User Manual chapter 6.15).

Limit Y-value To Stack Segment

Each XY series has a Boolean LimitYToStackSegment property. This limits Y draw range to segment area when y-axes are stacked.

For most of the XY series, if the property is enabled simple clipping of data is done. However, newer series (SampleDataBlockSeries, LiteLineSeries, and LiteFreeformLineSeries) have additional options.

There LimitYToSegment is enumerated type: None, Clip (a line will be clipped as for old series), and ClampToSegment (if the line exceeds the segment’s edge, it will be rendered horizontally on the y-axis edge).

Note, the LiteFreeformLineSeries ClampToSegment line will be rendered along the edge as far as the real point x-value would be, therefore, may be longer than other series clamping lines. (see User Manual chapter 6.1.4).

Each XY series has a Boolean LimitYToStackSegment property. This limits Y draw range to segment area when y-axes are stacked.

For most of the XY series, if the property is enabled simple clipping of data is done.

However, newer series (SampleDataBlockSeries, LiteLineSeries, and LiteFreeformLineSeries) have additional options.

There LimitYToSegment is enumerated type: None, Clip (a line will be clipped as for old series), and ClampToSegment (if the line exceeds the segment’s edge, it will be rendered horizontally on the y-axis edge).

Note, the LiteFreeformLineSeries ClampToSegment line will be rendered along the edge as far as the real point x-value would be, therefore, may be longer than other series clamping lines. (see User Manual chapter 6.1.4).

Limit-Y-value-To-Stack-Segment
Figure 10.   When the series has the Boolean LimitYToStackSegment property enabled, the y-value is clipped at minimum and maximum. This is applicable for all XY series.

Automatic Series title placement

Each XY series has a title (by default hidden), for which style and position could be modified through properties. The user could enable ViewXY.TitlesAutoPlacement.Enabled, which informs the chart that the Series’ Title location should be calculated in order to avoid multiple titles overlapping.

The title position could be locked (at the current X-Y value) by enabling a series.Title.LockAutoPosition property. Auto positioning is reset with ViewXY.TitlesAutoPlacement.Reset() method.

Each XY series has a title (by default hidden), for which style and position could be modified through properties.

The user could enable ViewXY.TitlesAutoPlacement.Enabled, which informs the chart that the Series’ Title location should be calculated in order to avoid multiple titles overlapping.

The title position could be locked (at the current X-Y value) by enabling a series.Title.LockAutoPosition property.

Auto positioning is reset with ViewXY.TitlesAutoPlacement.Reset() method.

Line Style (pattern)

All (10) line series could render lines (between 2 or more points). Each of line-series has properties controlling the color and width of the line. In addition to those properties, the Pattern also could be modified.

Available options are Solid, Dot, Dash, DashDot, and SmallDot. Pattern lines could be drawn for SampleDataSeries, PointLineSeries, FreeformPointLineSeries, AreaSeries, HighLowSeries, and LineCollection.

For those series also PatternScale property could be used to modify the length of each dash or dot. With SampleDataBlockSeries, LiteLineSeries, LiteFreeformLineSeries, and DigitalLineSeries only a Solid line could be drawn.

All (10) line series could render lines (between 2 or more points).

Each of line-series has properties controlling the color and width of the line.

In addition to those properties, the Pattern also could be modified.

Available options are Solid, Dot, Dash, DashDot, and SmallDot.

Pattern lines could be drawn for SampleDataSeries, PointLineSeries, FreeformPointLineSeries, AreaSeries, HighLowSeries, and LineCollection.

For those series also PatternScale property could be used to modify the length of each dash or dot.

With SampleDataBlockSeries, LiteLineSeries, LiteFreeformLineSeries, and DigitalLineSeries only a Solid line could be drawn.

Conclusion

In conclusion, choosing the best LightningChart .NET XY line series for your project requires careful consideration of several factors such as performance, customization options, and ease of use.

It’s important to assess your project’s specific needs and requirements, and then evaluate each line series based on its ability to meet those needs.

Whether you’re working on a high-performance financial application, or a simple data visualization project, LightningChart offers a range of XY line series options to suit your needs.

By taking the time to evaluate the different options available and selecting the best one for your project, you can ensure that your application will perform optimally and provide valuable insights to your users.

Kestutis Gurevicius, CTO, Scientific Software Analyst, Support, Team Lead (.NET)

Kestutis Gurevicius

CTO, Scientific Software Analyst, Support, Team Lead (.NET) LinkedIn icon
divider-light

Continue learning with LightningChart