Object tree - sharing LightningChart objects
Posted: Mon Sep 19, 2016 12:54 pm
LightningChart object model is tree-based. Every class has it's parent object, and list of child objects. With aid of this tree, child object notifies parent of its changes, so that parent can respond to it respectively, and parent notifies its parent chain until reaching the root node, LightningChartUltimate itself, so it knows how to refresh accordingly.
Objects also have reference to their unmanaged counterparts, like GPU resources. Disposing of shared objects explicitly by user code, or internally by LightningChart, will very likely lead into crashing, black screen, or flickering problems.
Therefore: Sharing objects between other objects is forbidden.
Example 1 of wrong usage:
WRONG. Same Fill object can't be shared between multiple objects.
Correct way: Only copy properties if they are of ValueType (e.g. Integer, Double, Color)
Example 2 of wrong usage:
WRONG. Same object shouldn't be added to collection of multiple collections.
Correct way: Create own marker for both series.
Objects also have reference to their unmanaged counterparts, like GPU resources. Disposing of shared objects explicitly by user code, or internally by LightningChart, will very likely lead into crashing, black screen, or flickering problems.
Therefore: Sharing objects between other objects is forbidden.
Example 1 of wrong usage:
Code: Select all
AnnotationXY annotation1 = new Annotation();
chart.ViewXY.Annotations.Add(annotation1);
AnnotationXY annotation2 = new Annotation();
annotation2.Fill = annotation1.Fill;
chart.ViewXY.Annotations.Add(annotation2);
Correct way: Only copy properties if they are of ValueType (e.g. Integer, Double, Color)
Example 2 of wrong usage:
Code: Select all
SeriesEventMarker marker = new SeriesEventMarker();
chart.ViewXY.PointLineSeries[0].SeriesEventMarkers.Add(marker);
chart.ViewXY.PointLineSeries[1].SeriesEventMarkers.Add(marker);
Correct way: Create own marker for both series.