diff --git a/.babelrc b/.babelrc index a78771c4bb..f77f4dcb12 100644 --- a/.babelrc +++ b/.babelrc @@ -3,7 +3,9 @@ [ "@babel/preset-env", { - "targets": "> 0.1% or not dead" + "targets": "> 0.1% or not dead", + "useBuiltIns": "usage", + "corejs": 3 } ], "@babel/preset-typescript" @@ -11,8 +13,7 @@ "plugins": [ "css-modules-transform", "@babel/proposal-class-properties", - "@babel/proposal-object-rest-spread", - "@babel/plugin-transform-runtime" + "@babel/proposal-object-rest-spread" ], "env": { "test": { diff --git a/.eslintrc.js b/.eslintrc.js index e4b33ffb8e..2c177ad783 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -103,8 +103,6 @@ module.exports = { }, { files: [ - "lib/index-bundle.ts", - "lib/index.ts", "lib/network/gephiParser.ts", "test/NodesHandler.test.ts", "test/dot-parser/dot-parser.test.ts", diff --git a/.gitignore b/.gitignore index 88ee4168c6..dc9f43a575 100644 --- a/.gitignore +++ b/.gitignore @@ -17,5 +17,12 @@ gen/ .nyc_output/ coverage/ .rpt2_cache -vis-network-*.tgz + +# built files +/declarations/ /dist/ +/examples/index.html +/examples/thumbnails/ +/peer/ +/standalone/ +vis-network-*.tgz diff --git a/README.md b/README.md index e6ef87648d..c76a81929f 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Install via npm: ## Example -A basic example on loading a Timeline is shown below. More examples can be +A basic example on loading a Network is shown below. More examples can be found in the [examples directory](https://github.com/visjs/vis-network/tree/master/examples/) of the project. @@ -27,8 +27,7 @@ of the project.
+ Create a simple network with some nodes and edges. +
+ ++ This is kept only for backwards compatibility as this build is broken. + It doesn't play well with tree shaking, doesn't work with other Vis + family packages and atop of that contains bloatware that is not used by + Vis Network at all. +
+ ++ Please don't use this. Use the + standalone build + instead. +
+ +
+<script type="text/javascript" src="https://unpkg.com/vis-network/dist/vis-network.min.js"></script>
+<link rel="stylesheet" type="text/css" href="https://unpkg.com/vis-network/dist/vis-network.min.css" />
+<!--
+ Including other packages like Vis Timeline or Vis Graph3D here won't work.
+ You need the peer build to do that.
+-->
+
+<script type="text/javascript">
+ // 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 },
+ { from: 3, to: 3 }
+ ]);
+
+ // create a network
+ var container = document.getElementById("mynetwork");
+ var data = {
+ nodes: nodes,
+ edges: edges
+ };
+ var options = {};
+ var network = new vis.Network(container, data, options);
+</script>
+
+
+
+import { DataSet, Network } from "vis-network";
+import "vis-network/styles/vis-network.css";
+
+// create an array with nodes
+const nodes = new 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
+const edges = new DataSet([
+ { from: 1, to: 3 },
+ { from: 1, to: 2 },
+ { from: 2, to: 4 },
+ { from: 2, to: 5 },
+ { from: 3, to: 3 }
+]);
+
+// create a network
+const container = document.getElementById("mynetwork");
+const data = {
+ nodes: nodes,
+ edges: edges
+};
+const options = {};
+const network = new Network(container, data, options);
+
+