Skip to content

Commit 9b21d9e

Browse files
committed
Merge branch 'master' into opa-styleguide
2 parents 9cf9e40 + aac3bfb commit 9b21d9e

File tree

5 files changed

+577
-119
lines changed

5 files changed

+577
-119
lines changed

3d-test-dashboard/test.js

+60-33
Original file line numberDiff line numberDiff line change
@@ -101,47 +101,74 @@ function plotButtons(plots) {
101101
})
102102
});
103103

104-
var pummelButton = document.createElement('button');
105-
pummelButton.style.cssFloat = 'left';
106-
pummelButton.style.width = '100px';
107-
pummelButton.style.height = '40px';
108-
pummelButton.style.marginLeft = '25px';
109-
pummelButton.innerHTML = 'pummel3d';
110-
pummelButton.style.background = 'blue';
111-
plotlist.appendChild(pummelButton);
112-
113-
var i = 0;
114-
var mock = require('./testplots/marker-color.json');
115-
var statusDiv = document.getElementById('status-info');
116-
117-
pummelButton.addEventListener('click', function () {
118-
setInterval(function () {
119-
var plotDiv = document.createElement('div');
120-
window.plotDiv = plotDiv;
121-
122-
plotDiv.id = 'div' + i;
123-
document.body.appendChild(plotDiv);
124-
125-
Plotly.plot(plotDiv, mock.data, mock.layout, {staticPlot: true}).then(function () {
126-
127-
Plotly.Plots.getSubplotIds(plotDiv._fullLayout, 'gl3d').forEach( function (key) {
128-
var scene = plotDiv._fullLayout[key]._scene;
129-
scene.destroy();
130-
i ++;
131-
statusDiv.innerHTML = 'Created ' + i + ' webgl contexts.';
132-
});
104+
var loseContextButton = document.createElement('button');
105+
loseContextButton.style.cssFloat = 'left';
106+
loseContextButton.style.width = '100px';
107+
loseContextButton.style.height = '40px';
108+
loseContextButton.style.marginLeft = '25px';
109+
loseContextButton.innerHTML = 'lose/restore context';
110+
loseContextButton.style.background = 'blue';
111+
plotlist.appendChild(loseContextButton);
112+
113+
var ext = null;
114+
loseContextButton.addEventListener('click', function() {
115+
if(!gd) {
116+
return;
117+
}
118+
Plotly.Plots.getSubplotIds(gd._fullLayout, 'gl3d').forEach( function (key) {
119+
var scene = gd._fullLayout[key]._scene;
120+
var gl = scene.glplot.gl;
121+
if(gl.isContextLost()) {
122+
ext.restoreContext();
123+
} else {
124+
ext = gl.getExtension('WEBGL_lose_context');
125+
ext.loseContext();
126+
}
127+
});
128+
});
133129

134-
document.body.removeChild(plotDiv);
135-
});
136130

137-
}, 500);
138-
});
131+
var pummelButton = document.createElement('button');
132+
pummelButton.style.cssFloat = 'left';
133+
pummelButton.style.width = '100px';
134+
pummelButton.style.height = '40px';
135+
pummelButton.style.marginLeft = '25px';
136+
pummelButton.innerHTML = 'pummel3d';
137+
pummelButton.style.background = 'blue';
138+
plotlist.appendChild(pummelButton);
139+
140+
var i = 0;
141+
var mock = require('./testplots/marker-color.json');
142+
var statusDiv = document.getElementById('status-info');
143+
144+
pummelButton.addEventListener('click', function () {
145+
setInterval(function () {
146+
var plotDiv = document.createElement('div');
147+
window.plotDiv = plotDiv;
148+
149+
plotDiv.id = 'div' + i;
150+
document.body.appendChild(plotDiv);
139151

152+
Plotly.plot(plotDiv, mock.data, mock.layout, {staticPlot: true}).then(function () {
153+
154+
Plotly.Plots.getSubplotIds(plotDiv._fullLayout, 'gl3d').forEach( function (key) {
155+
var scene = plotDiv._fullLayout[key]._scene;
156+
scene.destroy();
157+
i ++;
158+
statusDiv.innerHTML = 'Created ' + i + ' webgl contexts.';
159+
});
160+
161+
document.body.removeChild(plotDiv);
162+
});
163+
164+
}, 500);
165+
});
140166

141167
}
142168

143169
var plots = {};
144170

171+
plots['ibm-plot'] = require('./testplots/ibm-plot.json');
145172
plots['marker-color'] = require('./testplots/marker-color.json');
146173
plots['log-axis-big'] = require('./testplots/log-axis-big.json');
147174
plots['delaunay'] = require('./testplots/delaunay.json');

0 commit comments

Comments
 (0)