Skip to content

Commit

Permalink
#64 [Dashboard] fix: make graphs color way less random
Browse files Browse the repository at this point in the history
  • Loading branch information
evarisk-micka committed Jun 28, 2023
1 parent cc78d2e commit c8f9b50
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion class/easycrmdashboard.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function getDataFromExtrafieldsAndDictionnary($title, $dico, $class = 'pr
$arrayNbDataByLabel[$i] = 0;
$array['labels'][$i] = [
'label' => $langs->transnoentities($data->label),
'color' => '#' . str_pad(dechex(rand(0x000000, 0xFFFFFF)), 6, 0, STR_PAD_LEFT)
'color' => $this->getColorRange($i)
];
$i++;
}
Expand All @@ -114,4 +114,16 @@ public function getDataFromExtrafieldsAndDictionnary($title, $dico, $class = 'pr

return $array;
}

/**
* get color range for key
*
* @param int $key Key to find in color array
* @return string
*/
public function getColorRange($key)
{
$colorArray = ['#f44336', '#e81e63', '#9c27b0', '#673ab7', '#3f51b5', '#2196f3', '#03a9f4', '#00bcd4', '#009688', '#4caf50', '#8bc34a', '#cddc39', '#ffeb3b', '#ffc107', '#ff9800', '#ff5722', '#795548', '#9e9e9e', '#607d8b'];
return $colorArray[$key % count($colorArray)];
}
}

0 comments on commit c8f9b50

Please sign in to comment.