Skip to content

Instantly share code, notes, and snippets.

@knbknb
Last active January 19, 2019 22:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save knbknb/d05be6529087596eb279f6734b6067cf to your computer and use it in GitHub Desktop.
Save knbknb/d05be6529087596eb279f6734b6067cf to your computer and use it in GitHub Desktop.
Grab existing visjs DOM object on html page, change visjs options. http://visjs.org/ , R htmlwidgets
// Grab existing visjs DOM object on html page, change options
// knb 2018-12-08
// http://visjs.org/ Visualisation Library
// get similar id e.g. by inspecting HTML page source code that was generated by R htmlwidgets package
var = "htmlwidget-4210fec5d0f413c28b94";
var el = document.getElementById("graph" + widget);
var network = el.chart;
el.nodes.length; // should print a single int
el.chart.setOptions({
nodes: {
shape: 'dot',
size: 30,
font: {
size: 13
},
borderWidth: 2,
shadow:true
},
edges: {
width: 2,
shadow:true
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment