Why I have to leave you, amCharts.

I recently spent a bit of time working with amCharts on an app that already used it. At first I was indifferent to using it, a charting library is a charting library, right? But eventually I was spending so much time trying to get the tool working how I wanted, I wrote up these pionts for bringing in a new tool like Highcharts.

Here are 5 quick reasons:

1. Community Support

Google for “amcharts ruby” or “amchart rails”. Welcome to 2007. I’m not kidding, look at the dates. I’m sure it was a fine tool, but the community has moved on. We could fight this, or we could do a little digging and look for the reasons they moved on. They either found an easier tool, or more comprehensive tool, or both.

Now google for “highcharts ruby” of “highcharts rails”. Enjoy good documentation, examples, tutorials, screencasts, stackoverflow, etc.

2. Quality Examples

Charting libraries are complex by nature. They have to support many generic operations in robust ways. Not only do you need good API documentation, you must have good examples online. This is lacking in amCharts. I found more about loading CSV files than any of my modern ‘Getting Started’ problems. Speaking of “Getting Started”.. I like short, but this is awesome (http://www.amcharts.com/docs/v.2/shortgettingstarted). They do have examples in their download zip but this doesn’t allow people to find, link to or comment on them very easily.

Compare this to Highcharts. All of their examples are online, organized by type, with one click access to the configuration options and links to play with them live in jsFiddle. Huge. Time. Saver. And their Getting Started guide really gets you started.

3. Code vs Config

As far as I can tell in amCharts, I cannot separate a chart’s configuration information from it’s initialization code.

For instance, an example starts setting up a chart like this:

 var chart = new AmCharts.AmSerialChart();
chart.dataProvider = chartData;  
chart.categoryField = "country";  

Instead, would hope to be able to pass in this configuration information in via object notation (json) like this:

 var chart = new AmCharts.AmSerialChart({
 "dataProvider": chartData,
 "categoryField": "country"
});

Why? Because then you can generate your config anywhere you want; ahead of time, on the server, or dynamically fetch it over XmlHttp. This is a bigger deal than you might think. It allows you to organize all your charts in a charts controller. Or it allows you to write a server-side ruby library to generate configs in our native ruby tongue on the fly (LazyHighCharts). Or you can pass a base config into multiple charts, only overriding the options you want to change. In short, you have choices.

But you can’t do that unless can separate the two. Otherwise everything has to be inline. Inline is fine for getting started, but we developers often like to move or encapsulate data. And you can’t with amCharts (at least not without writing your own wrappers). Similarly, building a single amChart requires you to build multiple objects (AmSerialChart, categoryAxis, ValueAxis, AmGraph, ChartCursor) which aren’t re-usuable or easy to pass around like json. Hide this implementation logic from us, amCharts.

In HighCharts (and others, like Flot), you can generate all of the configuration options, including series data points, in json anywhere you want (inline, server-side, ajax), then pass it in like this:

chart = new Highcharts.Chart(options);

Done.

4. Standards, Jason

Speaking of json, I saw several examples where amCharts instructs us to gsub out certain characters because its supports a “modified” type of json. Big. Red. Flag. Json is json, or should be.

5. Multiple series/datasets

It appears that amCharts doesn’t support multiple datasets on a single line chart like I needed. . You have to use their Stock Charting library. Maybe I just missed it, or couldn’t figure it out, but if so that’s a problem too.


There are more reasons and fanciness about Highcharts I could cover, but these 5 counts against amCharts are enough to push me to another tool.

After wrestling with amCharts for several hours, I ripped it out its too-messy-too-messy lines of javascript, dropped in Highcharts, grabbed a handy gem to generate a quick chart in the controller and had charts rendering within a couple minutes. I used all my extra time to write this blog entry :)

Disclaimer: I only spent a few days on amCharts. There are likely ways to accomplish the things I wanted- so if I’m way off, let me know.

Disclaimer #2: price. Highcharts is definitely more expensive. But a) I did spend a few days on this and developer time isn’t cheap. And b) you get what you pay for. :)


comments powered by Disqus
comments powered by Disqus