vis.js is a dynamic, browser-based visualization library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

190 lines
5.8 KiB

11 years ago
11 years ago
11 years ago
11 years ago
  1. vis.js
  2. ==================
  3. Vis.js is a dynamic, browser based visualization library.
  4. The library is designed to be easy to use, handle large amounts
  5. of dynamic data, and enable manipulation of the data.
  6. The library consists of the following components:
  7. - DataSet and DataView. A flexible key/value based data set. Add, update, and
  8. remove items. Subscribe on changes in the data set. A DataSet can filter and
  9. order items, and convert fields of items.
  10. - DataView. A filtered and/or formatted view on a DataSet.
  11. - Graph2d. Plot data on a timeline with lines or barcharts.
  12. - Graph3d. Display data in a three dimensional graph.
  13. - Network. Display a network (force directed graph) with nodes and edges.
  14. - Timeline. Display different types of data on a timeline.
  15. The vis.js library is developed by [Almende B.V](http://almende.com).
  16. ## Install
  17. Install via npm:
  18. npm install vis
  19. Install via bower:
  20. bower install vis
  21. Or download the library from the github project:
  22. [https://github.com/almende/vis.git](https://github.com/almende/vis.git).
  23. ## Load
  24. To use a component, include the javascript and css files of vis in your web page:
  25. ```html
  26. <!DOCTYPE HTML>
  27. <html>
  28. <head>
  29. <script src="components/vis/dist/vis.js"></script>
  30. <link href="components/vis/dist/vis.css" rel="stylesheet" type="text/css" />
  31. </head>
  32. <body>
  33. <script type="text/javascript">
  34. // ... load a visualization
  35. </script>
  36. </body>
  37. </html>
  38. ```
  39. or load vis.js using require.js. Note that vis.css must be loaded too.
  40. ```js
  41. require.config({
  42. paths: {
  43. vis: 'path/to/vis',
  44. }
  45. });
  46. require(['vis'], function (math) {
  47. // ... load a visualization
  48. });
  49. ```
  50. A timeline can be instantiated as:
  51. ```js
  52. var timeline = new vis.Timeline(container, data, options);
  53. ```
  54. Where `container` is an HTML element, `data` is an Array with data or a DataSet,
  55. and `options` is an optional object with configuration options for the
  56. component.
  57. ### Bundles
  58. The folder `dist` contains bundled versions of vis.js for direct use in the browser. In general, to use vis, load the files `vis.js` and `vis.css`.
  59. vis.js offers various bundled files: default or light version, and minified or non-minified. The source code of vis.js consists of commonjs modules, which makes it possible to create custom bundles using tools like [Browserify](http://browserify.org/) or [Webpack](http://webpack.github.io/). This can be bundling just one visualization like the Timeline, or bundling vis.js as part of your own browserified web application. Note that hammer.js v1.0.6 or newer is required.
  60. Bundle | Files | Description
  61. ------ | ----- | -----------
  62. default | vis.js, vis.css | The default bundle, fully standalone. Code is not minified, use this version for development.
  63. default minified | vis.min.js, vis.min.css | The default bundle, fully standalone. Code is minified, use this version for production.
  64. light | vis-light.js, vis.css | The light bundle. External libraries [moment.js](http://momentjs.com/) and [hammer.js](http://hammerjs.github.io/) are excluded and need to be loaded before loading vis. Code is not minified, use this version for development.
  65. light minified | vis-light.min.js, vis.min.css | The light bundle. External libraries [moment.js](http://momentjs.com/) and [hammer.js](http://hammerjs.github.io/) are excluded and need to be loaded before loading vis. Codee is minified, use this version for production.
  66. ## Example
  67. A basic example on loading a Timeline is shown below. More examples can be
  68. found in the [examples directory](https://github.com/almende/vis/tree/master/examples)
  69. of the project.
  70. ```html
  71. <!DOCTYPE HTML>
  72. <html>
  73. <head>
  74. <title>Timeline basic demo</title>
  75. <script src="vis/dist/vis.js"></script>
  76. <link href="vis/dist/vis.css" rel="stylesheet" type="text/css" />
  77. <style type="text/css">
  78. body, html {
  79. font-family: sans-serif;
  80. }
  81. </style>
  82. </head>
  83. <body>
  84. <div id="visualization"></div>
  85. <script type="text/javascript">
  86. var container = document.getElementById('visualization');
  87. var data = [
  88. {id: 1, content: 'item 1', start: '2013-04-20'},
  89. {id: 2, content: 'item 2', start: '2013-04-14'},
  90. {id: 3, content: 'item 3', start: '2013-04-18'},
  91. {id: 4, content: 'item 4', start: '2013-04-16', end: '2013-04-19'},
  92. {id: 5, content: 'item 5', start: '2013-04-25'},
  93. {id: 6, content: 'item 6', start: '2013-04-27'}
  94. ];
  95. var options = {};
  96. var timeline = new vis.Timeline(container, data, options);
  97. </script>
  98. </body>
  99. </html>
  100. ```
  101. ## Build
  102. To build the library from source, clone the project from github
  103. git clone git://github.com/almende/vis.git
  104. The source code uses the module style of node (require and module.exports) to
  105. organize dependencies. To install all dependencies and build the library,
  106. run `npm install` in the root of the project.
  107. cd vis
  108. npm install
  109. Then, the project can be build running:
  110. npm run build
  111. To automatically rebuild on changes in the source files, once can use
  112. npm run watch
  113. This will both build and minify the library on changes. Minifying is relatively
  114. slow, so when only the non-minified library is needed, one can use the
  115. `watch-dev` script instead:
  116. npm run watch-dev
  117. ## Test
  118. To test the library, install the project dependencies once:
  119. npm install
  120. Then run the tests:
  121. npm test
  122. ## License
  123. Copyright (C) 2010-2014 Almende B.V.
  124. Licensed under the Apache License, Version 2.0 (the "License");
  125. you may not use this file except in compliance with the License.
  126. You may obtain a copy of the License at
  127. http://www.apache.org/licenses/LICENSE-2.0
  128. Unless required by applicable law or agreed to in writing, software
  129. distributed under the License is distributed on an "AS IS" BASIS,
  130. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  131. See the License for the specific language governing permissions and
  132. limitations under the License.