获取实际图表的位置,宽度和高度

时间:2010-05-07 19:34:27

标签: flex charts

我想在我的图表上放置一个容器(透明红色)。

如何获得该区域的原点(点A),宽度和高度?

http://img88.imageshack.us/img88/4558/flexchart01.png http://img88.imageshack.us/img88/4558/flexchart01.png

1 个答案:

答案 0 :(得分:1)

因此,如果您想将此容器放置为背景图像(我意识到这不是您想要做的),您可以在画布的标记中放置100%宽度和高度的画布。我相信有一个类似的属性在图表的顶部,也许你可以用这个做点什么?

编辑:它是您想要的注释元素:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="955" minHeight="600">
    <mx:Script><![CDATA[
        import mx.collections.ArrayCollection;
        [Bindable]
        public var expenses:ArrayCollection = new ArrayCollection([
            {Month:"Jan", Profit:2000, Expenses:1500, Amount:450},
            {Month:"Feb", Profit:1000, Expenses:200, Amount:600},
            {Month:"Mar", Profit:1500, Expenses:500, Amount:300}
        ]);
    ]]></mx:Script>
    <mx:Panel title="Line Chart">
        <mx:LineChart id="myChart" 
                      dataProvider="{expenses}" 
                      showDataTips="true"
                      >
            <mx:horizontalAxis>
                <mx:CategoryAxis 
                    dataProvider="{expenses}" 
                    categoryField="Month"
                    />
            </mx:horizontalAxis>
            <mx:series>
                <mx:LineSeries 
                    yField="Profit" 
                    displayName="Profit"
                    />
                <mx:LineSeries 
                    yField="Expenses" 
                    displayName="Expenses"
                    />
            </mx:series>
            <mx:annotationElements>
                <mx:Canvas backgroundAlpha=".5" backgroundColor="0xff0000" />
            </mx:annotationElements>
        </mx:LineChart>
        <mx:Legend dataProvider="{myChart}"/>
    </mx:Panel>

</mx:Application>