Skip to content

Commit b0f6230

Browse files
committed
rm uselss canvas container in to-image
1 parent 68a6a96 commit b0f6230

File tree

2 files changed

+10
-19
lines changed

2 files changed

+10
-19
lines changed

src/plot_api/to_image.js

+5-9
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88

99
'use strict';
1010

11+
var isNumeric = require('fast-isnumeric');
12+
1113
var Plotly = require('../plotly');
14+
var Lib = require('../lib');
1215

13-
var isNumeric = require('fast-isnumeric');
1416

1517
/**
1618
* @param {object} gd figure Object
@@ -61,14 +63,8 @@ function toImage(gd, opts) {
6163
setTimeout(function() {
6264
var svg = Snapshot.toSVG(clonedGd);
6365

64-
var canvasContainer = document.createElement('div'),
65-
canvas = document.createElement('canvas');
66-
67-
// no need to attach canvas container to DOM
68-
69-
canvasContainer.appendChild(canvas);
70-
canvasContainer.id = Plotly.Lib.randstr();
71-
canvas.id = Plotly.Lib.randstr();
66+
var canvas = document.createElement('canvas');
67+
canvas.id = Lib.randstr();
7268

7369
Snapshot.svgToImg({
7470
format: opts.format,

src/snapshot/toimage.js

+5-10
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9-
/*eslint dot-notation: [2, {"allowPattern": "^catch$"}]*/
10-
119
'use strict';
1210

1311
var EventEmitter = require('events').EventEmitter;
12+
1413
var Plotly = require('../plotly');
14+
var Lib = require('../lib');
15+
1516

1617
/**
1718
* @param {object} gd figure Object
@@ -38,14 +39,8 @@ function toImage(gd, opts) {
3839
setTimeout(function() {
3940
var svg = Plotly.Snapshot.toSVG(clonedGd);
4041

41-
var canvasContainer = document.createElement('div'),
42-
canvas = document.createElement('canvas');
43-
44-
// no need to attach canvas container to DOM
45-
46-
canvasContainer.appendChild(canvas);
47-
canvasContainer.id = Plotly.Lib.randstr();
48-
canvas.id = Plotly.Lib.randstr();
42+
var canvas = document.createElement('canvas');
43+
canvas.id = Lib.randstr();
4944

5045
ev = Plotly.Snapshot.svgToImg({
5146
format: opts.format,

0 commit comments

Comments
 (0)