Skip to content

Instantly share code, notes, and snippets.

@rjbriody
Last active October 16, 2015 19:46
Show Gist options
  • Save rjbriody/16636617c2208d0c83b6 to your computer and use it in GitHub Desktop.
Save rjbriody/16636617c2208d0c83b6 to your computer and use it in GitHub Desktop.
vis.js Network delete edge label not working
<!doctype html>
<html>
<head>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/vis/4.9.0/vis.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/vis/4.9.0/vis.min.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="mynetwork"></div>
<script type="text/javascript">
var nodes = new vis.DataSet([
{id: 1, label: 'Node 1'},
{id: 2, label: 'Node 2'}
]);
var edges = new vis.DataSet([
// initially the edge has a label, but it is removed below.
{id: 0, from: 1, to: 2, label: 'BOO'}
]);
var data = {
nodes: nodes,
edges: edges
};
var network = new vis.Network(document.getElementById('mynetwork'), data, {});
setTimeout(function () {
var edge = edges.get(0);
// ****************************************************************
// Delete the label field and update the edge, but the label does
// not disappear from the view.
// ****************************************************************
delete edge.label;
edges.update(edge);
alert("Updated " + JSON.stringify(edge));
}, 1000);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment