Skip to content

Commit 411d55d

Browse files
Merge pull request #4330 from plotly/init-slideout-toolpanel
Refactor ToolPanel JS to slide-out instead of floating panels
2 parents 705e102 + 8db0f89 commit 411d55d

File tree

1 file changed

+39
-20
lines changed
  • test-dashboard/toolpanel-dashboard

1 file changed

+39
-20
lines changed

test-dashboard/toolpanel-dashboard/ui.js

Lines changed: 39 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,48 +15,67 @@ function createRemoveButton () {
1515
};
1616
}
1717

18-
function createPlot (divId) {
18+
function createTrace (type) {
19+
20+
function rand() {
21+
return Math.random() * 360;
22+
}
23+
24+
var traces = {
25+
polar: {
26+
r: [1, 2, 3, 4],
27+
t: [rand(), rand(), rand(), rand()],
28+
type: 'scatter',
29+
name: new Date()
30+
},
31+
line: {
32+
x: [1, 2, 3, 4],
33+
y: [rand(), rand(), rand(), rand()],
34+
type: 'scatter',
35+
name: new Date()
36+
}
37+
};
38+
39+
return traces[type] || traces.line;
40+
}
41+
42+
function createPlot (divId, type) {
1943
var containerDiv = document.getElementById('main');
2044
var graphDiv = document.createElement('div');
2145
var toolDiv = document.createElement('div');
46+
2247
containerDiv.style.width = '100%';
2348
containerDiv.style.height = '100%';
24-
containerDiv.style.clear = 'both';
2549

2650
graphDiv.id = divId;
27-
graphDiv.style.width = '80%';
51+
graphDiv.style.width = '50%';
2852
graphDiv.style.display = 'inline-block';
2953
graphDiv.style.margin = '0px';
30-
graphDiv.style.position = 'relative';
3154
graphDiv.style.verticalAlign = 'top';
3255

3356
toolDiv.className = 'toolDiv';
34-
toolDiv.style.width = '500px';
57+
toolDiv.style.display = 'inline-block';
58+
toolDiv.style.position = 'relative';
3559

36-
containerDiv.appendChild(toolDiv);
3760
containerDiv.appendChild(graphDiv);
61+
containerDiv.appendChild(toolDiv);
3862

39-
var trace1 = {
40-
x: [1, 2, 3, 4],
41-
y: [10, 15, 13, 17],
42-
type: 'scatter'
43-
};
44-
45-
var trace2 = {
46-
x: [1, 2, 3, 4],
47-
y: [16, 5, 11, 9],
48-
type: 'scatter'
49-
};
63+
var data = [
64+
createTrace(type),
65+
createTrace(type),
66+
createTrace(type)
67+
];
5068

51-
var data = [trace1, trace2];
5269
var toolPanel;
5370

5471
Plotly.newPlot(divId, data);
5572

5673
graphDiv.toolPanel = toolPanel = new ToolPanel(Plotly, graphDiv, {
5774
standalone: true,
75+
slideoutDirection: 'right',
5876
popoverContainer: containerDiv,
59-
menuStyle: 'descriptive'
77+
menuStyle: 'minimal',
78+
orientation: 'horizontal'
6079
});
6180

6281
window.toolPanel = graphDiv.toolPanel;
@@ -87,7 +106,7 @@ function createPlot (divId) {
87106
}
88107

89108
['one'].forEach(function (index) {
90-
createPlot(index);
109+
createPlot(index, 'polar');
91110
});
92111

93112
createRemoveButton();

0 commit comments

Comments
 (0)