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"/>
amPie Chart in Flex

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.

Related articles you should check out:

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
If you have a Gravatar account, used to display your avatar.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • You can enable syntax highlighting of source code with the following tags: <code>. Beside the tag style "<foo>" it is also possible to use "[foo]".
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

About

Daniel McLaren

Daniel is a Flash and Flex developer specializing in the art of information visualization.

Latest from SketchyD

Latest Drawing from SketchyD

This is the most recent drawing from my mobile sketch blog, SketchyD.com.

Recent comments