Socket
Socket
Sign inDemoInstall

vis

Package Overview
Dependencies
5
Maintainers
5
Versions
76
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    vis

A dynamic, browser-based visualization library.


Version published
Weekly downloads
196K
decreased by-2.25%
Maintainers
5
Install size
18.1 MB
Created
Weekly downloads
 

Package description

What is vis?

The vis npm package is a dynamic, browser-based visualization library. It is designed to handle large amounts of dynamic data and enables the creation of interactive timelines, 2D/3D graphs, and network visualizations.

What are vis's main functionalities?

Timeline

The Timeline feature allows you to create interactive timelines with items that can have start and end dates. This is useful for visualizing events over time.

const vis = require('vis');

// Create a DataSet (allows two way data-binding)
var items = new vis.DataSet([
  {id: 1, content: 'item 1', start: '2023-04-20'},
  {id: 2, content: 'item 2', start: '2023-04-14'},
  {id: 3, content: 'item 3', start: '2023-04-18'},
  {id: 4, content: 'item 4', start: '2023-04-16', end: '2023-04-19'},
  {id: 5, content: 'item 5', start: '2023-04-25'},
  {id: 6, content: 'item 6', start: '2023-04-27', type: 'point'}
]);

// Configuration for the Timeline
var options = {};

// Create a Timeline
var timeline = new vis.Timeline(container, items, options);

Network

The Network feature allows you to create interactive network graphs with nodes and edges. This is useful for visualizing relationships and connections between entities.

const vis = require('vis');

// create an array with nodes
var nodes = new vis.DataSet([
  {id: 1, label: 'Node 1'},
  {id: 2, label: 'Node 2'},
  {id: 3, label: 'Node 3'},
  {id: 4, label: 'Node 4'},
  {id: 5, label: 'Node 5'}
]);

// create an array with edges
var edges = new vis.DataSet([
  {from: 1, to: 3},
  {from: 1, to: 2},
  {from: 2, to: 4},
  {from: 2, to: 5}
]);

// create a network
var container = document.getElementById('mynetwork');
var data = {
  nodes: nodes,
  edges: edges
};
var options = {};
var network = new vis.Network(container, data, options);

Graph2D

The Graph2D feature allows you to create interactive 2D graphs. This is useful for visualizing data points over a two-dimensional space.

const vis = require('vis');

// Create a DataSet (allows two way data-binding)
var data = new vis.DataSet();

// Add data
for (var i = 0; i < 100; i++) {
  data.add({x: i, y: Math.sin(i / 5)});
}

// Configuration for the Graph2d
var options = {
  start: '2023-04-10',
  end: '2023-04-30'
};

// Create a Graph2d
var container = document.getElementById('mygraph');
var graph2d = new vis.Graph2d(container, data, options);

Other packages similar to vis

Changelog

Source

2017-10-12, version 4.21.0

General

  • Added #3394: Adds unit tests for add, setOptions and on/off DataSet
  • FIX #3406: Eliminate possibility of 'window is undefined' during travis test
  • Added #3402: added @macleodbroad-wf to the support team
  • REFA #3442: Strapping down of Extend-routines in util.js
  • FIX #3392: Addresses TODOs in Queue unit test by adding unit tests for setOptions and destroy
  • Added #3354: Adds missing jsdoc and adds lint rule require-jsdoc to build process
  • Added #3331 - Enable linting for Travis
  • Added #3312, #3311, #3310, #3309, #3308, #3304 - Add lint
  • Added #3230 - Enable 'eslint'
  • Added #3262 - Upgrade packages and tools for Travis unit testing
  • Added #3287: Update module versions to latest stable
  • Added #3295: Update the webpack example

