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

Issue #2944087 by John Cook, andileco: Add polar plotting to Highcharts graphs

parent 4f9a33ec
No related branches found
No related tags found
No related merge requests found
...@@ -439,6 +439,19 @@ function charts_settings_form($form, $defaults = [], $field_options = [], $paren ...@@ -439,6 +439,19 @@ function charts_settings_form($form, $defaults = [], $field_options = [], $paren
], ],
]; ];
$form['display']['polar'] = [
'#title' => t('Transform cartesian charts into the polar coordinate system'),
'#type' => 'checkbox',
'#default_value' => $options['polar'],
'#parents' => array_merge($parents, ['polar']),
'#attributes' => [
'class' => [
'chart-type-checkbox',
'container-inline',
],
],
];
$form['display']['dimensions'] = [ $form['display']['dimensions'] = [
'#title' => t('Dimensions'), '#title' => t('Dimensions'),
'#theme_wrappers' => ['form_element'], '#theme_wrappers' => ['form_element'],
......
...@@ -72,7 +72,7 @@ class ChartsApiExample extends ControllerBase implements ContainerInjectionInter ...@@ -72,7 +72,7 @@ class ChartsApiExample extends ControllerBase implements ContainerInjectionInter
// If using C3, comment out the following two cases. // If using C3, comment out the following two cases.
case 'pie': case 'pie':
case 'donut': case 'donut':
} }
$build = [ $build = [
......
...@@ -138,6 +138,9 @@ class ChartsBlock extends BlockBase { ...@@ -138,6 +138,9 @@ class ChartsBlock extends BlockBase {
unset($form['display']['three_dimensional']['#parents']); unset($form['display']['three_dimensional']['#parents']);
$form['display']['three_dimensional']['#default_value'] = $this->configuration['three_dimensional']; $form['display']['three_dimensional']['#default_value'] = $this->configuration['three_dimensional'];
unset($form['display']['polar']['#parents']);
$form['display']['polar']['#default_value'] = $this->configuration['polar'];
unset($form['display']['legend_position']['#parents']); unset($form['display']['legend_position']['#parents']);
$form['display']['legend_position']['#default_value'] = $this->configuration['legend_position']; $form['display']['legend_position']['#default_value'] = $this->configuration['legend_position'];
...@@ -178,6 +181,7 @@ class ChartsBlock extends BlockBase { ...@@ -178,6 +181,7 @@ class ChartsBlock extends BlockBase {
$this->configuration['colors'] = $form_state->getValue('colors'); $this->configuration['colors'] = $form_state->getValue('colors');
$this->configuration['background'] = $form_state->getValue(['display','background']); $this->configuration['background'] = $form_state->getValue(['display','background']);
$this->configuration['three_dimensional'] = $form_state->getValue(['display','three_dimensional']); $this->configuration['three_dimensional'] = $form_state->getValue(['display','three_dimensional']);
$this->configuration['polar'] = $form_state->getValue(['display','polar']);
$this->configuration['tooltips'] = $form_state->getValue(['display','tooltips']); $this->configuration['tooltips'] = $form_state->getValue(['display','tooltips']);
$this->configuration['tooltips_use_html'] = $form_state->getValue('tooltips_use_html'); $this->configuration['tooltips_use_html'] = $form_state->getValue('tooltips_use_html');
$this->configuration['width'] = $form_state->getValue(['display','dimensions','width']); $this->configuration['width'] = $form_state->getValue(['display','dimensions','width']);
...@@ -211,6 +215,7 @@ class ChartsBlock extends BlockBase { ...@@ -211,6 +215,7 @@ class ChartsBlock extends BlockBase {
'colors'=>$this->configuration['colors'], 'colors'=>$this->configuration['colors'],
'background'=>$this->configuration['background'], 'background'=>$this->configuration['background'],
'three_dimensional'=>$this->configuration['three_dimensional'], 'three_dimensional'=>$this->configuration['three_dimensional'],
'polar'=>$this->configuration['polar'],
'tooltips'=>$this->configuration['tooltips'], 'tooltips'=>$this->configuration['tooltips'],
'tooltips_use_html'=>$this->configuration['tooltips_use_html'], 'tooltips_use_html'=>$this->configuration['tooltips_use_html'],
'width'=>$this->configuration['width'], 'width'=>$this->configuration['width'],
......
...@@ -32,6 +32,24 @@ If you use Composer to manage dependencies, edit "/composer.json" as follows. ...@@ -32,6 +32,24 @@ If you use Composer to manage dependencies, edit "/composer.json" as follows.
} }
} }
}, },
{
"type": "package",
"package": {
"name": "highcharts/more",
"version": "6.0.4",
"type": "drupal-library",
"extra": {
"installer-name": "highcharts_more"
},
"dist": {
"url": "https://code.highcharts.com/6.0.4/highcharts-more.js",
"type": "file"
},
"require": {
"composer/installers": "~1.0"
}
}
},
{ {
"type": "package", "type": "package",
"package": { "package": {
...@@ -87,5 +105,5 @@ If you use Composer to manage dependencies, edit "/composer.json" as follows. ...@@ -87,5 +105,5 @@ If you use Composer to manage dependencies, edit "/composer.json" as follows.
} }
} }
4. Run "composer require --prefer-dist highcharts/highcharts:6.0.4 highcharts/exporting:6.0.4 highcharts/export-data:6.0.4 highcharts/accessibility:6.0.4" 4. Run "composer require --prefer-dist highcharts/highcharts:6.0.4 highcharts/more:6.0.4 highcharts/exporting:6.0.4 highcharts/export-data:6.0.4 highcharts/accessibility:6.0.4"
- you should find that new directories have been created under "/libraries" - you should find that new directories have been created under "/libraries"
...@@ -16,6 +16,7 @@ highcharts: ...@@ -16,6 +16,7 @@ highcharts:
gpl-compatible: false gpl-compatible: false
js: js:
/libraries/highcharts/highcharts.js: {} /libraries/highcharts/highcharts.js: {}
/libraries/highcharts_more/highcharts-more.js: {}
/libraries/highcharts_exporting/exporting.js: {} /libraries/highcharts_exporting/exporting.js: {}
/libraries/highcharts_export-data/export-data.js: {} /libraries/highcharts_export-data/export-data.js: {}
/libraries/highcharts_accessibility/accessibility.js: {} /libraries/highcharts_accessibility/accessibility.js: {}
......
...@@ -84,6 +84,11 @@ class HighchartsChartsRender implements ChartsRenderInterface { ...@@ -84,6 +84,11 @@ class HighchartsChartsRender implements ChartsRenderInterface {
$chart->setBackgroundColor($options['background']); $chart->setBackgroundColor($options['background']);
} }
// Set polar plotting.
if (isset($options['polar'])) {
$chart->setPolar($options['polar']);
}
// Set title position. // Set title position.
if (isset($options['title_position'])) { if (isset($options['title_position'])) {
if ($options['title_position'] == 'in') { if ($options['title_position'] == 'in') {
...@@ -192,7 +197,6 @@ class HighchartsChartsRender implements ChartsRenderInterface { ...@@ -192,7 +197,6 @@ class HighchartsChartsRender implements ChartsRenderInterface {
$highchart->setChart($chart); $highchart->setChart($chart);
$highchart->setTitle($chartTitle); $highchart->setTitle($chartTitle);
$highchart->setAxisX($chartXaxis); $highchart->setAxisX($chartXaxis);
/* $highchart->yAxis = $yAxes; */
$highchart->setTooltip($chartTooltip); $highchart->setTooltip($chartTooltip);
$highchart->setPlotOptions($plotOptions); $highchart->setPlotOptions($plotOptions);
$highchart->setCredits($chartCredits); $highchart->setCredits($chartCredits);
......
...@@ -91,6 +91,11 @@ class Highchart extends AbstractChart { ...@@ -91,6 +91,11 @@ class Highchart extends AbstractChart {
$chart->setBackgroundColor($options['background']); $chart->setBackgroundColor($options['background']);
} }
// Set polar plotting.
if (isset($options['polar'])) {
$chart->setPolar($options['polar']);
}
// Set title position. // Set title position.
if ($options['title_position'] == 'in') { if ($options['title_position'] == 'in') {
$chartTitle->setVerticalAlign('middle'); $chartTitle->setVerticalAlign('middle');
......
...@@ -11,6 +11,7 @@ class Chart implements \JsonSerializable { ...@@ -11,6 +11,7 @@ class Chart implements \JsonSerializable {
private $width = NULL; private $width = NULL;
private $height = NULL; private $height = NULL;
private $backgroundColor; private $backgroundColor;
private $polar = NULL;
/** /**
* Get Type. * Get Type.
...@@ -102,6 +103,26 @@ class Chart implements \JsonSerializable { ...@@ -102,6 +103,26 @@ class Chart implements \JsonSerializable {
$this->backgroundColor = $backgroundColor; $this->backgroundColor = $backgroundColor;
} }
/**
* Get Polar
*
* @return bool
* Polar.
*/
public function getPolar() {
return $this->polar;
}
/**
* Set Polar.
*
* @param bool $polar
* Polar.
*/
public function setPolar($polar) {
$this->polar = $polar;
}
/** /**
* Json Serialize. * Json Serialize.
* *
......
...@@ -353,6 +353,19 @@ class ChartsConfigForm extends ConfigFormBase { ...@@ -353,6 +353,19 @@ class ChartsConfigForm extends ConfigFormBase {
], ],
]; ];
$form['display']['polar'] = [
'#title' => t('Transform cartesian charts into the polar coordinate system'),
'#type' => 'checkbox',
'#default_value' => $options['polar'],
'#parents' => array_merge($parents, ['polar']),
'#attributes' => [
'class' => [
'chart-type-checkbox',
'container-inline',
],
],
];
$form['display']['dimensions'] = [ $form['display']['dimensions'] = [
'#title' => $this->t('Dimensions'), '#title' => $this->t('Dimensions'),
'#theme_wrappers' => ['form_element'], '#theme_wrappers' => ['form_element'],
......
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