@@ -320,7 +320,8 @@ public function getChartUrl($directUrl = true)
320
320
321
321
foreach ($ this ->getAllSeries () as $ index => $ serie ) {
322
322
$ thisdataarray = $ serie ;
323
- for ($ j = 0 ; $ j < sizeof ($ thisdataarray ); $ j ++) {
323
+ $ count = count ($ thisdataarray );
324
+ for ($ j = 0 ; $ j < $ count ; $ j ++) {
324
325
$ currentvalue = $ thisdataarray [$ j ];
325
326
if (is_numeric ($ currentvalue )) {
326
327
$ ylocation = $ yorigin + $ currentvalue ;
@@ -341,45 +342,13 @@ public function getChartUrl($directUrl = true)
341
342
342
343
$ valueBuffer = [];
343
344
344
- if (sizeof ($ this ->_axisLabels ) > 0 ) {
345
+ if (count ($ this ->_axisLabels ) > 0 ) {
345
346
$ params ['chxt ' ] = implode (', ' , array_keys ($ this ->_axisLabels ));
346
347
$ indexid = 0 ;
347
348
foreach ($ this ->_axisLabels as $ idx => $ labels ) {
348
349
if ($ idx == 'x ' ) {
349
- /**
350
- * Format date
351
- */
352
- foreach ($ this ->_axisLabels [$ idx ] as $ _index => $ _label ) {
353
- if ($ _label != '' ) {
354
- $ period = new \DateTime ($ _label , new \DateTimeZone ($ timezoneLocal ));
355
- switch ($ this ->getDataHelper ()->getParam ('period ' )) {
356
- case '24h ' :
357
- $ this ->_axisLabels [$ idx ][$ _index ] = $ this ->_localeDate ->formatDateTime (
358
- $ period ->setTime ($ period ->format ('H ' ), 0 , 0 ),
359
- \IntlDateFormatter::NONE ,
360
- \IntlDateFormatter::SHORT
361
- );
362
- break ;
363
- case '7d ' :
364
- case '1m ' :
365
- $ this ->_axisLabels [$ idx ][$ _index ] = $ this ->_localeDate ->formatDateTime (
366
- $ period ,
367
- \IntlDateFormatter::SHORT ,
368
- \IntlDateFormatter::NONE
369
- );
370
- break ;
371
- case '1y ' :
372
- case '2y ' :
373
- $ this ->_axisLabels [$ idx ][$ _index ] = date ('m/Y ' , strtotime ($ _label ));
374
- break ;
375
- }
376
- } else {
377
- $ this ->_axisLabels [$ idx ][$ _index ] = '' ;
378
- }
379
- }
380
-
350
+ $ this ->formatAxisLabelDate ($ idx , $ timezoneLocal );
381
351
$ tmpstring = implode ('| ' , $ this ->_axisLabels [$ idx ]);
382
-
383
352
$ valueBuffer [] = $ indexid . ":| " . $ tmpstring ;
384
353
} elseif ($ idx == 'y ' ) {
385
354
$ valueBuffer [] = $ indexid . ":| " . implode ('| ' , $ yLabels );
@@ -407,6 +376,46 @@ public function getChartUrl($directUrl = true)
407
376
}
408
377
}
409
378
379
+ /**
380
+ * Format dates for axis labels
381
+ *
382
+ * @param string $idx
383
+ * @param string $timezoneLocal
384
+ *
385
+ * @return void
386
+ */
387
+ private function formatAxisLabelDate ($ idx , $ timezoneLocal )
388
+ {
389
+ foreach ($ this ->_axisLabels [$ idx ] as $ _index => $ _label ) {
390
+ if ($ _label != '' ) {
391
+ $ period = new \DateTime ($ _label , new \DateTimeZone ($ timezoneLocal ));
392
+ switch ($ this ->getDataHelper ()->getParam ('period ' )) {
393
+ case '24h ' :
394
+ $ this ->_axisLabels [$ idx ][$ _index ] = $ this ->_localeDate ->formatDateTime (
395
+ $ period ->setTime ($ period ->format ('H ' ), 0 , 0 ),
396
+ \IntlDateFormatter::NONE ,
397
+ \IntlDateFormatter::SHORT
398
+ );
399
+ break ;
400
+ case '7d ' :
401
+ case '1m ' :
402
+ $ this ->_axisLabels [$ idx ][$ _index ] = $ this ->_localeDate ->formatDateTime (
403
+ $ period ,
404
+ \IntlDateFormatter::SHORT ,
405
+ \IntlDateFormatter::NONE
406
+ );
407
+ break ;
408
+ case '1y ' :
409
+ case '2y ' :
410
+ $ this ->_axisLabels [$ idx ][$ _index ] = date ('m/Y ' , strtotime ($ _label ));
411
+ break ;
412
+ }
413
+ } else {
414
+ $ this ->_axisLabels [$ idx ][$ _index ] = '' ;
415
+ }
416
+ }
417
+ }
418
+
410
419
/**
411
420
* Get rows data
412
421
*
0 commit comments