My New Hugo Site

  1. Bash
    1. Filters
      1. grep
      2. Sed
      3. jq
    2. Shellspec
  2. Design
  3. Architectural Patterns
    1. Systemd
    2. Message Broker
    3. JSON-RPC
  4. Go
    1. Concurrency
    2. Web Applications
    3. Compound Data
    4. Json
    5. Go vs Erlang
  5. Prolog Cookbook
  6. Documentation
    1. Hugo
      1. Go Html Template
      2. Table of Contents
    2. HTML
    3. CSS
      1. Color
      2. Style Guides
      3. Layout
    4. Mathjax
  7. Visualization
    1. D3
      1. Venn Diagrams
    2. SVG
    3. Visjs
      1. Network
  8. Data
    1. Yaml
    2. Events
      1. JSON-LD
    3. JSON
      1. jCal
    4. SQL
  9. JavaScript

Network

vis.Network(…)

const container = {...};
const data = {...};
const options = {...};

const network = new vis.Network(container, data, options);

container

This can be <div> or a semantic element such as <figure>

I tried changing to <canvas> and the diagram vanished.

HTML

<div id="mynetwork"></div>

JavaScript

const container = document.getElementById('mynetwork');

data

Network Data Format

const data = {
  nodes: nodes,
  edges: edges
};

nodes

const 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'}
]);

edges

const edges = new vis.DataSet([
  {from: 1, to: 3},
  {from: 1, to: 2},
  {from: 2, to: 4},
  {from: 2, to: 5},
  {from: 3, to: 3}
]);

Alternatively, a string in the dot language.

const data = {
  dot: 'digraph g {\
a -> b;\
a -> c;\
a -> d;\
b -> e;\
b -> f;\
c -> g;\
c -> h;\
c -> i;\
d -> j;\
e -> k;\
f -> l;\
f -> m;\
h -> n;\
i -> o;\
i -> p;\
j -> q;\
j -> r;\
j -> s;\
m -> t;\
n -> t;\
}'
};

DataSet documentation

options

Configuration options

const options = {
  width:  '100%',
  height: '400px',
  edges: {
    color: 'red',
    width: 2
  }
};