d3.js和chart.js之间的比较(仅适用于图表) [英] Comparison between d3.js and chart.js (only for charts)

查看:747
本文介绍了d3.js和chart.js之间的比较(仅适用于图表)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的项目中使用了chart.js多次,但我从来没有使用过d3.js。很多人说d3.js是最好的javascript框架,但没有人能够解释为什么,特别是当我想要与chart.js比较。



我发现这一点: http://www.fusioncharts.com/javascript-charting-comparison/
,但它不是我正在寻找的。

有没有人知道这些框架的可用性和性能(仅用于图表)的比较?

解决方案

d3.js 库。它是一个用于创建和操作SVG / HTML的库。它提供了工具来帮助您可视化和操作您的数据。虽然你可以使用它来创建传统的图表(酒吧,线,饼等),它有能力这么多。当然,这种能够这么多带来了更陡峭的学习曲线。在 d3.js - nvd3.js 之上构建了很多传统的图表库c> dimple.js , dc.js



我不熟悉 Chart.js ,但快速浏览网站告诉我,它更多是一个运行的磨坊图表库。它支持6种基本图表类型,并且您不会东西 like this



除此之外,两者之间最明显的区别是 code> Chart.js 是基于画布的,而 d3.js 主要是关于SVG。 (现在我主要说 ,因为SVG可以处理所有类型的HTML元素,所以甚至可以使用它,以帮助你在画布上绘制。)一般来说,画布会为大量的元素执行SVG(我说的很大 - 数千个点,线等等)。另一方面,SVG更容易操作和交互。使用SVG,每个点,线等都成为DOM的一部分 - 你希望那个点现在绿色,只是改变它。使用canvas是一个静态绘图,要重绘以进行任何更改 - 当然,它画得如此之快,你通常不会注意到。这是来自Microsoft的一些好看的


I have used chart.js in my projects several times but I have never used d3.js. A lot of people say that d3.js is the best javascript framework for charts but none of them is able to explain why, especially when I want a comparison to chart.js.

I have found this: http://www.fusioncharts.com/javascript-charting-comparison/ but it is not what I was looking for.

Does anyone know about a comparison of these frameworks in terms of usability and performance (only for charts)?

解决方案

d3.js is not a "charting" library. It is a library for creating and manipulating SVG/HTML. It provides tools to help you visualize and manipulate your data. While you can use it to create conventional charts (bar, line, pie, etc...) it's capable of so much more. Of course with this "capable of so much" comes a steeper learning curve. There are a lot of conventional charting libraries built on top of d3.js - nvd3.js, dimple.js, dc.js if you want to go that route.

I'm not familiar with Chart.js but a quick look at the website tells me it's more of a run of the mill charting library. It supports 6 basic chart types and you aren't ever going to do stuff like this with it. But the API looks straightforward and I'm sure it's easy to use.

Other than that the most obvious distinction between the two is that Chart.js is canvas based, while d3.js is mainly about SVG. (Now I say mainly because SVG can manipulate all types of HTML elements so you could even use it to help you draw on a canvas.) In general canvas will out perform SVG for a large number of elements (I'm talking very large - thousands of points, lines, etc...). SVG, on the other hand, is easier to manipulate and interact with. With SVG each point, line, etc becomes part of the DOM - you want that point green now, just change it. With canvas its a static drawing that was to be redrawn to make any change - of course it draws so fast you'll usually never notice. Here's some good reading from Microsoft.

这篇关于d3.js和chart.js之间的比较(仅适用于图表)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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