在很多项目中都会有在前端展现数据图表的需求,而在开发过程中,开发者往往会使用一些JavaScript库,从而更有效地达到想要的目标。最近,TechSlide上的一篇文章总结了50种用于展现图表的JavaScript库,并对每种库做了简要的说明。这对于想要选择合适JavaScript库的开发者很有参考意义。
文章作者首推的库是D3,他说到:
它非常让人惊叹,我很喜欢它的简洁性。它的文档非常完备,源代码托管在GitHub上,而且不断会添加新的示例。有一种叫做Tributary的创建D3原型的工具,其中有很多非常棒的示例。这个库非常好,以至于xcharts、nvd3、Rickshaw、Cubism.js、dc.js、xkcd都是基于它构建的。如果你想要做出优秀的自定义数据可视化效果,那么D3可能是你最佳选择,或者对于更简单的图,你可以选择上面所提到的基于D3的库。最后,我强烈推荐阅读Scott Murray关于D3的免费书《Interactive Data Visualization for the Web》和《Dashing D3 tutorials》。
接下来,他列举并简要说明了其它用于展现数据、制作表格和图表的JavaScript库,列在前20位的如下:
- HighCharts——它非常强大,你可以在JSFiddle中查看和编辑大量示例。它不免费,但拥有很多客户(IBM、NASA、MasterCard等)。它还向下兼容IE 8。
- jqPlot——如果你已经在使用jQuery,不想为HighCharts付费,而且情况很简单,不需要D3那样复杂的库,那么jqPlot是很好的选择。
- dygraphs——一种开源的JavaScript库,可以做出可交互、可缩放的时间线图表。对于大数据集合非常适用。
- Protovis——和D3出自同一支团队之手,是一种免费的开源库。你可以查看这个stackoveflow 页面来了解D3与其的区别。
- Flot Charts——与jqPlot一样,Flot是一种针对jQuery的纯JavaScript库,专注于简单的用法、引人注目的外观和交互特性。
- Google Chart Tools——强大、免费、易于使用。内容丰富,从最简单的线状图到负责的层级树状图都有,在展示页面中提供了大量设计良好的图表类型。
- dc.js——基于D3的JavaScript图表库,拥有本地跨过滤器(crossfilter)的支持,并让你可以高效率地浏览大型多维数据集。
- xcharts——基于D3用于构建自定义图表的库。
- nvd3——让你可以构建可重用的图表和图表组件,同时具有d3.js的强大功能。
- rickshaw——用于创建可交互时间线图表的JavaScript工具。
- Cubism.js——用于可视化时间线的D3插件。使用了Cubism构建更好的实时仪表盘,可以从Graphite、Cube和其他源拉取数据。
- xkcd——让你可以使用D3在JavaScript中做出XKCD样式的图表。
- jQuery Sparklines——一种jQuery插件,可以直接在浏览器中创建小型的内嵌图表。
- peity——一种简单的jQuery插件,可以把元素的内容转换成简单的饼图、线图和柱状图。
- BonsaiJS——一种轻量级的图形库,拥有直观的图形API和SVG渲染器。
- Flotr——为Prototype.js所用的JavaScript图表库。它拥有很多特性,像对负数值的支持、鼠标跟踪、选定支持、缩放支持、事件挂钩、CSS样式支持、在画布(canvas)中包含文字、旋转的标签、渐变颜色、图形标题和子标题、电子表格、CSV数据下载等等。
- ProtoChart——物如其名,ProtoChart让你可以使用JavaScript和Prototype创建很漂亮的图表。它是一种开源库。
- Flotr2——HumbleSoftware当前正在做的项目,让你可以使用Canvas和JavaScript创建图表。
- jQuery-Visualize——HTML的table元素驱动的HTML5 canvas图表。也是针对jQuery的图表插件。
- JS Charts——基于JavaScript的图表生成器,只需要很少甚至不需要编码。免费版会有水印,可以通过付费去掉。
- ……
文章中还列举的JavaScript库有:PlotKit、MilkChart、moochart、moowheel、table2chart、Canvas 3D Graph、TufteGraph、ArborJS、TimePlot、gRaphael、ICO、Elycharts、ZingChart、RGraph、Dojo Charting、Bluff、canvasXpress、ccchart、JIT、JSXGraph、Smoothie Charts、YUI Charts、amcharts、Emprise JavaScript Charts、FusionCharts、JavaScript Diagram Builder、jGraph、Sencha Touch Charts、Style Chart、AwesomeChartJS等,都各有千秋,如果你对这些库感兴趣的话,可以访问相应的链接或者阅读原文。
这个列表对于想要利用JavaScript技术创建图表展现数据的开发者来说,非常具有参考意义,你可以从中选择最适合的库,从而高效、高质量地完成任务。
50 JAVASCRIPT LIBRARIES FOR CHARTS AND GRAPHS
How are you visualizing data in JavaScript? What is your favorite library for creating charts and graphs with JavaScript?
I have been a long time fan of jqPlot for its open source approach, simplicity, examples, and great features. It performs well, it is used by many corporations, and it is built on top of jQuery. Recently, however, D3 has really caught my eye. It uses JavaScript, HTML, SVG and CSS to really bring data to life. It is also open sourced, does not depend on jQuery, has a ton of examples, and there are even some good charting libraries based on D3. The other big player isHighCharts, also written in pure JavaScript with all demos that you can view and edit in JSFiddleand it also has some powerful features. Beyond these three, there are many more useful JavaScript charting libraries worth considering. Here is a list of the top 50 JS libraries for making charts and graphs:
D3 – is really amazing and I love it’s simplicity. The documentation is really extensive, the source code is hosted on GitHub, and the examples are never-ending. There is a D3 prototyping tool called Tributary with many great examples. It’s so good that xcharts, nvd3, Rickshaw, Cubism.js, dc.js, and xkcd are all based on D3. If you are making some amazing custom data visualizations, D3 should probably be your choice, otherwise these d3-based libraries mentioned above are great for more simple straightforward graphs. Finally, I highly recommend looking at Scott Murray free book on D3 called Interactive Data Visualization for the Web and Dashing D3 tutorials.
HighCharts – very powerful, I love the JSFiddle examples and powerful features. I don’t like the license fee but they have great customers (IBM, NASA, MasterCard, etc). They also have backward compatibility with IE8.
jqPlot – if you are already using jQuery, you don’t want to pay for HighCharts, and D3 is too much for your simple use cases, then jqPlot is an excellent choice.
dygraphs – open source JavaScript library that produces interactive, zoomable charts of time series. It is really excellent for large data sets.
Protovis – free and open-source created by the same team that is now working on D3. If you are interested in comparing D3 to Protovis, check out this stackoveflow page.
Flot Charts – similar to jqPlot, Flot is a pure JavaScript plotting library for jQuery, with a focus on simple usage, attractive looks and interactive features. If you are interested in comparing Flot to jqPlot, this thread has some good information.
Google Chart Tools – powerful, free, simple to use, and it has everything from simple line charts to complex hierarchical tree maps, the chart galley provides a large number of well-designed chart types.
dc.js – a javascript charting library based on D3 with native crossfilter support and allowing highly efficient exploration on large multi-dimensional dataset.
xcharts – a D3-based library for building custom charts and graphs.
nvd3 – allows you to build re-usable charts and chart components without taking away the power that d3.js gives you.
rickshaw – JavaScript toolkit for creating interactive time series graphs.
Cubism.js – a D3 plugin for visualizing time series. Use Cubism to construct better realtime dashboards, pulling data from Graphite, Cube and other sources.
xkcd – allows you to make XKCD-style plots in Javascript using D3. Check out xkcdgraphs to make your own xkcd graphs.
jQuery Sparklines – a jQuery plugin that creates small inline charts directly in the browser.
peity – a simple jQuery plugin that converts an element’s content into a simple CANVAS mini pie, line or bar chart.
BonsaiJS – lightweight graphics library with an intuitive graphics API and an SVG renderer.
Flotr – a Javascript plotting library for Prototype.js. It comes with great features like legend support, negative value support, mouse tracking, selection support, zoom support, event hooks, css styling support, text included into the canvas, rotated labels, color gradients, graph title and subtitle, spreadsheet, CSV data download and much more.
ProtoChart – As the name suggests, ProtoChart allows you to create beautiful charts using Javascript and Prototype. It is open sourced, uses Canvas, and was highly motivated by Flot, Flotr and PlotKit libraries.
Flotr2 – a recent project by HumbleSoftware that lets you make graphs and charts with Canvas and JavaScript. HumbleSoftware also came out with envisionjs which uses flotr2 and allows you to make dynamic HTML5 visualizations.
jQuery-Visualize – HTML5 canvas charts driven by HTML table elements. Another charting plugin for jQuery.
JS Charts – a JavaScript based chart generator that requires little or no coding. The free version has a watermark which can be removed by paying for a license.
PlotKit – a chart and graph plotting Library for Javascript. It has support for HTML Canvas and also SVG via Adobe SVG Viewer and native browser support. PlotKit is a complete rewrite ofCanvasGraph.
MilkChart – a compact JavaScript framework for creating graphs based on MooTools. It is simple and easy to understand.
moochart – is another plugin for MooTools and it focuses on drawing bubble diagrams on the canvas tag.
moowheel – a JavaScript connections visualization library based on MooTools.
table2chart – a MooTools plugin that generates charts from accessible data tables.
Canvas 3D Graph – a special type of bar graph that plot numbers in 3D.
TufteGraph – another JavaScript charting library based on jQuery. It has a really compact API and non-core layout is done via CSS.
ArborJS – a graph visualization library using web workers and jQuery.
TimePlot – focused entirely on graphing time-series data, with support for annotating the graph with temporal events.
gRaphael – create stunning charts on your website, based on Raphael graphics library.
ICO – another JavaScript graph library based on Raphael.
Elycharts – a pure javascript charting library, easy to use and completely customizable. It is based on jQuery and Raphaël libraries.
ZingChart – allows you to build advanced charts and visualizations in HTML5, SVG, VML and Flash.
RGraph – produces interactive charts using the HTML5 canvas tag.
Dojo Charting – if you are already using Dojo, then Dojo’s charting library is a great solution for making charts and graphs.
Bluff – Bluff is a JavaScript port of the Gruff graphing library for Ruby. It is designed to support all the features of Gruff with minimal dependencies.
canvasXpress – a javascript library based on the Canvas tag implemented in HTML5.
ccchart – a Simple JavaScript chart that does not depend on libraries such as jQuery.
JIT – JavaScript InfoVis Toolkit provides tools for creating Interactive Data Visualizations for the Web.
JSXGraph – a cross-browser library for interactive geometry, function plotting, charting, and data visualization in a web browser.
Smoothie Charts – a JavaScript Charting Library for Streaming Data.
YUI Charts – YUI module that provides a JavaScript API for visualizing data in a variety of formats leveraging SVG, HTML Canvas and VML to render its graphical elements.
amcharts – JavaScript/HTML5 charts including serial (column, bar, line, area, step line, smoothed line, candlestick and ohlc graphs), pie/donut, radar/polar and xy/scatter/bubble charts.
Emprise JavaScript Charts – pure JavaScript charts with great features and good cross browser support.
FusionCharts – delightful data visualization for your needs, a chart web service powering more than a billion charts per month.
JavaScript Diagram Builder – a library of some objects and functions, which can help you to display a chart or graph in an easy way.
jGraph – HTML5 diagramming component with full IE 6-8 and touch device support.
Sencha Touch Charts – it uses HTML5 Canvas and CSS3 to deliver charts to the mobile web browsers.
Style Chart – a free Ajax Visualization Charting Service
If you are looking for more libraries and web services that deal with visualizing data, I recommend checking out Datavisualization.ch.
Have I missed any good JavaScript charting libraries?
Update:
AwesomeChartJS – great looking charts with JavaScript and the canvas element
Sigma.js – an open-source lightweight JavaScript library to make network visualizations using the HTML canvas element.