Answered by:
Charting with gaps in series
Question

User1812511197 posted
I need to chart data that has gaps in series.
I have tried..... I have not been able to fin many examples with this code, so maybe I am not using it correctly.
Chart1.AlignDataPointsByAxisLabel()
I get the following errror....
To align data points to X axis labels all series must have XValueIndexed property set to true or use only zero XValue for all data points.
What am I not understanding about this code?
Wednesday, July 20, 2016 5:49 PM
Answers

User283571144 posted
Hi gene7135,
Aligning the multiple series, is the point behind my entire problem.
It was my understanding that the AlignDataPointByAxisLabel command would insert zeros where needed to accomplish this.
Do to the data being retrieved from the query, I have no way of ensuring the same no of series show.
As far as I know, Data points in the chart can be positioned along the X axis using their X values or index of the data point in the series.
Chart uses index of the data points in the collection to position along the axis in these cases:
1) All data point XValue properties are set to zero.
This happens if you only bind the Y value or you binding to a categorical (string) value.2) XValueIndexed property of the series is set to true.
Aligned series means that we have exactly the same number of data points and their X values (or AxisLabel for categories) match in the same order.
You need to analyze the data in your series and the result of the formula and make sure they are 'aligned' and can be plotted together.
Here are the common steps required to align series:
1) Add empty points to make sure you have same number of series.
In simple cases you need to add empty points in the beginning or end of the series but you may also have to add empty points in the middle.2) Group several data points into one.
For example, if you have hourly data you may group it into a single day point.
Best Regards,
Brando
 Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, July 27, 2016 9:07 AM
All replies

User1812511197 posted
if it helps, is is a pic of the chart showing the gaps.
Wednesday, July 20, 2016 9:08 PM 
User283571144 posted
Hi gene7135,
To align data points to X axis labels all series must have XValueIndexed property set to true or use only zero XValue for all data points.
What am I not understanding about this code?
As far as I know, this error shows you must define Series's IsXValueIndexed value to true, beacuse AlignDataPointsByAxisLabel means aligns data points along the X axis using their axis labels.
More details, you could refer to follow codes and link:Chart1.Series.FindByName("series1").IsXValueIndexed = true; Chart1.Series.FindByName("Serise2").IsXValueIndexed = true;
https://msdn.microsoft.com/enus/library/system.web.ui.datavisualization.charting.chart.aligndatapointsbyaxislabel(v=vs.110).aspx
https://msdn.microsoft.com/engb/library/system.web.ui.datavisualization.charting.series.isxvalueindexed(v=vs.110).aspxBest Regards,
BrandoThursday, July 21, 2016 5:34 AM 
User1812511197 posted
Where is where I am now.
I created a loop to loop through all the Series and the the XvalueIndexed property to true. Then call the Chart1.AlignDataPointsByAxisLabel().
Dim x As Integer = Chart1.Series.Count Dim start As Integer = 0 For start = 0 To x Chart1.Series(start).IsXValueIndexed = True Next Chart1.AlignDataPointsByAxisLabel()
Now I get the following error.
Cannot display indexed series (XValueIndexed = true) on the same axis if they are not aligned.Series 'Name1' and Series 'Name2' must be aligned to perform the operation. The series currently have a different number of data points.
Any thoughts?
Thursday, July 21, 2016 3:36 PM 
User283571144 posted
Hi gene7135,
Cannot display indexed series (XValueIndexed = true) on the same axis if they are not aligned.Series 'Name1' and Series 'Name2' must be aligned to perform the operation. The series currently have a different number of data points.This error means you should make sure the number of all Series's point is the same.
I suggest you check your codes and set same number of series.
MSDN "Series.IsXValueIndexed Property" important message:
If you are displaying multiple series and at least one series uses indexed Xvalues, then all series must be aligned—that is, have the same number of data points—and the corresponding points must have the same Xvalues.
More details, you could refer to follow link:
Best Regards,
Brando
Friday, July 22, 2016 6:52 AM 
User1812511197 posted
Aligning the multiple series, is the point behind my entire problem.
It was my understanding that the AlignDataPointByAxisLabel command would insert zeros where needed to accomplish this.
Do to the data being retrieved from the query, I have no way of ensuring the same no of series show.
Thanks for trying Brando! It is appreciated.
Friday, July 22, 2016 3:22 PM 
User283571144 posted
Hi gene7135,
Aligning the multiple series, is the point behind my entire problem.
It was my understanding that the AlignDataPointByAxisLabel command would insert zeros where needed to accomplish this.
Do to the data being retrieved from the query, I have no way of ensuring the same no of series show.
As far as I know, Data points in the chart can be positioned along the X axis using their X values or index of the data point in the series.
Chart uses index of the data points in the collection to position along the axis in these cases:
1) All data point XValue properties are set to zero.
This happens if you only bind the Y value or you binding to a categorical (string) value.2) XValueIndexed property of the series is set to true.
Aligned series means that we have exactly the same number of data points and their X values (or AxisLabel for categories) match in the same order.
You need to analyze the data in your series and the result of the formula and make sure they are 'aligned' and can be plotted together.
Here are the common steps required to align series:
1) Add empty points to make sure you have same number of series.
In simple cases you need to add empty points in the beginning or end of the series but you may also have to add empty points in the middle.2) Group several data points into one.
For example, if you have hourly data you may group it into a single day point.
Best Regards,
Brando
 Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, July 27, 2016 9:07 AM