I wrote a small sample for a customer to demonstrate how to write a Charting Datatip Renderer and Axis Label Renderer that displayed HTML links that when clicked on open up other web pages.

I based my renderers on the TextArea component, since that component has a link event that gets fired off if the TextArea htmlText contains an anchor tag that has an href that contains “event:”.

Here is the DataTip Renderer, MyDataTipRenderer.mxml:

< ?xml version="1.0" encoding="utf-8"?>
<mx :TextArea xmlns:mx="http://www.adobe.com/2006/mxml" borderStyle="outset"
    editable="false" selectable="true" link="linkHandler(event)" fontSize="16" >
   
    </mx><mx :Script>
        < ![CDATA[
       
        import flash.events.TextEvent;

        public function linkHandler(event:TextEvent):void {
            // Open the link in a new window.
            navigateToURL(new URLRequest(event.text), ‘_blank’)
        }

        override public function set data(value:Object):void
        {
            super.data=value;
            htmlText="<a href=’event:http://www.google.com/search?hl=en&q=" + data.chartItem.yValue + "+" + data.chartItem.xValue + "&btnG=Google+Search’>" + data.chartItem.yValue + ":" + data.chartItem.xValue + "";
        }
        ]]>
    </mx>

 

Read the rest of this post»



1 Comment »