Skip to content

Commit

Permalink
chore(examples): do not use flatMap in raw JS (#151)
Browse files Browse the repository at this point in the history
This is new, not yet widely supported feature.
  • Loading branch information
Thomaash committed Oct 24, 2019
1 parent 16ab8de commit a69cc61
Show file tree
Hide file tree
Showing 14 changed files with 46 additions and 37 deletions.
56 changes: 31 additions & 25 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3838,18 +3838,21 @@ <h2>Edge Styles</h2>
><input
type="hidden"
name="js"
value='const types = [
"curvedCW",
"diagonalCross",
"continuous",
"cubicBezier",
"discrete",
"dynamic",
"horizontal",
"straightCross",
"vertical",
"curvedCCW"
].flatMap(type =&gt; [{ type, scaleFactor: 1 }, { type, scaleFactor: -1 }]);
value='var types = [].concat.apply(
[],
[
"curvedCW",
"diagonalCross",
"continuous",
"cubicBezier",
"discrete",
"dynamic",
"horizontal",
"straightCross",
"vertical",
"curvedCCW"
].map(type =&gt; [{ type, scaleFactor: 1 }, { type, scaleFactor: -1 }])
);

// create an array with nodes
var nodes = new vis.DataSet();
Expand Down Expand Up @@ -3955,22 +3958,25 @@ <h2>Edge Styles</h2>
><input
type="hidden"
name="data"
value='{"css":"html,\nbody {\n height: 100%;\n width: 100%;\n margin: 0px;\n padding: 0px;\n}\n\n.mycontainer {\n position: relative;\n width: 100%;\n height: 100%;\n}\n#mynetwork {\n position: absolute;\n top: 0px;\n right: 0px;\n bottom: 0px;\n left: 0px;\n}\n","css_external":"https://visjs.github.io/vis-network/dist/vis-network.min.css","html":"&lt;div class=\".mycontainer\"&gt;\n &lt;div id=\"mynetwork\"&gt;&lt;/div&gt;\n&lt;/div&gt;\n","js":"const types = [\n \"curvedCW\",\n \"diagonalCross\",\n \"continuous\",\n \"cubicBezier\",\n \"discrete\",\n \"dynamic\",\n \"horizontal\",\n \"straightCross\",\n \"vertical\",\n \"curvedCCW\"\n].flatMap(type =&gt; [{ type, scaleFactor: 1 }, { type, scaleFactor: -1 }]);\n\n// create an array with nodes\nvar nodes = new vis.DataSet();\n\n// create an array with edges\nvar edges = new vis.DataSet();\n\ntypes.forEach(({ type, scaleFactor }, i) =&gt; {\n nodes.add([\n {\n id: 10 * i + 1,\n label: type,\n x: 0,\n y: i * 50\n },\n {\n id: 10 * i + 2,\n label: type,\n x: 800,\n y: i * 50\n }\n ]);\n edges.add([\n {\n from: 10 * i + 1,\n to: 10 * i + 2,\n smooth: { type },\n arrows: {\n from: { enabled: true, scaleFactor },\n middle: { enabled: true, scaleFactor },\n to: { enabled: true, scaleFactor }\n }\n }\n ]);\n});\n\n// create a network\nvar container = document.getElementById(\"mynetwork\");\n\n// provide the data in the vis format\nvar data = {\n nodes: nodes,\n edges: edges\n};\nvar options = {\n physics: {\n enabled: false\n }\n};\n\n// initialize your network!\nvar network = new vis.Network(container, data, options);\n","js_external":"https://visjs.github.io/vis-network/dist/vis-network.js","title":"Vis Network | Edge Styles | Arrow Alignment"}'
value='{"css":"html,\nbody {\n height: 100%;\n width: 100%;\n margin: 0px;\n padding: 0px;\n}\n\n.mycontainer {\n position: relative;\n width: 100%;\n height: 100%;\n}\n#mynetwork {\n position: absolute;\n top: 0px;\n right: 0px;\n bottom: 0px;\n left: 0px;\n}\n","css_external":"https://visjs.github.io/vis-network/dist/vis-network.min.css","html":"&lt;div class=\".mycontainer\"&gt;\n &lt;div id=\"mynetwork\"&gt;&lt;/div&gt;\n&lt;/div&gt;\n","js":"var types = [].concat.apply(\n [],\n [\n \"curvedCW\",\n \"diagonalCross\",\n \"continuous\",\n \"cubicBezier\",\n \"discrete\",\n \"dynamic\",\n \"horizontal\",\n \"straightCross\",\n \"vertical\",\n \"curvedCCW\"\n ].map(type =&gt; [{ type, scaleFactor: 1 }, { type, scaleFactor: -1 }])\n);\n\n// create an array with nodes\nvar nodes = new vis.DataSet();\n\n// create an array with edges\nvar edges = new vis.DataSet();\n\ntypes.forEach(({ type, scaleFactor }, i) =&gt; {\n nodes.add([\n {\n id: 10 * i + 1,\n label: type,\n x: 0,\n y: i * 50\n },\n {\n id: 10 * i + 2,\n label: type,\n x: 800,\n y: i * 50\n }\n ]);\n edges.add([\n {\n from: 10 * i + 1,\n to: 10 * i + 2,\n smooth: { type },\n arrows: {\n from: { enabled: true, scaleFactor },\n middle: { enabled: true, scaleFactor },\n to: { enabled: true, scaleFactor }\n }\n }\n ]);\n});\n\n// create a network\nvar container = document.getElementById(\"mynetwork\");\n\n// provide the data in the vis format\nvar data = {\n nodes: nodes,\n edges: edges\n};\nvar options = {\n physics: {\n enabled: false\n }\n};\n\n// initialize your network!\nvar network = new vis.Network(container, data, options);\n","js_external":"https://visjs.github.io/vis-network/dist/vis-network.js","title":"Vis Network | Edge Styles | Arrow Alignment"}'
/><input
type="hidden"
name="js"
value='const types = [
"curvedCW",
"diagonalCross",
"continuous",
"cubicBezier",
"discrete",
"dynamic",
"horizontal",
"straightCross",
"vertical",
"curvedCCW"
].flatMap(type =&gt; [{ type, scaleFactor: 1 }, { type, scaleFactor: -1 }]);
value='var types = [].concat.apply(
[],
[
"curvedCW",
"diagonalCross",
"continuous",
"cubicBezier",
"discrete",
"dynamic",
"horizontal",
"straightCross",
"vertical",
"curvedCCW"
].map(type =&gt; [{ type, scaleFactor: 1 }, { type, scaleFactor: -1 }])
);

// create an array with nodes
var nodes = new vis.DataSet();
Expand Down
27 changes: 15 additions & 12 deletions examples/network/edgeStyles/arrowAlignment.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,21 @@
</div>

<script type="text/javascript">
const types = [
"curvedCW",
"diagonalCross",
"continuous",
"cubicBezier",
"discrete",
"dynamic",
"horizontal",
"straightCross",
"vertical",
"curvedCCW"
].flatMap(type => [{ type, scaleFactor: 1 }, { type, scaleFactor: -1 }]);
var types = [].concat.apply(
[],
[
"curvedCW",
"diagonalCross",
"continuous",
"cubicBezier",
"discrete",
"dynamic",
"horizontal",
"straightCross",
"vertical",
"curvedCCW"
].map(type => [{ type, scaleFactor: 1 }, { type, scaleFactor: -1 }])
);

// create an array with nodes
var nodes = new vis.DataSet();
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a69cc61

Please sign in to comment.