@@ -12,8 +12,11 @@ var isNumeric = require('fast-isnumeric');
12
12
13
13
var Plotly = require ( '../plotly' ) ;
14
14
var Lib = require ( '../lib' ) ;
15
- var Snapshot = require ( '../snapshot' ) ;
16
15
16
+ var helpers = require ( '../snapshot/helpers' ) ;
17
+ var clonePlot = require ( '../snapshot/cloneplot' ) ;
18
+ var toSVG = require ( '../snapshot/tosvg' ) ;
19
+ var svgToImg = require ( '../snapshot/svgtoimg' ) ;
17
20
18
21
/**
19
22
* @param {object } gd figure Object
@@ -48,7 +51,7 @@ function toImage(gd, opts) {
48
51
}
49
52
50
53
// first clone the GD so we can operate in a clean environment
51
- var clone = Snapshot . clone ( gd , { format : 'png' , height : opts . height , width : opts . width } ) ;
54
+ var clone = clonePlot ( gd , { format : 'png' , height : opts . height , width : opts . width } ) ;
52
55
var clonedGd = clone . td ;
53
56
54
57
// put the cloned div somewhere off screen before attaching to DOM
@@ -57,16 +60,16 @@ function toImage(gd, opts) {
57
60
document . body . appendChild ( clonedGd ) ;
58
61
59
62
function wait ( ) {
60
- var delay = Snapshot . getDelay ( clonedGd . _fullLayout ) ;
63
+ var delay = helpers . getDelay ( clonedGd . _fullLayout ) ;
61
64
62
65
return new Promise ( function ( resolve , reject ) {
63
66
setTimeout ( function ( ) {
64
- var svg = Snapshot . toSVG ( clonedGd ) ;
67
+ var svg = toSVG ( clonedGd ) ;
65
68
66
69
var canvas = document . createElement ( 'canvas' ) ;
67
70
canvas . id = Lib . randstr ( ) ;
68
71
69
- Snapshot . svgToImg ( {
72
+ svgToImg ( {
70
73
format : opts . format ,
71
74
width : clonedGd . _fullLayout . width ,
72
75
height : clonedGd . _fullLayout . height ,
@@ -88,7 +91,7 @@ function toImage(gd, opts) {
88
91
} ) ;
89
92
}
90
93
91
- var redrawFunc = Snapshot . getRedrawFunc ( clonedGd ) ;
94
+ var redrawFunc = helpers . getRedrawFunc ( clonedGd ) ;
92
95
93
96
Plotly . plot ( clonedGd , clone . data , clone . layout , clone . config )
94
97
. then ( redrawFunc )
0 commit comments