Hello!
I'm new to DataChart, and have a following question.
I need to create a line chart with several series, like this:
Series1: { X: 0, Y:0; X:1, Y:5; X:2,Y:10; X:3, Y:15 }Series2 may be like this: { X: 10, Y:10; X:11, Y:15; X:12,Y:110; X:13, Y:115 }Series3 may also be something different.
Normally I'd do it like this:
for( i = 0; i < 3; i++ ){ series = new LineSeries(); points = new points(); for( // all points ) { point = new point; // .... points.Add( point ); } series.ItemSource = points; chart.Series.Add( series );}
The question is -- what do I do with the XAxis? In the samples there is a line:
xmXAxis.ItemsSource = data;
But here it's not a simple data, it's an array of arrays of points. If I don't execute this line, the chart comes out empty. So, how whould I do this? Or would I better be off with WebChart in tis case (but what about performace?)?
Thanks in advance!
Certainly there have been some issues fixed with CategoryDateTimeXAxis since the first version of 10.2. I would recommend updating to the latest service release if you can, and a later volume release if possible, as there have also been some performance improvements to all series types since 10.2.
Hope this helps!
-Graham
For CategoryDateTimeXAxis I use LineSeries of course instead of ScatterLineSeries, and apart from this issue this seems to work quite ok.
I will put a sample tomorrow, if I have time. The version we use is 10.2For now I think you very much for your support! :)
Hi,
Which version are you using? This sounds like a bug that has already been resolved. Could you provide a small sample that replicates it?
With categoryXAxis, you can use dates, they are just treated like string values, so you wont see a larger space between values if there is a large time between them. If your sampling rate is constant though, this shouldn't matter. CategoryDateTimeXAxis will allow for different time spans between different data points to be represented as different spacings, rather than everything being equidistant.
This is for use with category type series though, so if you are using a scatter line series, you will have to use a NumericXAxis for the dates. If you do a search on these forums you should see examples of using a numericXAxis with date time values.
Thanks for your reply!
I tried the scatter series, and it seems to do the trick, so I think I'll leave it as it is, at least for now.
Now I have another question. If I have data with X values being dates, I think that's where the CategoryDateTimeXAxis comes into play, doesn't it? And sometimes the chart rendering fails with the message:
Message: Unhandled Error in Silverlight Application Index was out of range. Must be non-negative and less than the size of the collection.Parameter name: index at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource) at System.ThrowHelper.ThrowArgumentOutOfRangeException() at System.Collections.Generic.List`1.get_Item(Int32 index) at Infragistics.FastItemColumn.get_Item(Int32 index) at Infragistics.Controls.Charts.AnchoredCategorySeries.PrepareFrame(CategoryFrame frame) at Infragistics.Controls.Charts.CategorySeries.RenderSeries(Boolean animate) at Infragistics.Controls.Charts.CategorySeries.ViewportRectChangedOverride(Rect oldViewportRect, Rect newViewportRect) at Infragistics.Controls.Charts.Series.<OnApplyTemplate>b__a(Object o, SizeChangedEventArgs e) at System.Windows.FrameworkElement.OnSizeChanged(Object sender, SizeChangedEventArgs e) at MS.Internal.JoltHelper.RaiseEvent(IntPtr target, UInt32 eventId, IntPtr coreEventArgs, UInt32 eventArgsTypeIndex)Line: 1Char: 1Code: 0Message: Unhandled Error in Silverlight Application Index was out of range. Must be non-negative and less than the size of the collection.Parameter name: index at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource) at System.ThrowHelper.ThrowArgumentOutOfRangeException() at System.Collections.Generic.List`1.get_Item(Int32 index) at Infragistics.FastItemColumn.get_Item(Int32 index) at Infragistics.Controls.Charts.AnchoredCategorySeries.PrepareFrame(CategoryFrame frame) at Infragistics.Controls.Charts.CategorySeries.RenderSeries(Boolean animate) at Infragistics.Controls.Charts.XamDataChart.<.ctor>b__d(Object o, AxisRangeChangedEventArgs e) at Infragistics.Controls.Charts.Axis.RaiseRangeChanged(AxisRangeChangedEventArgs ea) at Infragistics.Controls.Charts.NumericAxisBase.UpdateRange() at Infragistics.Controls.Charts.NumericYAxis.ViewportChangedOverride(Rect oldRect, Rect newRect) at Infragistics.Controls.Charts.Axis.<.ctor>b__5(Object o, SizeChangedEventArgs e) at System.Windows.FrameworkElement.OnSizeChanged(Object sender, SizeChangedEventArgs e) at MS.Internal.JoltHelper.RaiseEvent(IntPtr target, UInt32 eventId, IntPtr coreEventArgs, UInt32 eventArgsTypeIndex)Line: 1Char: 1Code: 0I suspect the problem is that we have a setting in our system that limits the number of points rendered in the chart. So it may happen that there are 4 series with 24 points, and 1 serie with 4 points -- and that's when the exception happens. For now I've put an IF checking that if a serie has less points than the 1st one, it doesn't get added -- but is that a proper solution, or just a workaround, and is there a better solution in the latter case?
If you have a situation where both of your axes are numerical it can often make sense to use a scatter type series rather than a category series. I really depends on your other requirements. If you want some of the other capabilities of the category series, clustering series by category, for example. Then you may want to use category series by padding the data such that you have zero values for a series where data was not present for that index. If you are dealing with large volumes of data the category series is also better performing than the scatter series, as we are able to make more assumptions about the shape of the data.
Meanwhile, if you have a very sparse representation of data, but must represent the spaces between the data points based on their differing x values then scatterlineseries may be much more appropriate.
If you could describe what you are trying to achieve in more detail I may be able to point you in the right direction.