When setting a Series
to be indexed by setting the Series.IsXValueIndexed
to true
the chart requires all Series
to be aligned:
If you are displaying multiple series and at least one series uses indexed X-values, then all series must be aligned — that is, have the same number of data points—and the corresponding points must have the same X-values.
How can you add the necessary Emtpy DataPoints
to the slots they are missing in, in any of the Series
?
This routine first collects all values in all
Series
in a collection ofdoubles
.Then it loops over all
Series
and over all values and inserts the missing emptyDataPoints
:Note that the code assumes ..
that your x-values are correctly set, i.e. they were added as
numbers
orDateTimes
. If you added them asstrings
they all are0
and indexing makes no sense.that the
DataPoints
were added in ascending order. This is not always the case, especially when plottingLineCharts
. However indexing these makes no sense either.Also note that you can set several options of how to treat
Empty DataPoints
in aSeries
by setting properties in theSeries.EmptyPointStyle
, which is derived fromDataPointCustomProperties
.So you could set their
Color
like this: