@@ -101,47 +101,74 @@ function plotButtons(plots) {
101
101
} )
102
102
} ) ;
103
103
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
+ } ) ;
133
129
134
- document . body . removeChild ( plotDiv ) ;
135
- } ) ;
136
130
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 ) ;
139
151
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
+ } ) ;
140
166
141
167
}
142
168
143
169
var plots = { } ;
144
170
171
+ plots [ 'ibm-plot' ] = require ( './testplots/ibm-plot.json' ) ;
145
172
plots [ 'marker-color' ] = require ( './testplots/marker-color.json' ) ;
146
173
plots [ 'log-axis-big' ] = require ( './testplots/log-axis-big.json' ) ;
147
174
plots [ 'delaunay' ] = require ( './testplots/delaunay.json' ) ;
0 commit comments