protected function Chartjs::populateChartType in Charts 8.4
Same name and namespace in other branches
- 5.0.x modules/charts_chartjs/src/Plugin/chart/Library/Chartjs.php \Drupal\charts_chartjs\Plugin\chart\Library\Chartjs::populateChartType()
Outputs a type that can be used by Chart.js.
Parameters
array $element: The given element.
Return value
string The generated type.
3 calls to Chartjs::populateChartType()
- Chartjs::populateCategories in modules/
charts_chartjs/ src/ Plugin/ chart/ Library/ Chartjs.php - Populate categories.
- Chartjs::populateDatasets in modules/
charts_chartjs/ src/ Plugin/ chart/ Library/ Chartjs.php - Populate Dataset.
- Chartjs::populateOptions in modules/
charts_chartjs/ src/ Plugin/ chart/ Library/ Chartjs.php - Populate options.
File
- modules/
charts_chartjs/ src/ Plugin/ chart/ Library/ Chartjs.php, line 365
Class
- Chartjs
- Define a concrete class for a Chart.
Namespace
Drupal\charts_chartjs\Plugin\chart\LibraryCode
protected function populateChartType(array $element) {
switch ($element['#chart_type']) {
case 'bar':
$type = 'horizontalBar';
break;
case 'column':
$type = 'bar';
break;
case 'area':
case 'spline':
$type = 'line';
break;
case 'donut':
$type = 'doughnut';
break;
case 'gauge':
// Setting this, but gauge is currently not supported by Chart.js.
$type = 'gauge';
break;
default:
$type = $element['#chart_type'];
break;
}
if (isset($element['display']['polar']) && $element['display']['polar'] == 1) {
$type = 'radar';
}
return $type;
}