Drawing inside Scatter DataChart

[Infragistics] Petar Monov / Wednesday, May 18, 2011

There has been lots of questions on how to draw different objects inside our charts and almost each and every one has a requirement on how this should be done on specific axes coordinates. That is why I have created a sample project, with David Carron’s help, that draws a rectangle inside a scatter XamDataChart.

In the sample I have used mostly the XamDataChart’s built-in functionality:

For the axis value referencing we have an exposed method on the Numeric axes called GetScaledValue.
We have used the XamDatachart’s WindowRect property to take into account the any zooming actions.
We have set a Canvas element to the XamDataChart’s PlotAreaBackgroundConent in order to easily position the Rectangle.

All this is configured in a REFRESH method which is called in the SizeChanged event of the Canvas element to reflect any chart resizing, in the XamDataChart’s WindowRectChanged event to reflect zooming and in the Axes’ RangeChanged event to reflect any changes caused by changes in the Series’ DataPoints collections.

Hope you find this useful.

DataChart_Scatter_drawing.zip