.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
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.
Assumption about order of X-value in data array
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).
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).
Optimize memory and GC usage
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.
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
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.
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
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).
Y-value 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).
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
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).
CustomLinePointColoringAndShaping event
Customized coloring and coordinate adjustment could be done only for SampleDataSeries, PointLineSeries, and FreeformPointLineSeries (see User Manual chapter 6.14.21).
X-Axis ScaleBreaks
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).
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).
DataBreaking by NaN or other value
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.
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.
ClipAreas
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).
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).
Tracking Y-value with LineSeriesCursors
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).
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 with DataCursors
‘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).
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).
Polynomial regression
For other series, it is possible to use MathRoutines.PolynomialRegression() method and replace data with fitted points. (see User Manual chapter 6.15).
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
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).
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).
Automatic Series title placement
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.
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)
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.
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.