-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathplotly.js
More file actions
44 lines (33 loc) · 1.01 KB
/
plotly.js
File metadata and controls
44 lines (33 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
CATEGORY = "Visualization"
script = document.createElement("script");
script.type = "text/javascript";
script.src = "https://boostlet.org/dist/boostlet.min.js";
script.onload = run;
document.head.appendChild(script);
eval(script);
function run() {
// detect visualization framework
Boostlet.init();
all_pixels = Boostlet.get_image().data;
// load Plotly.js library and start plotting in the onload callback
Boostlet.load_script('https://cdn.plot.ly/plotly-2.25.2.min.js', plot);
}
function plot() {
// create div for plot
let container = window.document.createElement('div');
container.id = 'plotlyDiv';
container.style.position = 'absolute';
container.style.top = '10px';
container.style.left = '10px';
container.style.zIndex = '1000';
container.onclick = function() {
// destroy on click
window.document.body.removeChild(container);
}
window.document.body.appendChild(container);
// plot the data
Plotly.newPlot('plotlyDiv', [{
x: all_pixels,
type: 'histogram'
}]);
}