amCharts in Flex?
A client wanted to use amCharts in a Flex application. From my understanding the reasoning was mostly aesthetics. This, of course presented the problem of getting these charts into Flex when they were designed to be embedded in HTML pages. Another hurdle is that amCharts are all written in ActionScript 2.0 and Flex runs using AS3.
It turns out getting AS2 content into Flex isn't so hard after all. There's a SWFLoader class which makes quick work of the problem. I got the am pie chart in Flex before it had a chance to protest. The MXML code is below:
<mx:SWFLoader id="swfLoader" source="@Embed(source='ampie.swf')" scaleContent="false" height="800" width="600"/>

The am Pie Chart embedded in a Flex application with the familiar grey gradient background.
There's even a nice article about AS2-AS3 communication by Peter Ent. For amCharts, however, this wasn't even necessary. The chart loads the configuration and data files normally as long as all the paths are correct.
The problem for us was that the charts don't resize well—or at all. I checked with a pie chart embedded in an HTML page with width and height set to 100% and it turns out the charts don't even do resize handling in that case. So it definitely wasn't going to happen embedded in a Flex app.
So it looks like we'll be using Flex Charting instead, and looking at those slick controls, I'm not the least bit sad about it.
Delicious
Digg
Reddit
Facebook
Google
Yahoo
Technorati

Comments
Post new comment