views:

836

answers:

6

I'm developing a new site that graphs some operational metrics. As such about a dozen charts/graphs will be displayed on the site. I want to be able to have them dynamically scale down (within reason) based upon the size of the browser.

I'm debating the pros/cons of generating these as one of these options:

  1. SVG. Great for scaling but support may have limited support,
  2. HTML5. Clearly a great choice for the future and for FF customers, IE?
  3. PNG. This would require that I regenerate the PNG based upon the size of the DIV &c.

Which is the preferable option? I'm leaning towards PNG just for ubiquitous support, but would like to have client-side scaling. What is the best solution given the state of affairs of SVG and HTML5 canvas support in browsers?

+2  A: 

The best option would be SVG or HTML5 that will fall back on PNG if the others aren't available.

Greg
An option is to generate PNG/JPGs from the SVG files serverside for the clients that don't support SVG.
Erik Dahlström
If the <object> tag is used however, then one could default a PNG request inside should the SVG not be requested...might be best.
Xepoch
A: 

ExplorerCanvas brings <canvas> support to IE. So, it would be an amalgamation of 1 & 2. The benefit would be that (a) as more browsers add support for <canvas>, you would automatically get the benefits of already supporting it and (b) you would get scaling with browser size.

Ates Goral
+3  A: 

Now you can use SVG anywhere

Javier
Secured environment. No flash option.
Xepoch
+2  A: 

SVG is supported by all modern browsers. Canvas is supported by all modern browser. Internet Explorer supports neither. A partial API for SVG, with fallback mechanism for IE exists in Raphaël (raphaeljs.com) A partial Canvas-implementation for IE exists in ExCanvas

I'd say say its not a question of "Canvas or SVG", but what high-level library exists that best covers your needs.

Audun
Well, I'll be employing gnuplot which can produce any of the above for the most part with a flick of the output terminal switch. I should mention that this needs to be without client plug-in, I'll need to read more as to this ExCanvas.
Xepoch
+4  A: 

You could do worse than explore a new charting library: http://g.raphaeljs.com/

You won't believe it at first.

Chasbeen
+1  A: 

I prefer SVG over HTML5 canvas or PNG for charts. Canvas and PNG zoom as bitmaps in Firefox. (Canvas provides a vector API, but it's a drawable bitmaps surface--not a vector store.) SVG zooms as vector graphics in Firefox.

I ofter run with the view zoomed, so I appreciate real vector zooming.

(Canvas makes sense for games that can't handle the perf hit of retained mode graphics.)

hsivonen
I may need to start another question, but how would SVG dynamically scale in say a resized DIV?
Xepoch
In browsers that don't have full-page zoom and have only text zoom, you need to wrap the SVG element in an em-sized div and make the SVG box size to 100% of the containing div. My concern above was having vector zooming of the chart with the full-page zoom in Firefox >= 3.5, and to make that work, the em/div trick isn't necessary.
hsivonen