Skip to content

Commit 710f312

Browse files
committed
rm circular dep in plot_image/to_image.js
1 parent 2382c04 commit 710f312

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/plot_api/to_image.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@ var isNumeric = require('fast-isnumeric');
1212

1313
var Plotly = require('../plotly');
1414
var Lib = require('../lib');
15-
var Snapshot = require('../snapshot');
1615

16+
var helpers = require('../snapshot/helpers');
17+
var clonePlot = require('../snapshot/cloneplot');
18+
var toSVG = require('../snapshot/tosvg');
19+
var svgToImg = require('../snapshot/svgtoimg');
1720

1821
/**
1922
* @param {object} gd figure Object
@@ -48,7 +51,7 @@ function toImage(gd, opts) {
4851
}
4952

5053
// 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});
5255
var clonedGd = clone.td;
5356

5457
// put the cloned div somewhere off screen before attaching to DOM
@@ -57,16 +60,16 @@ function toImage(gd, opts) {
5760
document.body.appendChild(clonedGd);
5861

5962
function wait() {
60-
var delay = Snapshot.getDelay(clonedGd._fullLayout);
63+
var delay = helpers.getDelay(clonedGd._fullLayout);
6164

6265
return new Promise(function(resolve, reject) {
6366
setTimeout(function() {
64-
var svg = Snapshot.toSVG(clonedGd);
67+
var svg = toSVG(clonedGd);
6568

6669
var canvas = document.createElement('canvas');
6770
canvas.id = Lib.randstr();
6871

69-
Snapshot.svgToImg({
72+
svgToImg({
7073
format: opts.format,
7174
width: clonedGd._fullLayout.width,
7275
height: clonedGd._fullLayout.height,
@@ -88,7 +91,7 @@ function toImage(gd, opts) {
8891
});
8992
}
9093

91-
var redrawFunc = Snapshot.getRedrawFunc(clonedGd);
94+
var redrawFunc = helpers.getRedrawFunc(clonedGd);
9295

9396
Plotly.plot(clonedGd, clone.data, clone.layout, clone.config)
9497
.then(redrawFunc)

0 commit comments

Comments
 (0)