Network

  • FIX #3554: Relax clustering condition for adding already clustered nodes to cluster
  • FIX #3517: Retain constraint values in label font handling
  • REFA #3507: Cleanup and refactoring PhysicsEngine
  • FIX #3500: re-adds edges if they are now connected and add does not add invalid edges
  • FIX #3486: Add extra check on null value during label handling
  • FEAT #824: Network detect clicks on labels
  • FIX #3474: Adjust documentation for arrows.middle.scaleFactor
  • FIX #3483: Prevent image loading for hidden cluster nodes
  • FIX #3408, #2677: Fix handling of multi-fonts
  • FIX #3425: IE performance improvements
  • FIX #3356 and #3297: IE11 svg image fixes
  • FIX #3474: Make negative scaleFactor reverse middle arrow correctly
  • FIX #3464: Fix handling of space before huge word in label text
  • FIX #3467: Adjust for-in loops so they can deal with added properties in Array and Object prototype
  • FEAT #3412: Add endpoint 'bar' to Network
  • FIX #3403: Fixes sorting on Layout, refactoring
  • FIX #3421: Added default sizes for nodes without labels
  • FEAT #3418: Added new Hexagon shape in the Network
  • FEAT #3368: Cluster node handling due to dynamic data change
  • FIX #3395: Allow for multiline titles
  • FIX #3367: Network Clustering fixes on usage joinCondition for clusterOutliers()
  • FIX #3350: Fix setting of edge color options via Network.setOptions()
  • FEAT #3348: Add edge styles support for DOT lib
  • FIX #2839: Re-words documentation to reflect symmetrical input/output of get() when passed multiple ids
  • FIX #3316: Updates network documentation to account for edge
  • FIX #1218, #1291, #1315: Dynamically adjust clustering when data changes
  • FIX #2311: Block recalculation of level in LayoutEngine._determineLevelsDirected()
  • FIX #3280: Cleanup mergeOptions() and fix missing ref on globalOptions in mergeOptions()
  • FEAT #3131: Added dragStart event for adding edges
  • FIX #3171 and #3185: Fix infinite loop on drawing of large labels
  • FIX #3220: Update hierarchy when node level changes
  • FIX #3245: Multiple base edges in clustered edge
  • FEAT #1222: Add pointer data to hover events
  • REFA #3106: Refactoring and unit testing of Validator module
  • REFA #3227: Refactor LayoutEngine for further work
  • FIX #3164: make 'hidden' and 'clustered' play nice together
  • FIX #2579: Allow DOM elements for node titles
  • FIX #2856: Fix manipulation examples for Network

Graph2D

  • FIX #1852: Correct documentation for graph2d’s moveTo function

Graph3D

  • FIX #3467: Adjust for-in loops so they can deal with added properties in Array and Object prototypes
  • FEAT #3099: Add option definitions and validation to Graph3d
  • REFA #3159: move Filter into DataGroup
  • FEAT #3255: Add unit tests for Graph3D issue
  • FIX #3251: Graph3d put guards before unsubscription in DataGroup
  • FIX #3255: Fix missing reference to Graph3D instance in DataGroup

Timeline

  • FEAT #3529: On timeline loaded
  • FEAT #3505: Drag object in to item
  • FEAT #3050: Allow disabling of RangeItem limitSize
  • FIX #3475: Item Redraw Performance - Bug Fix
  • FIX #3504: Fixing a bug with the timing of the final setting of the vertical scroll position
  • FIX #3509: Added describe sections to PointItem unit tests
  • FIX #2851: Vertical focus
  • FEAT #620: Subgroup stacking
  • FIX #3475: Improve Item redraw and initial draw performance
  • FIX #3409: Group redraw performance
  • FEAT #3428: Adds locale for Chinese (cn)
  • FIX #3405: fix orientation option
  • FIX #3360: Add performance tips to timeline docs
  • FIX #3378: Add item with ctrlKey/metaKey when dagging on a selected item
  • FIX #3126: Nested groups order logic
  • FIX #3246: Fix issue when showMajorLabels == false is used with a weekly scale and weekly scale minor label fix
  • FIX #3342: Bug fix for null parent
  • FIX #2123: Disable the default handling of the pinch event when handling it
  • FIX #3169: add parenthesis around ternary
  • FIX #3249: Only draw non-visible items once when they are loaded, instead of continuously every frame
  • FEAT #3162: Bidirectional scrolling in timeline - make horizontalScroll and verticalScroll work together

Readme

Source

vis.js

Join the chat at https://gitter.im/vis-js/Lobby

Vis.js is a dynamic, browser based visualization library. The library is designed to be easy to use, handle large amounts of dynamic data, and enable manipulation of the data. The library consists of the following components:

  • DataSet and DataView. A flexible key/value based data set. Add, update, and remove items. Subscribe on changes in the data set. A DataSet can filter and order items, and convert fields of items.
  • DataView. A filtered and/or formatted view on a DataSet.
  • Graph2d. Plot data on a timeline with lines or barcharts.
  • Graph3d. Display data in a three dimensional graph.
  • Network. Display a network (force directed graph) with nodes and edges.
  • Timeline. Display different types of data on a timeline.

