File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -343,6 +343,15 @@ class PlotlyPanelCtrl extends MetricsPanelCtrl {
343343 } else {
344344 delete layout . zaxis ;
345345 delete layout . scene ;
346+
347+ // Check if the X axis should be a date
348+ if ( ! layout . xaxis . type || layout . xaxis . type === 'auto' ) {
349+ const mapping = _ . get ( this . cfg , 'traces[0].mapping.x' ) ;
350+ if ( mapping && mapping . indexOf ( 'time' ) >= 0 ) {
351+ layout . xaxis . type = 'date' ;
352+ }
353+ }
354+
346355 const isDate = layout . xaxis . type === 'date' ;
347356 layout . margin = {
348357 l : layout . yaxis . title ? 50 : 35 ,
@@ -352,6 +361,12 @@ class PlotlyPanelCtrl extends MetricsPanelCtrl {
352361 pad : 2 ,
353362 } ;
354363
364+ if ( isDate && ! layout . xaxis . range ) {
365+ const range = this . timeSrv . timeRange ( ) ;
366+ layout . xaxis . range = [ range . from . valueOf ( ) , range . to . valueOf ( ) ] ;
367+ console . log ( 'AUTO range' , range , layout . xaxis ) ;
368+ }
369+
355370 // get the css rule of grafana graph axis text
356371 const labelStyle = this . getCssRule ( 'div.flot-text' ) ;
357372 if ( labelStyle ) {
You can’t perform that action at this time.
0 commit comments