开发者

Possible to have Flex dataTips on Canvas rather than Chart objects?

Flex charts, like AreaChart, have wonderful built-in support for displaying data "tool tips" when a user hovers over a point supplied in the data of a graph. You can hover over any of the bar graph examples on this page for a demonstration.

I have a graph situation where I optionally draw in some dots as reference points on CartesianDataCanvases supplied to my AreaChart through it's <mx:annotationElements> and <mx:backgroundElements> tags. I would like to have the same hover data-tip functionality tha开发者_Python百科t the AreaChart has, but applied to these dots. Does anyone know how to accomplish this, or if it is even possible?

I realize that I am just drawing on canvas, and that no actual dataProvider supports these dots, but if there was a way to supply the CartesianDataCanvas with an array of data values or something to that effect, that would be great!


Having seen your other post, I assume you are drawing dots using cdc.graphics. In that case, it is not easy to add hover text to them. Create a class that extends UIComponent, override the updateDisplayList method and do the drawing inside that. Now you can easily add mouse over text using the dot.toolTip property.

//Dot.as
package 
{
  public class Dot 
  {
    override protected function updateDisplayList(unscaledWidth:Number, 
        unscaledHeight:Number):void 
    {
      this.graphics.lineStyle(1);
      this.graphics.drawCircle(0, 0, 5);
    }
}

//... later:
var dot:Dot = new Dot();
dot.x = xValue;
dot.y = yValue;
dot.toolTip = "Hover Text";
cdc.addChild(dot);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