I am developing a WPF application that has a stacked column chart (I'm using the Silverlight Toolkit charting features). I need to dynamically overlay a semi-transparent rectangle over a section of the chart - the size and location of the rectangle needs to adapt to the number of data points on the X axis. The X-axis values represent days, the number of which may vary, but the rectangle always needs to cover 30 days.
In any case, I've figured out most of it, but I need to find out how much width the Y-axis label section of the chart is taking up so that I can take it into account in my rectangle size and location calculations.
There is an "Actual Width" property for the chart available, but I don't know how to get the actual width for just the Y-axis label area. Does anyone know how to find this?
I was able to address this issue by waiting until the chart was loaded and then using the techniques described here http://www.scottlogic.co.uk/blog/colin/2009/03/adding-a-location-crosshair-to-silverlight-charts-again/.
The key thing here is to do the processing when the Loaded event is received:
MyChart.Loaded += (sender, e) =>
{
// MyChart is about to be rendered
// it's now safe to access the ActualWidth properties of the chart components
MyRectangle.Left = MyChart.ActualWidth/2;
}