@@ -376,23 +376,11 @@ protected function generateResponse(array &$form, AppInterface $app, string $met
376376 $ form ['#attached ' ]['drupalSettings ' ]['analytics ' ]['metric ' ] = $ form ['controls ' ]['metrics ' ]['#options ' ][$ metric ];
377377 $ form ['#attached ' ]['drupalSettings ' ]['analytics ' ]['timestamps ' ] = $ analytics ['TimeUnit ' ];
378378 $ form ['#attached ' ]['drupalSettings ' ]['analytics ' ]['values ' ] = $ analytics ['stats ' ]['data ' ][0 ]['metric ' ][0 ]['values ' ];
379- $ form ['#attached ' ]['drupalSettings ' ]['analytics ' ]['skip_zero_values ' ] = TRUE ;
379+ $ form ['#attached ' ]['drupalSettings ' ]['analytics ' ]['skip_zero_values ' ] = FALSE ;
380380 $ form ['#attached ' ]['drupalSettings ' ]['analytics ' ]['language ' ] = $ this ->currentUser ()
381381 ->getPreferredLangcode ();
382382 $ form ['#attached ' ]['drupalSettings ' ]['analytics ' ]['chart_container ' ] = $ form ['chart ' ]['#attributes ' ]['id ' ];
383383
384- $ view_window_min = $ view_window_max = 0 ;
385- if (array_key_exists ('TimeUnit ' , $ analytics ) && is_array ($ analytics ['TimeUnit ' ])) {
386- for ($ i = count ($ analytics ['TimeUnit ' ]) - 1 ; $ i > 0 ; $ i --) {
387- if ($ analytics ['stats ' ]['data ' ][0 ]['metric ' ][0 ]['values ' ][$ i ] !== 0 ) {
388- $ view_window_min = $ i ;
389- }
390- if ($ view_window_max === 0 && $ analytics ['stats ' ]['data ' ][0 ]['metric ' ][0 ]['values ' ][$ i ] !== 0 ) {
391- $ view_window_max = $ i ;
392- }
393- }
394- }
395-
396384 // Visualization options for Google Charts draw() function,
397385 // must be JSON encoded before passing.
398386 // @see: https://developers.google.com/chart/interactive/docs/gallery/linechart#configuration-options
@@ -402,8 +390,8 @@ protected function generateResponse(array &$form, AppInterface $app, string $met
402390 'interpolateNulls ' => 'true ' ,
403391 'hAxis ' => [
404392 'viewWindow ' => [
405- 'min ' => $ analytics ['TimeUnit ' ][ $ view_window_min ] ,
406- 'max ' => $ analytics ['TimeUnit ' ][ $ view_window_max ] ,
393+ 'min ' => ! empty ( $ analytics ['TimeUnit ' ]) ? min ( $ analytics [ ' TimeUnit ' ]) : 0 ,
394+ 'max ' => ! empty ( $ analytics ['TimeUnit ' ]) ? max ( $ analytics [ ' TimeUnit ' ]) : 0 ,
407395 ],
408396 'gridlines ' => [
409397 'count ' => -1 ,
0 commit comments