You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<!-- Overlay effect when opening sidebar on small screens -->
48
+
<divclass="w3-overlay w3-hide-large" onclick="w3_close()" style="cursor:pointer" title="close side menu" id="myOverlay"></div>
49
+
50
+
<!-- !PAGE CONTENT! -->
51
+
<divclass="w3-main" style="margin-left:300px;">
52
+
<divid="page">
53
+
<divid="content"><h1class="w3-xxlarge"><strong>VanGraph</strong>: Visualize Dependencies in Your App</h1><p><strong>VanGraph</strong> is a library that helps you visualize dependency graph among states and DOM nodes with the help of <ahref="https://graphviz.org/" class="w3-hover-opacity">Graphviz</a>. Here is the sample usage:</p><pre><codeclass="language-js">const firstName = van.state("Tao"), lastName = van.state("Xin")
// To visualize the dependency graph among `firstName`, `lastName`, `fullName`, and all the
59
+
// derived states and DOM nodes from them.
60
+
vanGraph.show({firstName, lastName, fullName})
61
+
</code></pre><p>Checkout a demo in <ahref="https://codesandbox.io/p/devbox/github/vanjs-org/van/tree/main/graph/examples/basic?file=%2Fsrc%2Fmain.ts" class="w3-hover-opacity">CodeSandbox</a>.</p><h2class="w3-xxlarge w3-text-red" id="installation"><aclass="self-link" href="#installation">Installation</a></h2><hrstyle="width:50px;border:5px solid red" class="w3-round"><h3class="w3-large w3-text-red" id="via-npm"><aclass="self-link" href="#via-npm">Via NPM</a></h3><p>The library is published as NPM package <ahref="https://www.npmjs.com/package/vanjs-graph" class="w3-hover-opacity">vanjs-graph</a>. Run the following command to install the package:</p><pre><codeclass="language-shell">npm install vanjs-graph
62
+
</code></pre><p>To use the NPM package, add this line to your script:</p><pre><codeclass="language-js">import * as vanGraph from "vanjs-graph"
63
+
</code></pre><h3class="w3-large w3-text-red" id="via-a-script-tag"><aclass="self-link" href="#via-a-script-tag">Via a Script Tag</a></h3><p>Alternatively, you can import <strong>VanGraph</strong> from CDN via a <codeclass="symbol"><script type="text/javascript"></code> tag:</p><pre><codeclass="language-html"><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/[email protected]/dist/van-graph.nomodule.min.js"></script>
64
+
</code></pre><p><codeclass="symbol">https://cdn.jsdelivr.net/npm/[email protected]/dist/van-graph.nomodule.js</code> can be used for the non-minified version.</p><p>Note that: you need to import <strong>VanJS</strong> and <codeclass="symbol">@viz-js/viz</code> before <strong>VanGraph</strong> for it to be used properly:</p><pre><codeclass="language-html"><script type="text/javascript" src="https://cdn.jsdelivr.net/gh/vanjs-org/van/public/van-1.5.2.nomodule.min.js"></script>
</code></pre><p>The parameter <codeclass="symbol">states</code> represents a collection of <codeclass="symbol">State</code> objects whose dependency graph we want to visualize. All the <codeclass="symbol">State</code> objects and their dependents will be rendered in the dependency graph. <codeclass="symbol">states</code> can either be specified as a plain object, e.g.: <codeclass="symbol">{firstName, lastName, fullName}</code>, or as an array, e.g.: <codeclass="symbol">[firstName, lastName, fullName]</code>. If <codeclass="symbol">states</code> is specified as an array, the variable names won't be shown in the rendered graph.</p><p><codeclass="symbol">options</code> is a plain object with the following properties:</p><ul><li><codeclass="symbol">rankdir</code>: Type <codeclass="symbol">string</code>. Default <codeclass="symbol">"LR"</code>. Optional. Corresponding to the graph attribute <codeclass="symbol">rankdir</code> in Graphviz.</li></ul><p>The function returns a <codeclass="symbol">Promise<SVGSVGElement></code> so that you can await the result and then attach <codeclass="symbol">SVGSVGElement</code> to the main DOM tree.</p></div>
68
+
<asideid="toc"><ul><li><ahref="#installation" class="w3-hover-opacity">Installation</a><ul><li><ahref="#via-npm" class="w3-hover-opacity">Via NPM</a></li><li><ahref="#via-a-script-tag" class="w3-hover-opacity">Via a Script Tag</a></li></ul></li><li><ahref="#documentation" class="w3-hover-opacity">Documentation</a></li></ul></aside>
0 commit comments