@@ -324,17 +324,36 @@ class PlotlyPanelCtrl extends MetricsPanelCtrl {
324324 layout . yaxis = { } ;
325325 }
326326
327+ // Fixed scales
328+ if ( this . cfg . fixScale ) {
329+ if ( 'x' === this . cfg . fixScale ) {
330+ layout . yaxis . scaleanchor = 'x' ;
331+ }
332+ else if ( 'y' === this . cfg . fixScale ) {
333+ layout . xaxis . scaleanchor = 'y' ;
334+ }
335+ else if ( 'z' === this . cfg . fixScale ) {
336+ layout . xaxis . scaleanchor = 'z' ;
337+ layout . yaxis . scaleanchor = 'z' ;
338+ }
339+ }
340+
327341 if ( this . is3d ( ) ) {
328342 if ( ! layout . zaxis ) {
329343 layout . zaxis = { } ;
330344 }
331345
332- // 3d uses 'scene' for the axis names
346+ // 3d uses 'scene' for the axis
333347 layout . scene = {
334- xaxis : { title : layout . xaxis . title } ,
335- yaxis : { title : layout . yaxis . title } ,
336- zaxis : { title : layout . zaxis . title } ,
348+ xaxis : layout . xaxis ,
349+ yaxis : layout . yaxis ,
350+ zaxis : layout . zaxis ,
337351 } ;
352+
353+ delete layout . xaxis ;
354+ delete layout . yaxis ;
355+ delete layout . zaxis ;
356+
338357 layout . margin = {
339358 l : 0 ,
340359 r : 0 ,
@@ -363,10 +382,10 @@ class PlotlyPanelCtrl extends MetricsPanelCtrl {
363382 pad : 2 ,
364383 } ;
365384
385+ // Set the range to the query window
366386 if ( isDate && ! layout . xaxis . range ) {
367387 const range = this . timeSrv . timeRange ( ) ;
368388 layout . xaxis . range = [ range . from . valueOf ( ) , range . to . valueOf ( ) ] ;
369- console . log ( 'AUTO range' , range , layout . xaxis ) ;
370389 }
371390
372391 // get the css rule of grafana graph axis text
@@ -392,19 +411,7 @@ class PlotlyPanelCtrl extends MetricsPanelCtrl {
392411 // Set the second axis
393412 layout . yaxis2 = PlotlyPanelCtrl . yaxis2 ;
394413 }
395-
396- if ( this . cfg . fixScale ) {
397- if ( 'x' === this . cfg . fixScale ) {
398- layout . yaxis . scaleanchor = 'x' ;
399- }
400- else if ( 'y' === this . cfg . fixScale ) {
401- layout . xaxis . scaleanchor = 'y' ;
402- }
403- else if ( 'z' === this . cfg . fixScale ) {
404- layout . xaxis . scaleanchor = 'z' ;
405- layout . yaxis . scaleanchor = 'z' ;
406- }
407- }
414+ console . log ( 'LAYOUT' , layout ) ;
408415 return layout ;
409416 }
410417
0 commit comments