How to set the same number of data points in a Line Chart?

839 views Asked by At

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";
1

There are 1 answers

0
TaW On

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.

  • One question here is where do you inset them (X-Value), probably where they are missing, right?
  • The other question is what ChartType do your series have? Here are a few typical types:

    • Point, Bars, Columns: That is fine, just make the Color 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 a Point Series on top with the same data, but with the missing Points invisible.

Btw: If you have correctly set the XValueType as DateTime, all this ought to be unnecessary, as then the missing dates won't matter and the DataPoints all sit at their respective dates. They only shift if you don't have a valid X-Value and/or fitting XValueType.

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..