wvk
March 29, 2018, 5:57am
1
Hello,
I’m working on an implementation where I need to generate a sankey graph in JS. I looked into adding only the minimum components;
"../node_modules/plotly.js/lib/core.js",
"../node_modules/plotly.js/lib/sankey.js"
But this results in a empty graph with an X & Y axis for some reason. It’s not the implementation of the rest of the code, if I include the complete Plotly library the graph is drawn correctly.
I looked into https://github.com/plotly/plotly.js/blob/master/dist/README.md but sankey is not listed there and none of the bundles seems to include it…
Am I missing something or is this by design and is there no other way to draw these kinds of plots?
Regards,
Wouter
The Sankey module is here → plotly.js/sankey.js at master · plotly/plotly.js · GitHub
So,
var Plotly = require('plotly.js/lib/core')
Plotly.register(require('plotly.js/lib/sankey'))
a build step using browserify or webpack should work.
1 Like
wvk
March 30, 2018, 7:37am
3
Thank you, this worked. I got confused since it’s not in any of the index packages.
1 Like
leviz
May 20, 2020, 5:33am
4
I ran the parameters you can have given. However I’m still getting a blank screen when using the bundled JS.
browserify your_parameters.js > bundle.js
<script src='bundle.js'></script>
Are there any other modules that need to be included for the Sankey Diagram?
For reference my script needs to process data from a JSON file.
Plotly.d3.json('./data.json', function (fig) {
and runs fine when using
<script src='plotly-latest.min.js'></script>