饼图,条,线:SVG / VML优于Canvas [英] Pie, bar, line: SVG/VML better than Canvas

查看:165
本文介绍了饼图,条,线:SVG / VML优于Canvas的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要为标准图表选择一个库:饼图,线条和酒吧。

I need to choose a library for "standard" charting: pies, lines and bars.

从我看过的,在我看来,格式是SVG / VML,例如Highcharts。 SVG正在成为所有主流浏览器的标准,现在IE 9接受它。看起来比Canvas更容易重新缩放和导出。

From what I've read, it seems to me that the best format is SVG/VML, like Highcharts for example. SVG is becoming standard across all major browsers, now that IE 9 accepts it. It seems easier to rescale and export than Canvas.

仍然,我看到几个图表库依赖于Canvas。我缺少什么?是否有任何理由考虑Canvas over SVG为这样的应用程序?

Still, I see that several charting libraries rely on Canvas. Am I missing something? Is there any reason for considering Canvas over SVG for such applications?

推荐答案

你通常可以获得相同的结果。两者最终为用户绘制像素到屏幕。主要的区别在于HTML5 Canvas给出了对结果(读和写)的像素级控制,而SVG是一个保留模式图形API,这使得它很容易处理事件或操纵

You can generally achieve the same results with either. Both end up drawing pixels to the screen for the user. The major differentiators are that HTML5 Canvas gives you pixel-level control over the results (both reading and writing), while SVG is a retained-mode graphics API that makes it very easy to handle events or manipulate the artwork with JavaScript or SMIL Animation and have all redrawing taken care of for you.

一般来说,如果您:


  • 需要对效果进行像素级控制(例如模糊或混合

  • 具有非常大量的数据点,这些数据点将被呈现一次(也许是平移的),但是是静态的

如果您使用SVG:


  • 希望在屏幕上绘制复杂的对象

  • 希望结果以高分辨率正常打印

  • 需要动画处理

  • 独立

  • 将在输出中包含要由搜索引擎编入索引的文本
  • /或XSLT以产生输出
  • want complex objects drawn on the screen to be associated with events (e.g. move over a data point to see a tooltip)
  • want the result to print well at high resolution
  • need to animate the shapes of various graph parts independently
  • will be including text in your output that you want to be indexed by search engines
  • want to use XML and/or XSLT to produce the output

这篇关于饼图,条,线:SVG / VML优于Canvas的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