File tree 2 files changed +11
-16
lines changed
2 files changed +11
-16
lines changed Original file line number Diff line number Diff line change @@ -143,6 +143,11 @@ function toImage(gd, opts) {
143
143
function convert ( ) {
144
144
return new Promise ( function ( resolve , reject ) {
145
145
var svg = toSVG ( clonedGd ) ;
146
+ var width = clonedGd . _fullLayout . width ;
147
+ var height = clonedGd . _fullLayout . height ;
148
+
149
+ Plotly . purge ( clonedGd )
150
+ document . body . removeChild ( clonedGd )
146
151
147
152
if ( format === 'svg' ) {
148
153
if ( imageDataOnly ) {
@@ -157,8 +162,8 @@ function toImage(gd, opts) {
157
162
158
163
svgToImg ( {
159
164
format : format ,
160
- width : clonedGd . _fullLayout . width ,
161
- height : clonedGd . _fullLayout . height ,
165
+ width : width ,
166
+ height : height ,
162
167
canvas : canvas ,
163
168
svg : svg ,
164
169
// ask svgToImg to return a Promise
@@ -167,14 +172,8 @@ function toImage(gd, opts) {
167
172
// compatibility
168
173
promise : true
169
174
} )
170
- . then ( function ( url ) {
171
- Plotly . purge ( clonedGd ) ;
172
- document . body . removeChild ( clonedGd ) ;
173
- resolve ( url ) ;
174
- } )
175
- . catch ( function ( err ) {
176
- reject ( err ) ;
177
- } ) ;
175
+ . then ( resolve )
176
+ . catch ( reject )
178
177
} ) ;
179
178
}
180
179
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ var Lib = require('@src/lib');
3
3
4
4
var d3 = require ( 'd3' ) ;
5
5
var createGraphDiv = require ( '../assets/create_graph_div' ) ;
6
+ var destroyGraphDiv = require ( '../assets/destroy_graph_div' ) ;
6
7
var fail = require ( '../assets/fail_test' ) ;
7
8
var customMatchers = require ( '../assets/custom_matchers' ) ;
8
9
var subplotMock = require ( '@mocks/multiple_subplots.json' ) ;
@@ -20,12 +21,7 @@ describe('Plotly.toImage', function() {
20
21
gd = createGraphDiv ( ) ;
21
22
} ) ;
22
23
23
- afterEach ( function ( ) {
24
- // make sure ALL graph divs are deleted,
25
- // even the ones generated by Plotly.toImage
26
- d3 . selectAll ( '.js-plotly-plot' ) . remove ( ) ;
27
- d3 . selectAll ( '#graph' ) . remove ( ) ;
28
- } ) ;
24
+ afterEach ( destroyGraphDiv )
29
25
30
26
function createImage ( url ) {
31
27
return new Promise ( function ( resolve , reject ) {
You can’t perform that action at this time.
0 commit comments