The vis.js library was initially developed by Almende B.V.

Badges

NPM

Dependency Status devDependency Status

last version on CDNJS GitHub contributors GitHub stars

GitHub issues Percentage of issues still open Average time to resolve an issue Pending Pull-Requests

Code Climate

Install

Install via npm:

$ npm install vis

Install via bower:

$ bower install vis

Link via cdnjs: http://cdnjs.com

Or download the library from the github project: https://github.com/almende/vis.git.

Load

To use a component, include the javascript and css files of vis in your web page:

<!DOCTYPE HTML>
<html>
<head>
  <script src="webroot/vis/dist/vis.js"></script>
  <link href="webroot/vis/dist/vis.css" rel="stylesheet" type="text/css" />
</head>
<body>
  <script type="text/javascript">
    // ... load a visualization
  </script>
</body>
</html>

or load vis.js using require.js. Note that vis.css must be loaded too.

require.config({
  paths: {
    vis: 'path/to/vis/dist',
  }
});
require(['vis'], function (math) {
  // ... load a visualization
});

A timeline can be instantiated as:

var timeline = new vis.Timeline(container, data, options);

Where container is an HTML element, data is an Array with data or a DataSet, and options is an optional object with configuration options for the component.

Example

A basic example on loading a Timeline is shown below. More examples can be found in the examples directory of the project.

<!DOCTYPE HTML>
<html>
<head>
  <title>Timeline basic demo</title>
  <script src="vis/dist/vis.js"></script>
  <link href="vis/dist/vis.css" rel="stylesheet" type="text/css" />

  <style type="text/css">
    body, html {
      font-family: sans-serif;
    }
  </style>
</head>
<body>
<div id="visualization"></div>

<script type="text/javascript">
  var container = document.getElementById('visualization');
  var data = [
    {id: 1, content: 'item 1', start: '2013-04-20'},
    {id: 2, content: 'item 2', start: '2013-04-14'},
    {id: 3, content: 'item 3', start: '2013-04-18'},
    {id: 4, content: 'item 4', start: '2013-04-16', end: '2013-04-19'},
    {id: 5, content: 'item 5', start: '2013-04-25'},
    {id: 6, content: 'item 6', start: '2013-04-27'}
  ];
  var options = {};
  var timeline = new vis.Timeline(container, data, options);
</script>
</body>
</html>

Build

To build the library from source, clone the project from github

$ git clone git://github.com/almende/vis.git

The source code uses the module style of node (require and module.exports) to organize dependencies. To install all dependencies and build the library, run npm install in the root of the project.

$ cd vis
$ npm install

Then, the project can be build running:

$ npm run build

To automatically rebuild on changes in the source files, once can use

$ npm run watch

This will both build and minify the library on changes. Minifying is relatively slow, so when only the non-minified library is needed, one can use the watch-dev script instead:

$ npm run watch-dev

Custom builds

The folder dist contains bundled versions of vis.js for direct use in the browser. These bundles contain all the visualizations and include external dependencies such as hammer.js and moment.js.

The source code of vis.js consists of commonjs modules, which makes it possible to create custom bundles using tools like Browserify or Webpack. 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 version 2 is required as of v4.

Prerequisites

Before you can do a build:

  • Install node.js and npm on your system: https://nodejs.org/

  • Install the following modules using npm: browserify, babelify, and uglify-js:

    $ [sudo] npm install -g browserify babelify uglify-js
    
  • Download or clone the vis.js project:

    $ git clone https://github.com/almende/vis.git
    
  • Install the dependencies of vis.js by running npm install in the root of the project:

    $ cd vis
    $ npm install
    

Examples of custom builds

Example 1: Bundle only a single visualization type

For example, to create a bundle with just the Timeline and DataSet, create an index file named custom.js in the root of the project, containing:

exports.DataSet = require('./lib/DataSet');
exports.Timeline = require('./lib/timeline/Timeline');

Then create a custom bundle using browserify, like:

$ browserify custom.js -t [ babelify --presets [es2015] ] -o dist/vis-custom.js -s vis

This will generate a custom bundle vis-custom.js, which exposes the namespace vis containing only DataSet and Timeline. The generated bundle can be minified using uglifyjs:

