diff --git a/includes/charts.pages.inc b/includes/charts.pages.inc index 0ce818baafa2bb10ac943411ad24d499971991d7..4e0085e51f06b6e6c8bf836db2433fecf8c4dc15 100644 --- a/includes/charts.pages.inc +++ b/includes/charts.pages.inc @@ -220,7 +220,12 @@ function charts_settings_form($form, $defaults = array(), $field_options = array $charts_info = charts_info(); $library_options = array(); foreach ($charts_info as $library_name => $library_info) { - $library_options[$library_name] = $library_info['label']; + if (\Drupal::moduleHandler()->moduleExists($charts_info[$library_name]['module'])) { + $library_options[$library_name] = $library_info['label']; + } + } + if (count($library_options) == 0) { + drupal_set_message(t('There are no enabled charting libraries. Please enable a Charts sub-module.')); } $form['library'] = array( '#title' => t('Charting library'), @@ -228,7 +233,7 @@ function charts_settings_form($form, $defaults = array(), $field_options = array '#options' => $library_options, '#default_value' => $options['library'], '#required' => TRUE, - '#access' => count($library_options) > 1, + '#access' => count($library_options) > 0, '#attributes' => array('class' => array('chart-library-select')), '#weight' => -15, '#parents' => array_merge($parents, array('library')), diff --git a/src/Plugin/views/style/ChartsPluginStyleChart.php b/src/Plugin/views/style/ChartsPluginStyleChart.php index 55b558d9989983696eafb9eb2b90c955e8e4843b..ad08c481a918511b292b81d3e656aa175dc0cb20 100644 --- a/src/Plugin/views/style/ChartsPluginStyleChart.php +++ b/src/Plugin/views/style/ChartsPluginStyleChart.php @@ -119,11 +119,10 @@ class ChartsPluginStyleChart extends StylePluginBase { $dataFieldsCounter = 0; foreach ($dataFields as $value) { - /*if (count(array_unique($plugin)) === 1 && end($plugin) === 0) { - $errors[] = $this->t('At least one data field must be selected in the chart configuration before this chart may be shown'); - }*/ - /*Skip title field no need to validate it and if data field is set add to dataFieldsValueState array state 1 - otherwise add to same array state 0*/ + /** + * Skip title field no need to validate it and if data field is set add to dataFieldsValueState array state 1 + * otherwise add to same array state 0 + */ if ($dataFieldsCounter > 0) { if (empty($value)) { array_push($dataFieldsValueState, 0); @@ -133,8 +132,11 @@ class ChartsPluginStyleChart extends StylePluginBase { } $dataFieldsCounter++; } - /*If total sum of dataFieldsValueState is less than 1, then no dataFields were selected otherwise 1 or more selected - total sum will be greater than 1*/ + + /** + * If total sum of dataFieldsValueState is less than 1, then no dataFields were selected otherwise 1 or more selected + * total sum will be greater than 1 + */ if (array_sum($dataFieldsValueState) < 1) { $errors[] = $this->t('At least one data field must be selected in the chart configuration before this chart may be shown'); }