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

Issue #2942129 by pinchy: Adding "is3D" option for 3D Google Charts integration

parent 7ac27f20
No related branches found
No related tags found
No related merge requests found
......@@ -422,6 +422,19 @@ function charts_settings_form($form, $defaults = [], $field_options = [], $paren
'#parents' => array_merge($parents, ['background']),
];
$form['display']['three_dimensional'] = [
'#title' => t('Make chart three-dimensional (3D)'),
'#type' => 'checkbox',
'#default_value' => $options['three_dimensional'],
'#parents' => array_merge($parents, ['three_dimensional']),
'#attributes' => [
'class' => [
'chart-type-checkbox',
'container-inline',
],
],
];
$form['display']['dimensions'] = [
'#title' => t('Dimensions'),
'#theme_wrappers' => ['form_element'],
......@@ -668,6 +681,7 @@ function charts_default_settings() {
'legend_position' => 'right',
'colors' => charts_default_colors(),
'background' => '',
'three_dimensional' => FALSE,
'tooltips' => TRUE,
'tooltips_use_html' => FALSE,
'width' => NULL,
......
......@@ -44,6 +44,7 @@ class ChartsApiExample extends ControllerBase implements ContainerInjectionInter
'yaxis_title' => $this->t('Y-Axis'),
'yaxis_min' => '',
'yaxis_max' => '',
'three_dimensional' => FALSE,
];
// Sample data format.
......
......@@ -134,6 +134,9 @@ class ChartsBlock extends BlockBase {
unset($form['display']['background']['#parents']);
$form['display']['background']['#default_value'] = $this->configuration['background'];
unset($form['display']['three_dimensional']['#parents']);
$form['display']['three_dimensional']['#default_value'] = $this->configuration['three_dimensional'];
unset($form['display']['legend_position']['#parents']);
$form['display']['legend_position']['#default_value'] = $this->configuration['legend_position'];
......@@ -174,6 +177,7 @@ class ChartsBlock extends BlockBase {
$this->configuration['legend_position'] = $form_state->getValue(['display','legend_position']);
$this->configuration['colors'] = $form_state->getValue('colors');
$this->configuration['background'] = $form_state->getValue(['display','background']);
$this->configuration['three_dimensional'] = $form_state->getValue(['display','three_dimensional']);
$this->configuration['tooltips'] = $form_state->getValue(['display','tooltips']);
$this->configuration['tooltips_use_html'] = $form_state->getValue('tooltips_use_html');
$this->configuration['width'] = $form_state->getValue(['display','dimensions','width']);
......@@ -206,6 +210,7 @@ class ChartsBlock extends BlockBase {
'legend_position'=>$this->configuration['legend_position'],
'colors'=>$this->configuration['colors'],
'background'=>$this->configuration['background'],
'three_dimensional'=>$this->configuration['three_dimensional'],
'tooltips'=>$this->configuration['tooltips'],
'tooltips_use_html'=>$this->configuration['tooltips_use_html'],
'width'=>$this->configuration['width'],
......
......@@ -325,6 +325,11 @@ class GoogleChartsRender implements ChartsRenderInterface {
$googleOptions->setHeight($options['height']);
}
// Determines if chart is three-dimensional.
if (isset($options['three_dimensional'])) {
$googleOptions->setThreeDimensional($options['three_dimensional']);
}
// 'legend' can be a string (for position) or an array with legend
// properties: [position: 'top', textStyle: [color: 'blue', fontSize: 16]].
if (isset($options['legend'])) {
......
......@@ -334,6 +334,11 @@ class GoogleCharts extends AbstractChart {
$googleOptions->setHeight($options['height']);
}
// Determines if chart is three-dimensional.
if (isset($options['three_dimensional'])) {
$googleOptions->setThreeDimensional($options['three_dimensional']);
}
// 'legend' can be a string (for position) or an array with legend
// properties: [position: 'top', textStyle: [color: 'blue', fontSize: 16]].
if (isset($options['legend'])) {
......
......@@ -100,6 +100,13 @@ class GoogleOptions implements \JsonSerializable {
*/
private $height;
/**
* 3D chart option.
*
* @var mixed
*/
private $is3D;
/**
* Gets the title of the Material Chart. Only Material Charts support titles.
*
......@@ -367,6 +374,26 @@ class GoogleOptions implements \JsonSerializable {
$this->height = $height;
}
/**
* Gets three-dimensional chart option.
*
* @return mixed
* 3D option.
*/
public function getThreeDimensional() {
return $this->is3D;
}
/**
* Sets three-dimensional chart option.
*
* @param mixed $threeDimensional
* 3D option.
*/
public function setThreeDimensional($is3D) {
$this->is3D = $is3D;
}
/**
* Json Serialize.
*
......
......@@ -115,6 +115,7 @@ class ChartsConfigForm extends ConfigFormBase {
'legend_position' => 'right',
'colors' => $this->chartsDefaultColors(),
'background' => '',
'three_dimensional' => FALSE,
'tooltips' => TRUE,
'tooltips_use_html' => FALSE,
'width' => NULL,
......@@ -339,6 +340,19 @@ class ChartsConfigForm extends ConfigFormBase {
'#parents' => array_merge($parents, ['background']),
];
$form['display']['three_dimensional'] = [
'#title' => t('Make chart three-dimensional (3D)'),
'#type' => 'checkbox',
'#default_value' => $options['three_dimensional'],
'#parents' => array_merge($parents, ['three_dimensional']),
'#attributes' => [
'class' => [
'chart-type-checkbox',
'container-inline',
],
],
];
$form['display']['dimensions'] = [
'#title' => $this->t('Dimensions'),
'#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