在chart上加入一条指示线

时间:2021-06-04 11:09:11

原文 http://hi.baidu.com/fuwei_bj/item/7e576410e970683db831801a

<mx:AreaChart width="521" height="146" id="aChart" mouseOut="handleMouseOut(event)" mouseMove="handleMouseMove(event)">

<mx:annotationElements>
            <mx:Canvas id="linesCanvas" horizontalScrollPolicy="off" verticalScrollPolicy="off" />
            </mx:annotationElements>

</mx:AreaChart >

as代码:

private function handleMouseMove(e:MouseEvent):void
    {

linesCanvas.removeAllChildren();
         //creating the line
         var theLine:VRule = VRule(linesCanvas.addChild(new VRule()));
         theLine.styleName="LineOnChart";
         theLine.x = Math.round(hda[0].x)-50;
         theLine.y = 0;
         theLine.height = linesCanvas.height;

}

private function handleMouseOut(e:MouseEvent):void
{
 linesCanvas.removeAllChildren(); 
}