Hello!
Another that I have is this: Is it possible to override the zooming action so that the actual zoom doesn't happen (i.e. chart stays as it is), but instead a list of the points within the zoom window is returned, so that they can be filtered out to create a separate report on them?
Well the data items (read: points) do have a Color property in them. The question is -- how do I access the serie color from inside the point?
The simplest way would be to engineer it such that the data items had the series color in a property, unless they had a property directly set on them.
For example, if they had one property called ActualBrush, and one called Brush. ActualBrush could check to see if Brush was null and return the value for the series if so, Otherwize the value of Brush. And then you would bind to ActualBrush rather than Brush.
There are other ways to achieve this too, although they would require a bit of a more complex setup. In WPF you could use a PriorityBinding, but I don't believe you have access to that in Silverlight.
-Graham
Any ideas?..
Thank you very much (again :) for your help -- it works.
I have another question, though. Now that the MarketTemplate.Brush is bound to Point.Color, by default, if Point.Color is not set, the marker is just not drawn. Is there an easy way to make it so that if Point.Color is not defined, the color of the serie is used instead (i.e., the markers on the yellow line are yellow, on the blue line are blue, &c.)?
The markers are not especially complicated for you to make this modification. They are all in the default style of the chart.
If you still want to use the charts ability to auto pick a marker type for each series you can actually modify each of these marker datatemplates to suit your needs and then assign them to the various template properties on the chart.
You will see properties that read something like this "CircleMarkerTemplate", etc. If you replace each of these with your custom version (a slightly modified version of what we ship with the default style). Then the chart will automatically cycle through these and choose a unique shape per series.
<DataTemplate x:key="TriangleMarkerTemplate"> <Polygon Points="0, 0 4, 8 8, 0" Stretch="Fill" Fill="{Binding ActualItemBrush}" Stroke="{Binding Series.ActualMarkerOutline}" Strokethickness="0.5"> </Polygon> </DataTemplate>
As an example, this is the default triangle marker. By default it takes its color from the assigned color of the series. Your modified version would just get its brush from somewhere on the data item:
<DataTemplate x:key="TriangleMarkerTemplate"> <Polygon Points="0, 0 4, 8 8, 0" Stretch="Fill" Fill="{Binding Item.Color}" Stroke="{Binding Series.ActualMarkerOutline}" Strokethickness="0.5"> </Polygon> </DataTemplate>
The other markers are just as simple, for the most part.