Skip to content
Snippets Groups Projects
Commit aa767fa7 authored by andileco's avatar andileco
Browse files

Incorporate 2879594 and add menu link to Charts API Example display on Config page.

parent c9df9f99
No related branches found
No related tags found
No related merge requests found
<?php <?php
/** /**
* @file * @file
* Install and update functions for the Charts module. * Install and update functions for the Charts module.
......
charts_api_example.display:
title: 'Charts API example'
description: 'Displays a chart rendered using the API.'
parent: system.admin_config_content
route_name: charts_api_example.display
...@@ -74,22 +74,27 @@ class C3ChartsRender implements ChartsRenderInterface { ...@@ -74,22 +74,27 @@ class C3ChartsRender implements ChartsRenderInterface {
array_unshift($categories, 'x'); array_unshift($categories, 'x');
array_push($c3Data, $categories); array_push($c3Data, $categories);
$chartData->setColumns($c3Data); $chartData->setColumns($c3Data);
} else { }
if ($options['type'] == 'column') { else if ($options['type'] == 'column') {
$chartData->setType('bar'); $chartData->setType('bar');
$chartAxis->setRotated(FALSE); $chartAxis->setRotated(FALSE);
array_unshift($categories, 'x'); array_unshift($categories, 'x');
array_push($c3Data, $categories); array_push($c3Data, $categories);
$chartData->setColumns($c3Data); $chartData->setColumns($c3Data);
} else { }
array_unshift($categories, 'x'); else if ($options['type'] == 'pie') {
array_push($c3Data, $categories); $chartData->setColumns($c3Data);
$chartData->setColumns($c3Data); }
} else {
array_unshift($categories, 'x');
array_push($c3Data, $categories);
$chartData->setColumns($c3Data);
} }
$chartData->types = $types; $chartData->types = $types;
$c3->setAxis($chartAxis); if ($options['type'] != 'pie') {
$c3->setAxis($chartAxis);
}
$chartColor = new ChartColor(); $chartColor = new ChartColor();
$seriesColors = []; $seriesColors = [];
......
...@@ -70,6 +70,10 @@ class ChartData implements \JsonSerializable { ...@@ -70,6 +70,10 @@ class ChartData implements \JsonSerializable {
public function jsonSerialize() { public function jsonSerialize() {
$vars = get_object_vars($this); $vars = get_object_vars($this);
if ($vars['type'] == 'pie') {
unset($vars['x']);
}
return $vars; return $vars;
} }
......
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