This post follows on from the comparisons by Colin, of two Silverlight chart libraries, and Graham, of Flex and Silverlight chart libraries. In this post I add an HTML5 chart library into the mix. The results show that the HTML5 Charts perform easily as well as the others in HTML5 browsers (Chrome, FireFox, Safari, Opera, IE9*).
* Note this is predicted performance in IE9 as the library does not yet support it during its preview phase, there is work being done on this.
There's been some interest in how Flex, HTML5 and Silverlight stack up against each other, and whether there's any stand out reason to choose one technology over the others. To aid in this comparison I've reproduced the example from Colin and Grahams posts using an open-sourced charting library.
The charting library is called Closure Charts, an open source project managed by Scott Logic aimed at producing fast and functional charts without requiring any browser plug-ins. It is built on top of the Closure Library framework and is fully annotated for use with the Closure Compiler. It has support for VML, SVG and canvas based rendering which means that it works on virtually all desktop web-browsers (including IE 6-8) and most smartphone browsers. For more information on the library visit the website on Google Code.
I think at this point it would be helpful to share my personal definition of HTML5 as it's a highly overloaded term in much the same way as web 2.0 was/is-
- New standards CSS3 (brings with it layout concepts, transitions etc...), SVG (persistent mode graphics)
- New tags including Canvas (also Video, Audio but less relevant)
The often quoted problem with HTML5 is the limited availability of the above features. Whilst is is true that support for most features is limited to the current versions of the non-IE browsers and the yet to be released IE 9, putting HTML5 support at approximatly 50% of desktop browsers and 60% of mobile browsers (statcounter.com). It is not true to say that this means we can't start using those features, and in many cases drag the legacy browsers along for the ride. Abstraction libraries make it possible to target many HTML5 features and be confident of them running on legacy browsers. I'd recommend watching this video, for a very passionate and informative talk on this very topic. (thanks Matt!).
Unfortunately in this example we require functionality that is only provided by the canvas element, specifically Context2D.getImageData which allows the retrieval of pixel data from an image. For this reason the below example only works in browsers which support the canvas tag, so no IE 6-8 support. However, I think it's fair to blame the example rather than the technology here, as I'm struggling to think of a genuine need for pixel data extraction in most circumstances.
Here are the examples of the three different technologies -
|HTML5 Chart||Flex Chart||Visiblox Chart|
|[kml_flashembed movie="/archive/2010/11/FlexChartsPerformance.swf" height="380" width="280" /]|
Image credit toClevergrrl
The example is implemented as a Closure Component, an interesting snippet is the mouse move code which is very similar to the Flex example -
I'm able to conclude in much the same way as Graham, from the above examples it is apparent that there is little, if anything, to differentiate their relative performance once loaded. Furthermore, it would be fair to say that the outright technology choice of HTML5, Flex or Silverlight has not differentiated these examples. Rather, the choice of charting library in either technology is far more significant with respect to performance.
However, I think a distinction can be drawn in terms of loading time. The HTML5 example initialising with the rest of the page, whereas both the plug-in based approaches have a noticeable loading lag, both network before they are cached, and plug-in initialisation once cached. Here, the HTML5 version has two clear advantages -
- The example itself weighs in at only ~65kB (including image, transferred size) versus ~225kB for Flash and ~285kB for Silverlight.
- There is no plug-in to initialise, a very big advantage of targeting the "native runtime".
So in conclusion, if loading performance, cuteness or mobile support are crucial to your component/application then HTML5 is a very strong contender.