Closed saeedvir closed 7 months ago
You can do it for yourself with a simple class:
class RandomColor
{
public static function getRandomColors(int $count): array
{
$array = [];
for ($i = 1; $i <= $count; $i++) {
$array[] = self::getRandomColor();
}
return $array;
}
private static function getRandomColor(): string
{
$color = '#';
for ($i = 1; $i <= 6; $i++) {
$color .= self::getRandomColorElement();
}
return $color;
}
private static function getRandomColorElement(): string
{
$colors = ['1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'];
return $colors[array_rand($colors)];
}
}
Then use it:
->setColors(RandomColor::getRandomColors(5))
As setColors()
allows to add your custom array in any order, I think this is out of the scope for the package.
add random colors or shuffle colors in config file
public function setColors(array $colors) :LarapexChart