Skip to content

Commit

Permalink
Vue Cannot read length issue fixed
Browse files Browse the repository at this point in the history
Sometimes it comes 5 digit & this is causing error in charts
  • Loading branch information
EnesSacid-Buker committed Mar 1, 2023
1 parent 8a5eeea commit 5a4b326
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion app/Abstracts/Report.php
Expand Up @@ -222,7 +222,9 @@ public function getDonutChart($table_key)
foreach ($tmp_values as $id => $value) {
$labels[$id] = $this->row_names[$table_key][$id];

$colors[$id] = ($group == 'category') ? Category::withSubCategory()->find($id)?->colorHexCode : '#' . dechex(rand(0x000000, 0xFFFFFF));
$colors[$id] = ($group == 'category')
? Category::withSubCategory()->find($id)?->colorHexCode
: $this->randHexColor();

$values[$id] = round(($value * 100 / $total), 0);
}
Expand Down Expand Up @@ -642,4 +644,14 @@ public function getBasisField()
],
];
}

public function randHexColorPart(): string
{
return str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT);
}

public function randHexColor(): string
{
return '#' . $this->randHexColorPart() . $this->randHexColorPart() . $this->randHexColorPart();
}
}

0 comments on commit 5a4b326

Please sign in to comment.