I'm currently testing out IG's DataVisualizaion and Charting tools, xamDataChart looks very nice, and I'm wondering if it can emulate, in xaml, a sort of DataTemplate wrapper for a Series (Line particularly). I've had success with a different Charting toolkit with an external wrapper class, and it's code looked something like this:
<multiChart:MultiChart> <multiChart:MultiChart.SeriesTemplate> <DataTemplate> <chartingToolkit:LineSeries /> </DataTemplate> </multiChart:MultiChart.SeriesTemplate> </multiChart:MultiChart>
The DataTemplate's the crucial part, as I do not know how many series I'll need to render until runtime. I don't see any kind of DataTemplate in the XamDataChart class, would there be another way to achieve this kind of behavior?
Hi,
Please see this post.
http://community.infragistics.com/forums/p/40011/242380.aspx#242380
Its possible it may need a small adjustment for the WPF version due to some different ways that DataContext is handled. Let me know if you have any problems or questions. I'll try to test this out later today myself and see if it needs any WPF adjustments.
We have been considering adding this feature natively. If you are interested in it, you could make a feature request to lodge your vote for it.
Hope this helps!
-Graham
The version I linked is a bit complicated, but very flexible, because it does everything with attached properties. You could also approach it with a just wrapper class instead which may simplify some things, but decrease the flexibility an amount.
Steph,
WPF has a couple differences with its binding engine that affect this sample. Specifically with the order in which it evaluates indexers. You need to perform a cast on the integers in the indexers to prevent them from being treated as string indexers. See: http://community.infragistics.com/forums/p/50183/264477.aspx#264477
Thanks Graham for your answer !
I modified my code like that but nothing changed :
<core:SeriesBinder.BindingInfo>
<core:SeriesBindingInfo ItemsSource="{Binding SeriesCollection}">
<core:SeriesBindingInfo.SeriesTemplate>
<DataTemplate>
<igCDA:LineSeries
XAxis="{Binding Path=Owner.Axes[(System:Int32)0]}"
YAxis="{Binding Path=Owner.Axes[(System:Int32)1]}"
ItemsSource="{Binding DataSource, Mode=OneWay}"
Title="Test"
MarkerType="None"
ValueMemberPath="TwrPerformance"
TransitionDuration="0"
Brush="#FF9966" />
</DataTemplate>
</core:SeriesBindingInfo.SeriesTemplate>
</core:SeriesBindingInfo>
</core:SeriesBinder.BindingInfo>
Did you also add the namespace binding for System, discussed further down the page? Are you receiving any binding errors in the log?
No errors, Axis are well drawn with right minimum and maximum values, just LineSeries don't appear.
If I use the code below instead of the SeriesBinder, it works :
<igCDA:LineSeries XAxis="{Binding ElementName=xAxis, Mode=OneWay}"
YAxis="{Binding ElementName=yAxis, Mode=OneWay}"
ItemsSource="{Binding SeriesCollection[0].DataSource, Mode=OneWay}"
The thing is I don't have a static collection of LineSeries.....
Steph
One more thing,
if I debug, I can see in my chart the right number of series but it's like the binding doesn't work for datapoints (ItemsSource is null).......
Hello,
I finally figured out what's going on..... I went through your code and find out you encapsulate ItemsSource in an Item object.... I just changed my code like that and everything works fine :
ItemsSource="{Binding Item.DataSource, Mode=OneWay}"
Thanks for you support Graham.