I have multiple series which share the same x-axis but some values are repeated as they have different number of data points. Since this is the case I want to set the same number of data points for all my series.
Is setting empty data points a solution to make all series have the same number of data points or are there any other solutions? If setting empty data points is a solution, how do I use it? My series aren't fixed and vary according to user selection.
They follow:
Chart1.Series[i].XValueMember = "Receipt date";
Chart1.Series[i].YValueMembers = "AvgAgingDays";
Is setting empty data points a solution?
Well, it certainly will achieve the counts to be the same. But how it looks is a different matter.
The other question is what
ChartType
do your series have? Here are a few typical types:Point, Bars, Columns
: That is fine, just make theColor
of the 'empty'Points
Transparent
!Line, Area
: That is more tricky. You don't want gaps in the lines so you need to keep them visible. And you want the lines to go straight so you need to calculate the Y-Values from the neighbours. Simple for one missing Point, a little bit more work for larger gaps. Not possible for points missing at the start or end. Those should be invisible again..Spline
: Next to impossible to get really right. Either put in some more work or live with some inaccuracies!If you have a
Line
chart, to fully document the situation, you may consider adding aPoint Serie
s on top with the same data, but with the missingPoints
invisible.Btw: If you have correctly set the
XValueType
asDateTime
, all this ought to be unnecessary, as then the missing dates won't matter and theDataPoints
all sit at their respective dates. They only shift if you don't have a validX-Value
and/or fittingXValueType
.This is a rather comon mistake because at first it all looks fine but without setting the type it will be
string
and then you run into trouble when you want to act on the values or rely on their positions or even just format them..Btw: While it is possible to
AddXY
the missing points afterwards, it makes things a lot easier if you can detect and add them while adding the real points..