@@ -139,7 +139,19 @@ module.exports = function plot(gd, plotinfo, cdimage, imageLayer) {
139139 // Pixelated image rendering
140140 // http://phrogz.net/tmp/canvas_image_zoom.html
141141 // https://developer.mozilla.org/en-US/docs/Web/CSS/image-rendering
142- var initialStyle = 'image-rendering: optimizeSpeed; image-rendering: -moz-crisp-edges; image-rendering: -o-crisp-edges; image-rendering: -webkit-optimize-contrast; image-rendering: optimize-contrast; image-rendering: crisp-edges; image-rendering: pixelated;' ;
142+ var style = 'image-rendering: optimizeSpeed; image-rendering: -moz-crisp-edges; image-rendering: -o-crisp-edges; image-rendering: -webkit-optimize-contrast; image-rendering: optimize-contrast; image-rendering: crisp-edges; image-rendering: pixelated;' ;
143+ if ( fastImage ) {
144+ // Flip the SVG image as needed (around the proper center location)
145+ var axisScale = [
146+ ( xa . range [ 0 ] < xa . range [ 1 ] ) ? 1 : - 1 ,
147+ ( ya . range [ 0 ] < ya . range [ 1 ] ) ? - 1 : 1
148+ ] ;
149+ style += 'transform:' +
150+ strTranslate ( left + imageWidth / 2 + 'px' , top + imageHeight / 2 + 'px' ) +
151+ 'scale(' + axisScale [ 0 ] + ',' + axisScale [ 1 ] + ')' +
152+ strTranslate ( - left - imageWidth / 2 + 'px' , - top - imageHeight / 2 + 'px' ) + ';' ;
153+ }
154+ image3 . attr ( 'style' , style ) ;
143155
144156 var p = new Promise ( function ( resolve ) {
145157 if ( trace . _hasZ ) {
@@ -175,23 +187,13 @@ module.exports = function plot(gd, plotinfo, cdimage, imageLayer) {
175187 }
176188 } )
177189 . then ( function ( ) {
178- var href , canvas , localStyle ;
179- localStyle = initialStyle ;
190+ var href , canvas ;
180191 if ( trace . _hasZ ) {
181192 canvas = drawMagnifiedPixelsOnCanvas ( function ( i , j ) { return z [ j ] [ i ] ; } ) ;
182193 href = canvas . toDataURL ( 'image/png' ) ;
183194 } else if ( trace . _hasSource ) {
184195 if ( fastImage ) {
185196 href = trace . source ;
186- // Flip the SVG image as needed (around the proper center location)
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' ) + ';' ;
195197 } else {
196198 var context = trace . _canvas . el . getContext ( '2d' ) ;
197199 var data = context . getImageData ( 0 , 0 , w , h ) . data ;
@@ -213,8 +215,7 @@ module.exports = function plot(gd, plotinfo, cdimage, imageLayer) {
213215 height : imageHeight ,
214216 width : imageWidth ,
215217 x : left ,
216- y : top ,
217- style : localStyle
218+ y : top
218219 } ) ;
219220 } ) ;
220221
0 commit comments