Skip to content
Snippets Groups Projects
Commit daa16b02 authored by Daniel Cothran's avatar Daniel Cothran
Browse files

Issue #2947190 by zinalacina, andileco: C3 Charts donut Chart Doesn't Render Properly

parent 242ef85b
No related branches found
No related tags found
No related merge requests found
......@@ -45,7 +45,7 @@ class C3 extends AbstractChart {
$attachmentCount = count($attachmentDisplayOptions);
$noAttachmentDisplays = $attachmentCount === 0;
$types = [];
for ($i = 1; $i <= $attachmentCount; $i++) {
if ($attachmentDisplayOptions[$i - 1]['style']['options']['type'] == 'column') {
$types[$seriesData[$i]['name']] = 'bar';
......
......@@ -332,7 +332,7 @@ class Google extends AbstractChart {
$googleOptions->setHorizontalAxes($hAxes);
if (in_array('donut', $chartSelected)) {
$googleOptions->pieHole = '0.5';
$googleOptions->pieHole = '0.25';
}
$chartArea = new ChartArea();
......@@ -357,10 +357,29 @@ class Google extends AbstractChart {
$chartArea->setPaddingLeft($options['chart_area']['left']);
}
$seriesCount = count($seriesData);
$categoriesCount = count($seriesData[0]['data']);
$seriesColors = [];
for ($i = 0; $i < count($seriesData); $i++) {
$seriesColor = $seriesData[$i]['color'];
array_push($seriesColors, $seriesColor);
if ($options['type'] == 'pie' || $options['type'] == 'donut') {
if ($seriesCount > 1) {
for ($i = 0; $i < $seriesCount; $i++) {
$seriesColor = $seriesData[$i]['color'];
array_push($seriesColors, $seriesColor);
}
}
else {
for ($i = 0; $i < $categoriesCount; $i++) {
// Use default colors if only one series.
$seriesColor = $options['colors'][$i];
array_push($seriesColors, $seriesColor);
}
}
} else {
for ($i = 0; $i < $seriesCount; $i++) {
$seriesColor = $seriesData[$i]['color'];
array_push($seriesColors, $seriesColor);
}
}
$googleOptions->setColors($seriesColors);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment