Can I have a break in a line series?

Oystein Bjorke 5 years ago 0
This discussion was imported from CodePlex

_Noctis_ wrote at 2013-10-21 06:28:

Assume I have a collection of 10 points.
The first five from the function: Y = X.
The last five from the function Y = 2X.
Is there any way of plotting the line for points 1 to 5, then have a break (as in, don't trace the line from 5 to 6), then continue?

The reason behind this, is I have a collection of points in a line, but I want to be disable some of the connections (for example when the next x-value is far away, or when the next y-value is lower than the prev)

The only workaround i can see is creating a different series, then giving them both the same color, and disabling one of them in the labels or something...

cwevers wrote at 2013-10-21 11:29:

Try adding a DataPoint.Undefined point between the two sets.

If the first point of the second set is invalid (i.e. a point instead of a line) try re-adding the last point of the first set to the second set.

E.g.:

series.Points.Add(new DataPoint(0, 0));
series.Points.Add(new DataPoint(1, 10));
series.Points.Add(new DataPoint(2, 20));
series.Points.Add(new DataPoint(3, 30));
series.Points.Add(new DataPoint(4, 40));

series.Points.Add(DataPoint.Undefined);
series.Points.Add(new DataPoint(4, 40));
series.Points.Add(new DataPoint(5, 50));
series.Points.Add(new DataPoint(6, 60));
series.Points.Add(new DataPoint(7, 70));

_Noctis_ wrote at 2013-10-22 09:02:

Marvelous ...

5 lines of code in the loop logic and this is solved.

Thanks for the help :)
CodePlex