$ uglifyjs dist/vis-custom.js -o dist/vis-custom.min.js

The custom bundle can now be loaded like:

<!DOCTYPE HTML>
<html>
<head>
  <script src="dist/vis-custom.min.js"></script>
  <link href="dist/vis.min.css" rel="stylesheet" type="text/css" />
</head>
<body>
  ...
</body>
</html>
Example 2: Exclude external libraries

The default bundle vis.js is standalone and includes external dependencies such as hammer.js and moment.js. When these libraries are already loaded by the application, vis.js does not need to include these dependencies itself too. To build a custom bundle of vis.js excluding moment.js and hammer.js, run browserify in the root of the project:

$ browserify index.js -t [ babelify --presets [es2015] ] -o dist/vis-custom.js -s vis -x moment -x hammerjs

This will generate a custom bundle vis-custom.js, which exposes the namespace vis, and has moment.js and hammer.js excluded. The generated bundle can be minified with uglifyjs:

$ uglifyjs dist/vis-custom.js -o dist/vis-custom.min.js

The custom bundle can now be loaded as:

<!DOCTYPE HTML>
<html>
<head>
  <!-- load external dependencies -->
  <script src="http://cdnjs.cloudflare.com/ajax/libs/moment.js/2.17.1/moment.min.js"></script>
  <script src="http://cdnjs.cloudflare.com/ajax/libs/hammer.js/2.0.8/hammer.min.js"></script>

  <!-- load vis.js -->
  <script src="dist/vis-custom.min.js"></script>
  <link href="dist/vis.min.css" rel="stylesheet" type="text/css" />
</head>
<body>
  ...
</body>
</html>
Example 3: Bundle vis.js as part of your (commonjs) application

When writing a web application with commonjs modules, vis.js can be packaged automatically into the application. Create a file app.js containing:

var moment = require('moment');
var DataSet = require('vis/lib/DataSet');
var Timeline = require('vis/lib/timeline/Timeline');

var container = document.getElementById('visualization');
var data = new DataSet([
  {id: 1, content: 'item 1', start: moment('2013-04-20')},
  {id: 2, content: 'item 2', start: moment('2013-04-14')},
  {id: 3, content: 'item 3', start: moment('2013-04-18')},
  {id: 4, content: 'item 4', start: moment('2013-04-16'), end: moment('2013-04-19')},
  {id: 5, content: 'item 5', start: moment('2013-04-25')},
  {id: 6, content: 'item 6', start: moment('2013-04-27')}
]);
var options = {};
var timeline = new Timeline(container, data, options);

The application can be bundled and minified:

$ browserify app.js -o dist/app-bundle.js -t babelify
$ uglifyjs dist/app-bundle.js -o dist/app-bundle.min.js

And loaded into a webpage:

<!DOCTYPE HTML>
<html>
<head>
  <link href="node_modules/vis/dist/vis.min.css" rel="stylesheet" type="text/css" />
</head>
<body>
  <div id="visualization"></div>
  <script src="dist/app-bundle.min.js"></script>
</body>
</html>
Example 4: Integrate vis.js components directly in your webpack build

You can integrate e.g. the timeline component directly in you webpack build. Therefor you can e.g. import the component-files from root direcory (starting with "index-").

import { DataSet, Timeline } from 'vis/index-timeline-graph2d';

var container = document.getElementById('visualization');
var data = new DataSet();
var timeline = new Timeline(container, data, {});

To get this to work you'll need to add some babel-loader-setting to your webpack-config:

module: {
  module: {
    rules: [{
      test: /node_modules[\\\/]vis[\\\/].*\.js$/,
      loader: 'babel-loader',
      query: {
        cacheDirectory: true,
        presets: [ "babel-preset-es2015" ].map(require.resolve),
        plugins: [
          "transform-es3-property-literals", // #2452
          "transform-es3-member-expression-literals", // #2566
          "transform-runtime" // #2566
        ]
      }
    }]
  }
}

There is also an demo-project showing the integration of vis.js using webpack.

Test

To test the library, install the project dependencies once:

$ npm install

Then run the tests:

$ npm run test

License

Copyright (C) 2010-2017 Almende B.V. and Contributors

Vis.js is dual licensed under both

and

Vis.js may be distributed under either license.

Keywords

FAQs

Last updated on 12 Oct 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc