English 中文(简体)
Which would you prefer? SVG, HTML5 or regen d-PNG for graphs & charts? [closed]
原标题:

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 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?

最佳回答

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

You won t believe it at first.

问题回答

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.)

Now you can use SVG anywhere

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.

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

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.

You can use SVG with a png fallback just using CSS as it is described in this answer: https://stackoverflow.com/a/13575068/418711





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签