JavaScript 中的图形可视化库
我有一个表示有向图的数据结构,我想在 HTML 页面上动态呈现它。 这些图表通常只是几个节点,最高端可能有十个,所以我的猜测是性能不会是一个大问题。 理想情况下,我希望能够将其与 jQuery 挂钩,以便用户可以通过拖动节点来手动调整布局。
注意:我不是在寻找图表库。
I have a data structure that represents a directed graph, and I want to render that dynamically on an HTML page. These graphs will usually be just a few nodes, maybe ten at the very upper end, so my guess is that performance isn't going to be a big deal. Ideally, I'd like to be able to hook it in with jQuery so that users can tweak the layout manually by dragging the nodes around.
Note: I'm not looking for a charting library.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
在商业场景中,一个严肃的竞争者肯定是 yFiles for HTML:
它提供:
下面是一个示例渲染,显示了大多数请求的功能:
全面披露:我为 yWorks 工作,但在 Stackoverflow 上我不代表我的雇主。
In a commercial scenario, a serious contestant for sure is yFiles for HTML:
It offers:
Here is a sample rendering that shows most of the requested features:
Full disclosure: I work for yWorks, but on Stackoverflow I do not represent my employer.
正如 guruz 提到的,JIT 有几个可爱的图形/树布局,包括非常吸引人的 RGraph 和 HyperTree 可视化。
另外,我刚刚在 github 上发布了一个超级简单的基于 SVG 的实现(没有依赖项,~ 125 LOC)对于现代浏览器中显示的小图形来说应该足够好了。
As guruz mentioned, the JIT has several lovely graph/tree layouts, including quite appealing RGraph and HyperTree visualizations.
Also, I've just put up a super simple SVG-based implementation at github (no dependencies, ~125 LOC) that should work well enough for small graphs displayed in modern browsers.
免责声明:我是 Cytoscape.js 的开发人员
Cytoscape.js 是一个 HTML5 图形可视化库。 该 API 非常复杂,遵循 jQuery 约定,包括
cy.elements("node[weight >= 50].someClass")
的作用正如您所期望的那样)、如果您正在考虑构建一个带有图形的严肃的 Web 应用程序,您至少应该考虑 Cytoscape.js。 它是免费且开源的:
http://js.cytoscape.org
Disclaimer: I'm a developer of Cytoscape.js
Cytoscape.js is a HTML5 graph visualisation library. The API is sophisticated and follows jQuery conventions, including
cy.elements("node[weight >= 50].someClass")
does much as you would expect),cy.nodes().unselect().trigger("mycustomevent")
),If you're thinking about building a serious webapp with graphs, you should at least consider Cytoscape.js. It's free and open-source:
http://js.cytoscape.org
我刚刚整理了您可能需要的内容: http://www.graphdracula.net
它是 JavaScript通过定向图形布局、SVG,您甚至可以拖动节点。 仍然需要一些调整,但完全可用。 您可以使用这样的 JavaScript 代码轻松创建节点和边:
我使用了前面提到的 Raphael JS 库(graffle 示例)以及我在网上找到的基于力的图形布局算法的一些代码(一切都是开源的,MIT 许可证)。 如果您有任何意见或需要某个功能,我可以实现它,尽管问!
您可能还想看看其他项目! 以下是两个元比较:
SocialCompare 有广泛的库列表,“节点/边缘图”行将过滤图形可视化库。
DataVisualization.ch 评估了许多库,包括节点/图库。 不幸的是,没有直接链接,因此您必须过滤“graph”:
以下是类似项目的列表(其中一些项目已在此处提及):
纯 JavaScript 库
vis.js 支持多种类型的网络/边缘图,以及时间线和 2D/3D 图表。 自动布局、自动聚类、弹性物理引擎、移动设备友好、键盘导航、分层布局、动画等。 MIT 由一家专门研究自组织网络的荷兰公司授权和开发。
Cytoscape.js - 具有移动支持的交互式图形分析和可视化,遵循 jQuery 约定。 由 NIH 拨款资助,由 @maxkfranz 开发(请参阅 他的答案如下)在几所大学和其他组织的帮助下。
JavaScript InfoVis 工具包 - Jit,一个交互式、多用途图形绘制和布局框架。 例如,请参阅 双曲树 。 由 Twitter dataviz 架构师 Nicolas Garcia Belmonte 和 2010 年由 Sencha 购买。
D3.js 强大的多用途JS可视化库,Protovis的继承者。 请参阅 力导向图 示例,以及 画廊。
Plotly 的 JS 可视化库使用 D3.js 与 JS、Python、R 和 MATLAB 绑定。 请参阅 IPython 中的 nexworkx 示例此处,人机交互示例此处,以及 JS 嵌入 API。
sigma.js 轻量级但功能强大的图形绘制库
jsPlumb 用于创建交互式连接图的 jQuery 插件
Springy - 一种力导向的图形布局算法
JS Graph It - 通过直线连接的拖放框。 线条的最小自动布局。
RaphaelJS 的 Graffle - 通用多用途矢量绘图库的交互式图形示例。 RaphaelJS 无法自动布局节点; 为此,您需要另一个库。
JointJS Core - David Durman 的 MPL 许可的开源图表库。 它可用于创建静态图表或完全交互式的图表工具和应用程序构建器。 适用于支持 SVG 的浏览器。 布局算法未包含在核心包中
mxGraph 以前的商业 HTML 5 图表库,现已可用在 Apache v2.0 下。 mxGraph 是 draw.io 中使用的基础库。
商业库
GoJS交互式图形绘制和布局库
yFiles for HTML 商业图形绘制和布局库
KeyLines商业JS网络可视化工具包
ZoomCharts 商业多用途可视化库
Syncfusion JavaScript 图 用于绘图和可视化的商业图表库。
废弃的库
Cytoscape Web 可嵌入 JS 网络查看器(没有计划新功能;由 Cytoscape.js 继承)
Canviz JS 渲染器,用于 Graphviz 图表。 已于 2013 年 9 月废弃。
arbor.js 复杂的图形,具有良好的物理效果和养眼效果。 于 2012 年 5 月被废弃。存在多个半维护分叉。
jssvggraph “作为使用 SVG 对象的 Javascript 库实现的最简单的力定向图形布局算法”。 2012年被废弃。
jsdot 客户端图形绘制应用程序。 于 2011 年废弃。
Protovis 用于可视化的图形工具包 (JavaScript)。 已替换为 d3。
Moo Wheel 用于连接和关系的交互式 JS 表示(2008)
JSViz 2007 时代的图形可视化脚本
dagre JavaScript 图形布局
非 Javascript 库
Graphviz 复杂的图形可视化语言
Flare 美丽而强大的基于 Flash 的图形绘制
NodeBox Python 图形可视化
Processing.js John Resig 的处理库的 Javascript 端口
I've just put together what you may be looking for: http://www.graphdracula.net
It's JavaScript with directed graph layouting, SVG and you can even drag the nodes around. Still needs some tweaking, but is totally usable. You create nodes and edges easily with JavaScript code like this:
I used the previously mentioned Raphael JS library (the graffle example) plus some code for a force based graph layout algorithm I found on the net (everything open source, MIT license). If you have any remarks or need a certain feature, I may implement it, just ask!
You may want to have a look at other projects, too! Below are two meta-comparisons:
SocialCompare has an extensive list of libraries, and the "Node / edge graph" line will filter for graph visualization ones.
DataVisualization.ch has evaluated many libraries, including node/graph ones. Unfortunately there's no direct link so you'll have to filter for "graph":
Here's a list of similar projects (some have been already mentioned here):
Pure JavaScript Libraries
vis.js supports many types of network/edge graphs, plus timelines and 2D/3D charts. Auto-layout, auto-clustering, springy physics engine, mobile-friendly, keyboard navigation, hierarchical layout, animation etc. MIT licensed and developed by a Dutch firm specializing in research on self-organizing networks.
Cytoscape.js - interactive graph analysis and visualization with mobile support, following jQuery conventions. Funded via NIH grants and developed by by @maxkfranz (see his answer below) with help from several universities and other organizations.
The JavaScript InfoVis Toolkit - Jit, an interactive, multi-purpose graph drawing and layout framework. See for example the Hyperbolic Tree. Built by Twitter dataviz architect Nicolas Garcia Belmonte and bought by Sencha in 2010.
D3.js Powerful multi-purpose JS visualization library, the successor of Protovis. See the force-directed graph example, and other graph examples in the gallery.
Plotly's JS visualization library uses D3.js with JS, Python, R, and MATLAB bindings. See a nexworkx example in IPython here, human interaction example here, and JS Embed API.
sigma.js Lightweight but powerful library for drawing graphs
jsPlumb jQuery plug-in for creating interactive connected graphs
Springy - a force-directed graph layout algorithm
JS Graph It - drag'n'drop boxes connected by straight lines. Minimal auto-layout of the lines.
RaphaelJS's Graffle - interactive graph example of a generic multi-purpose vector drawing library. RaphaelJS can't layout nodes automatically; you'll need another library for that.
JointJS Core - David Durman's MPL-licensed open source diagramming library. It can be used to create either static diagrams or fully interactive diagramming tools and application builders. Works in browsers supporting SVG. Layout algorithms not-included in the core package
mxGraph Previously commercial HTML 5 diagramming library, now available under Apache v2.0. mxGraph is the base library used in draw.io.
Commercial libraries
GoJS Interactive graph drawing and layout library
yFiles for HTML Commercial graph drawing and layout library
KeyLines Commercial JS network visualization toolkit
ZoomCharts Commercial multi-purpose visualization library
Syncfusion JavaScript Diagram Commercial diagram library for drawing and visualization.
Abandoned libraries
Cytoscape Web Embeddable JS Network viewer (no new features planned; succeeded by Cytoscape.js)
Canviz JS renderer for Graphviz graphs. Abandoned in Sep 2013.
arbor.js Sophisticated graphing with nice physics and eye-candy. Abandoned in May 2012. Several semi-maintained forks exist.
jssvggraph "The simplest possible force directed graph layout algorithm implemented as a Javascript library that uses SVG objects". Abandoned in 2012.
jsdot Client side graph drawing application. Abandoned in 2011.
Protovis Graphical Toolkit for Visualization (JavaScript). Replaced by d3.
Moo Wheel Interactive JS representation for connections and relations (2008)
JSViz 2007-era graph visualization script
dagre Graph layout for JavaScript
Non-Javascript Libraries
Graphviz Sophisticated graph visualization language
Flare Beautiful and powerful Flash based graph drawing
NodeBox Python Graph Visualization
Processing.js Javascript port of the Processing library by John Resig