diff --git a/modules/charts_c3/charts_c3.module b/modules/charts_c3/charts_c3.module index d8ee65bd161155156d9e0e66fac72647d9053964..8d9928521c62897a41d4a14027ba19c8ee8cd72e 100644 --- a/modules/charts_c3/charts_c3.module +++ b/modules/charts_c3/charts_c3.module @@ -5,13 +5,26 @@ * Charts module integration with C3 library. */ +use Drupal\charts\Theme\ChartsInterface; + /** * Implements hook_charts_info(). */ function charts_c3_charts_info() { $info['c3'] = [ 'label' => t('C3 Charts'), - 'types' => ['area', 'bar', 'column', 'line', 'pie', 'scatter'], + 'types' => ['area', 'bar', 'column', 'line', 'pie', 'donut', 'scatter'], ]; return $info; } + +/** + * Implements hook_charts_type_info(). +*/ +function charts_c3_charts_type_info() { + $chart_types['donut'] = [ + 'label' => t('Donut'), + 'axis' => ChartsInterface::CHARTS_SINGLE_AXIS, + ]; + return $chart_types; +} diff --git a/modules/charts_c3/src/Charts/C3ChartsRender.php b/modules/charts_c3/src/Charts/C3ChartsRender.php index 9a40154eee36435e2008b99cf7d9a90df788baa7..e14c9057bde76dc88d60a20230d6c001ccd89e3a 100644 --- a/modules/charts_c3/src/Charts/C3ChartsRender.php +++ b/modules/charts_c3/src/Charts/C3ChartsRender.php @@ -82,7 +82,7 @@ class C3ChartsRender implements ChartsRenderInterface { array_push($c3Data, $categories); $chartData->setColumns($c3Data); } - else if ($options['type'] == 'pie') { + else if ($options['type'] == 'pie' || $options['type'] == 'donut') { $chartData->setColumns($c3Data); } else { @@ -92,7 +92,7 @@ class C3ChartsRender implements ChartsRenderInterface { } $chartData->types = $types; - if ($options['type'] != 'pie') { + if ($options['type'] != 'pie' && $options['type'] != 'donut') { $c3->setAxis($chartAxis); } diff --git a/modules/charts_c3/src/Settings/CThree/ChartData.php b/modules/charts_c3/src/Settings/CThree/ChartData.php index 0870037d29a36377e3bc83f299a6576780722374..31cd15a86e9175d49583a7f35f03bff70aba7f8f 100644 --- a/modules/charts_c3/src/Settings/CThree/ChartData.php +++ b/modules/charts_c3/src/Settings/CThree/ChartData.php @@ -70,7 +70,7 @@ class ChartData implements \JsonSerializable { public function jsonSerialize() { $vars = get_object_vars($this); - if ($vars['type'] == 'pie') { + if ($vars['type'] == 'pie' || $vars['type'] == 'donut') { unset($vars['x']); }