Skip to content

Commit 7895727

Browse files
committed
Bit of suggested code refactoring
1 parent 2470532 commit 7895727

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/traces/image/plot.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,14 @@ module.exports = function plot(gd, plotinfo, cdimage, imageLayer) {
184184
if(fastImage) {
185185
href = trace.source;
186186
// Flip the SVG image as needed (around the proper center location)
187-
var axisScale = [(xa.range[0] < xa.range[1]) ? 1 : -1, (ya.range[0] < ya.range[1]) ? -1 : 1];
188-
var trans = '';
189-
trans += strTranslate(left + imageWidth / 2 + 'px', top + imageHeight / 2 + 'px');
190-
trans += 'scale(' + axisScale[0] + ',' + axisScale[1] + ')';
191-
trans += strTranslate(-left - imageWidth / 2 + 'px', -top - imageHeight / 2 + 'px');
192-
localStyle += 'transform:' + trans + ';';
187+
var axisScale = [
188+
(xa.range[0] < xa.range[1]) ? 1 : -1,
189+
(ya.range[0] < ya.range[1]) ? -1 : 1
190+
];
191+
localStyle += 'transform:' +
192+
strTranslate(left + imageWidth / 2 + 'px', top + imageHeight / 2 + 'px') +
193+
'scale(' + axisScale[0] + ',' + axisScale[1] + ')' +
194+
strTranslate(-left - imageWidth / 2 + 'px', -top - imageHeight / 2 + 'px') + ';';
193195
} else {
194196
var context = trace._canvas.el.getContext('2d');
195197
var data = context.getImageData(0, 0, w, h).data;

0 commit comments

Comments
 (0)