How to build a line and scatter plot with Plotly.js charts.
Created
April 23, 2019 16:34
-
-
Save antoinerg/059e1f2d2080c1a168890125a5d4574c to your computer and use it in GitHub Desktop.
Sankey-order
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<head> | |
<!-- Plotly.js --> | |
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script> | |
</head> | |
<body> | |
<div id="myDiv"><!-- Plotly chart will be drawn inside this DIV --></div> | |
<script> | |
<!-- JAVASCRIPT CODE GOES HERE --> | |
</script> | |
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var scatter = { | |
"type": "scatter", | |
"xaxis": "x2" | |
} | |
var sankey = { | |
"domain": { | |
"x": [ | |
0, | |
0.45 | |
] | |
}, | |
"link": { | |
"source": [ | |
0, | |
0, | |
1, | |
1 | |
], | |
"target": [ | |
2, | |
3, | |
2, | |
3 | |
], | |
"value": [ | |
1, | |
1, | |
1, | |
1 | |
] | |
}, | |
"node": { | |
"label": [ | |
"A", | |
"B", | |
"C", | |
"D" | |
] | |
}, | |
"type": "sankey" | |
} | |
var fig = { | |
// Works | |
// "data": [sankey, scatter], | |
// Breaks | |
"data": [scatter, sankey], | |
"layout": { | |
"annotations": [ | |
{ | |
"text": "(1,1)", | |
"x": 1, | |
"xref": "x2", | |
"y": 1 | |
} | |
], | |
"xaxis2": { | |
"domain": [ | |
0.55, | |
1 | |
] | |
} | |
} | |
} | |
Plotly.newPlot('myDiv', fig, {showSendToCloud: true}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment