我正在开发一个具有堆叠柱形图的 WPF 应用程序(我正在使用 Silverlight Toolkit 图表功能)。我需要在图表的一部分上动态覆盖一个半透明矩形 - 矩形的大小和位置需要适应 X 轴上数据点的数量。 X 轴值代表天数,天数可能会有所不同,但矩形始终需要覆盖 30 天。
无论如何,我已经弄清楚了大部分内容,但我需要找出图表的 Y 轴标签部分占用了多少宽度,以便我可以在矩形大小和位置计算中考虑到它。
图表有一个“实际宽度”属性,但我不知道如何获取 Y 轴标签区域的实际宽度。有谁知道如何找到这个?
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)
我能够通过等待图表加载然后使用此处描述的技术来解决这个问题 http://www.scottlogic.co.uk/blog/colin/2009/03/adding-a-location-crosshair-to-silverlight-charts-again/。
这里关键是在收到Loaded事件时做处理:
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: