fix: [UI] Trending tags missing key

pull/8601/head
Jakub Onderka 2022-09-21 13:56:07 +02:00
parent f169d23be1
commit 23245157cd
2 changed files with 15 additions and 5 deletions

View File

@ -1,8 +1,10 @@
<?php
class ColourPaletteTool
{
// pass the number of distinct colours to receive an array of colours
/**
* @param int $count Pass the number of distinct colours to receive an array of colours
* @return array
*/
public function createColourPalette($count)
{
$interval = 1 / $count;
@ -13,6 +15,10 @@ class ColourPaletteTool
return $colours;
}
/**
* @param array $hsv
* @return string
*/
public function HSVtoRGB(array $hsv)
{
list($H, $S, $V) = $hsv;
@ -50,12 +56,16 @@ class ColourPaletteTool
return $this->convertToHex(array($R, $G, $B));
}
/**
* @param array $channels
* @return string
*/
public function convertToHex($channels)
{
$colour = '#';
foreach ($channels as $channel) {
$channel = strval(dechex(round($channel*255)));
if (strlen($channel) == 1) {
$channel = dechex(round($channel*255));
if (strlen($channel) === 1) {
$channel = '0' . $channel;
}
$colour .= $channel;

View File

@ -42,7 +42,6 @@ foreach ($allUniqueTags as $i => $tag) {
!empty($clusteredTags[$previousPeriod][$tag]['occurence']) ||
!empty($clusteredTags[$currentPeriod][$tag]['occurence'])
) {
$colorForTags[$tag] = $COLOR_PALETTE[$i];
$chartData[$tag] = [
$clusteredTags[$previousPeriod2][$tag]['occurence'] ?? 0,
$clusteredTags[$previousPeriod][$tag]['occurence'] ?? 0,
@ -50,6 +49,7 @@ foreach ($allUniqueTags as $i => $tag) {
];
$maxValue = max($maxValue, max($chartData[$tag]));
}
$colorForTags[$tag] = $COLOR_PALETTE[$i];
}
$canvasWidth = 600;
$canvasHeight = 150;