March 16th, 2007 by Kyle
Tags: charting, components, datatip-renderer, Flex, flex-charting, label-renderer, mxml, renderer
Posted in: Flex
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:
<mx:TextArea xmlns:mx="http://www.adobe.com/2006/mxml" borderStyle="outset"
editable="false" selectable="true" link="linkHandler(event)" fontSize="16" >
<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 + "</a>";
}
]]>
</mx:Script>
</mx:TextArea>
1 Comment »

Recent Comments