Skip to content

Commit

Permalink
Fix Dataset color if only single color is provided
Browse files Browse the repository at this point in the history
  • Loading branch information
mbourqui committed Feb 1, 2019
1 parent 4c7f939 commit 583da86
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Model/Dataset.php
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,15 @@ public function jsonSerialize()
$fieldOpacity = $field . 'Opacity';
if ($colors = $this->{$fieldColor}) {
$colorsOpacities = $this->getColorOpacity($colors, $this->{$fieldOpacity});
$renderedColors = array();
foreach ($colorsOpacities as $colorsOpacity) {
$dataset[$fieldColor][] = ChartColor::toColor($colorsOpacity[0], $colorsOpacity[1]);
$renderedColors[] = ChartColor::toColor($colorsOpacity[0], $colorsOpacity[1]);
}
if (count($renderedColors) == 1 ){
// Normalize to single value instead of array
$renderedColors = $renderedColors[0];
}
$dataset[$fieldColor] = $renderedColors;
}
}

Expand Down

0 comments on commit 583da86

Please sign in to comment.