0
votes

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?

1
You specify your axis in xaml or use autogenerated? For autogenerated axes I would create derived class of the Chart class.vortexwolf
I am using the autogenerated axes. I'm not crazy about the idea of going to the trouble of deriving from the Chart class and trying to figure out how to find the width of the y-axis section -- maybe it's not too bad. Do you know of any examples where the Chart class has been derived from? Thanks for your help.PIntag

1 Answers

1
votes

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;
}