I'm using the XamDataChart to show some ScatterSeries data and would like to graphically indicate that the marker in a series is selected. Essentially, if the user clicks on the marker (or otherwise selects it), I'd like to do something to either resize or color (maybe both) that marker while it is the selected data point.
I've tried something like so to change the fill color and it works:
xamDataChart1_seriesMouseLeftButtonUp(object sender, DataChartMouseButtonEventArgs e)
{
Shape shape = e.OriginalSource as Shape;
//
Color color = new Color();
color = Color.FromArgb(255,255,0,0);
shape.Fill = new SolidColorBrush(color);
}
And that will change the shape fill for the marker I click on to red. But what about resizing the shape to maybe twice as big? How can I do that?
Thanks,
Matt
Thanks for the ideas - I appreciate it.
Best,
Yeah, you have to be careful as the series calculates where to position the marker based on its desired size, so adjusting the width and height after the series has positioned the marker will result in its being offset until the series adjusts. Performing a scale transform like you have done there is a good way around this. You could probably just set the transform to null to remove it by the way.
If you were to put a property on your data items that are bound to the chart that coincides with whether the marker is "bigger" then you could bind against that property in a custom marker template to know whether to draw large or small. Then, all you would need to do in your click event is to do something like this
//set some other biggified ones to unbig maybe...
e.Item.IsLarge = true;
etc.
Also see:
http://community.infragistics.com/forums/p/45121/244711.aspx#244711
http://blogs.infragistics.com/blogs/anton_staykov/archive/2010/08/31/bubbleseries-in-xamdatachart.aspx
Hope this helps!
-Graham
I ended up doing something like so:
shape.RenderTransform = new ScaleTransform(2.0,2.0, shape.RenderSize.Height/2.0, shape.RenderSize.Width/2.0);
And this will blow the marker up to twice its size centered properly.
When I want to undo the scaling, I applied another ScaleTransform to it, something like this:
shape.RenderTransform = new ScaleTransform(1.0, 1.0, shape.RenderSize.Height/2.0, shape.RenderSize.Width/2.0);
Seems to work well enough.
If you have other thoughts, I'd be interested in hearing them.
Regards,