From a6fab50c20c20e747295f3298b8fdf333aabe81e Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 30 Jan 2020 18:35:00 +0100 Subject: [PATCH] Fix #3064 --- app/Generator/Chart/Basic/ChartJsGenerator.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/Generator/Chart/Basic/ChartJsGenerator.php b/app/Generator/Chart/Basic/ChartJsGenerator.php index 75d6f56074..6a8e160dcd 100644 --- a/app/Generator/Chart/Basic/ChartJsGenerator.php +++ b/app/Generator/Chart/Basic/ChartJsGenerator.php @@ -32,6 +32,7 @@ class ChartJsGenerator implements GeneratorInterface { /** * Constructor. + * * @codeCoverageIgnore */ public function __construct() @@ -118,7 +119,10 @@ class ChartJsGenerator implements GeneratorInterface public function multiSet(array $data): array { reset($data); - $first = current($data); + $first = current($data); + if (!is_array($first)) { + return []; + } $labels = is_array($first['entries']) ? array_keys($first['entries']) : []; $chartData = [ @@ -186,7 +190,7 @@ class ChartJsGenerator implements GeneratorInterface $chartData['datasets'][0]['data'][] = (float)app('steam')->positive((string)$value); $chartData['datasets'][0]['backgroundColor'][] = ChartColour::getColour($index); - $chartData['labels'][] = $key; + $chartData['labels'][] = $key; ++$index; }