diff --git a/includes/charts.pages.inc b/includes/charts.pages.inc index 4fa38d06242eece9e808d65969f3d5a2195eb6bf..947d6a0cd23d0ed59858bc8ec7a54340c323e749 100644 --- a/includes/charts.pages.inc +++ b/includes/charts.pages.inc @@ -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, diff --git a/modules/charts_api_example/src/Controller/ChartsApiExample.php b/modules/charts_api_example/src/Controller/ChartsApiExample.php index 18e3d6b1f3c279e694109d0b70af3ccc17ab8e9b..6f80e9f9a14fc5b18d39b5863fbde050364a737e 100644 --- a/modules/charts_api_example/src/Controller/ChartsApiExample.php +++ b/modules/charts_api_example/src/Controller/ChartsApiExample.php @@ -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. diff --git a/modules/charts_blocks/src/Plugin/Block/ChartsBlock.php b/modules/charts_blocks/src/Plugin/Block/ChartsBlock.php index 7703275978626e2f28b4b59f859c4a12137d7f4b..b7222693223c0fee47bd4648b0b13eb62e878340 100644 --- a/modules/charts_blocks/src/Plugin/Block/ChartsBlock.php +++ b/modules/charts_blocks/src/Plugin/Block/ChartsBlock.php @@ -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'], diff --git a/modules/charts_google/src/Charts/GoogleChartsRender.php b/modules/charts_google/src/Charts/GoogleChartsRender.php index 9bdb63489a98794a0313e8ee7a8b001732492cda..b4df824b8372e9b8ad648d5b69513d11ad6c8038 100644 --- a/modules/charts_google/src/Charts/GoogleChartsRender.php +++ b/modules/charts_google/src/Charts/GoogleChartsRender.php @@ -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'])) { diff --git a/modules/charts_google/src/Plugin/chart/GoogleCharts.php b/modules/charts_google/src/Plugin/chart/GoogleCharts.php index 67d42cba708438127645b05ac281da2d7379dc2d..15751badf9d19a38d85c2dd404572a4d48950c98 100644 --- a/modules/charts_google/src/Plugin/chart/GoogleCharts.php +++ b/modules/charts_google/src/Plugin/chart/GoogleCharts.php @@ -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'])) { diff --git a/modules/charts_google/src/Settings/Google/GoogleOptions.php b/modules/charts_google/src/Settings/Google/GoogleOptions.php index fee23fefe1a63c0e0aec4585ae478fe45a3a1b97..885affa0b973f20b8426fc00d32c0183366dc1ac 100644 --- a/modules/charts_google/src/Settings/Google/GoogleOptions.php +++ b/modules/charts_google/src/Settings/Google/GoogleOptions.php @@ -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. * diff --git a/src/Form/ChartsConfigForm.php b/src/Form/ChartsConfigForm.php index 5609507bac79f0220c8d9fa17effcb89d26ed5e2..220be738e8b42c1404900e7e70ad70971559b44b 100644 --- a/src/Form/ChartsConfigForm.php +++ b/src/Form/ChartsConfigForm.php @@ -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'],