3
votes

So have a chart with 2 chart areas and 3 series. Top chart area has 2 series. 1st series shows prices over time and 2nd series in top chart area shows earnings per share over the same time

Bottom chart area has 1 series and it shows volume over the same time.

All 3 series have the same amount of points. All 3 series XValueType is set to Date.

When the data is daily stock prices there are gaps on weekend and would like to suppress. So what is supposed to do this is setting IsXValueIndexed to true. If we do that the chart renders, but none of the lines show in either the price chart of the volume chart.

My understanding is for IsXValueIndexed to work each series has to have the same number of points with all having same date at the same point along the X axis. They do.

What else could I be missing?

1
Hard to tell when we don't see any code, any data or the chart (when it is drawn, of course, or both). - TaW
It would be awesome if you could provide a minimal reproducible example. - mjwills

1 Answers

2
votes

The only explanation for the effect you describe is that you have set Maximum&Minimum values for the x-axis.

MSDN:

Series.IsXValueIndexed

Gets or sets a flag that indicates whether data point indices will be used for the X-values

You got the other rules (about e.g. series alignment) right, but this simple statement implies that the actual x-values are now disregarded; they can still be used in formatting labels and also in calculating stuff (see below!), but when it comes to the layout of the datapoints along the axis they are all replaced by indices 0,1,2..

Therfore any values you have set for XAxis.Minimum&Maximum will no longer work as expected: the DateTimes in your points internally are huge doubles; no way an index can ever reach there, unless your dates are from the beginning of DateTime (January 1, 0001) time..

You can test by resetting the Minimum/Maximum values:

 Axis ax = someChartArea.AxisX;

 ax.Minimum = double.NaN;
 ax.Maximum = double.NaN;

But if you have set them you probably need them. So you may need to calculate the indices to use instead; here is an example:

Series s = yourSeries;

var p1 = s.Points.Where(x => x.XValue > ax.Minimum).First();
var p2 = s.Points.Where(x => x.XValue <= ax.Maximum).Last();

ax.Minimum = s.Points.IndexOf(p1);
ax.Maximum = s.Points.IndexOf(p2) + 1;

But maybe a simpler scheme will do as well or better when is come to e.g. paging..

Let's have a look:

enter image description here