diff --git a/charts.api.php b/charts.api.php index d9caeab5f42a450f5692b91e75f9dfc234935f60..593b6adafa2e6665f823cd2ffd224bb2b66548c4 100644 --- a/charts.api.php +++ b/charts.api.php @@ -57,9 +57,9 @@ use Drupal\charts\Theme\ChartsInterface; /** * Alter an individual chart before it is printed. * - * @param $chart + * @param mixed $chart * The chart renderable. Passed in by reference. - * @param $chart_id + * @param mixed $chart_id * The chart identifier, pulled from the $chart['#chart_id'] property (if * any). Not all charts have a chart identifier. */ @@ -76,10 +76,10 @@ function hook_chart_alter(&$chart, $chart_id) { * Same as hook_chart_alter(), only including the $chart_id in the function * name instead of being passed in as an argument. * - * @see hook_chart_alter() - * * @param mixed $chart * Chart. + * + * @see hook_chart_alter() */ function hook_chart_CHART_ID_alter(&$chart) { } @@ -116,10 +116,10 @@ function hook_chart_definition_alter(&$definition, $chart) { * Same as hook_chart_definition_alter(), only including the $chart_id in the * function name instead of being passed in as an argument. * - * @see hook_chart_definition_alter() - * - * @param $chart + * @param mixed $chart * Chart. + * + * @see hook_chart_definition_alter() */ function hook_chart_definition_CHART_ID_alter(&$chart) { } @@ -151,7 +151,7 @@ function hook_charts_info() { * If your module needs to modify the capabilities of a charting library, such * as to add support for a new chart type, it may do so with this hook. * - * @param array $info + * @param mixed $info * Info. */ function hook_charts_info_alter(&$info) { @@ -191,7 +191,7 @@ function hook_charts_type_info() { * If your module needs to modify the capabilities or labels of a paricular * chart type, it may alter the definitions provided by other modules. * - * @param array $chart_types + * @param mixed $chart_types * Chart Types. */ function hook_charts_type_info_alter(&$chart_types) { diff --git a/includes/charts.pages.inc b/includes/charts.pages.inc index dc43888307c1dc5f927f47c395158e4ee56abadc..2e92c258907313b33ed81fb85a9c2c753d37fbab 100644 --- a/includes/charts.pages.inc +++ b/includes/charts.pages.inc @@ -237,20 +237,6 @@ function charts_settings_form($form, $defaults = [], $field_options = [], $paren } } -/* - // Get a list of available chart libraries. - $charts_info = charts_info(); - $library_options = []; - foreach ($charts_info as $library_name => $library_info) { - 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'] = [ '#title' => t('Charting library'), '#type' => 'select', @@ -299,7 +285,7 @@ function charts_settings_form($form, $defaults = [], $field_options = [], $paren /* $form['#theme'] = 'charts_settings_fields'; */ - $form['fields'] = [ + $form['fields'] = [ '#title' => t('Charts fields'), '#type' => 'fieldset', ]; @@ -313,7 +299,7 @@ function charts_settings_form($form, $defaults = [], $field_options = [], $paren '#parents' => array_merge($parents, ['label_field']), ]; - $form['fields']['table'] = [ + $form['fields']['table'] = [ '#type' => 'table', '#header' => [t('Field Name'), t('Provides Data'), t('Color')], '#tabledrag' => TRUE, @@ -321,13 +307,13 @@ function charts_settings_form($form, $defaults = [], $field_options = [], $paren $field_count = 0; foreach ($field_options as $field_name => $field_label) { - $form['fields']['table'][$field_count]['label_label'] = [ + $form['fields']['table'][$field_count]['label_label'] = [ '#type' => 'label', '#title' => $field_label, '#column' => 'one', ]; - $form['fields']['table'][$field_count]['data_fields'][$field_name] = [ + $form['fields']['table'][$field_count]['data_fields'][$field_name] = [ '#type' => 'checkbox', '#title' => $field_name, '#default_value' => $options['data_fields'][$field_name], @@ -356,14 +342,14 @@ function charts_settings_form($form, $defaults = [], $field_options = [], $paren } } - $form['display'] = [ + $form['display'] = [ '#title' => t('Display'), '#type' => 'fieldset', '#collapsible' => TRUE, '#collapsed' => TRUE, ]; - $form['display']['title'] = [ + $form['display']['title'] = [ '#title' => t('Chart title'), '#type' => 'textfield', '#default_value' => $options['title'], @@ -431,13 +417,13 @@ function charts_settings_form($form, $defaults = [], $field_options = [], $paren '#parents' => array_merge($parents, ['background']), ]; - $form['display']['dimensions'] = [ + $form['display']['dimensions'] = [ '#title' => t('Dimensions'), '#theme_wrappers' => ['form_element'], '#description' => t('If dimensions are left empty, the chart will fill its containing element.'), ]; - $form['display']['dimensions']['width'] = [ + $form['display']['dimensions']['width'] = [ '#type' => 'textfield', '#attributes' => [ 'TYPE' => 'number', @@ -469,7 +455,7 @@ function charts_settings_form($form, $defaults = [], $field_options = [], $paren '#parents' => array_merge($parents, ['height']), ]; - $form['xaxis'] = [ + $form['xaxis'] = [ '#title' => t('Horizontal axis'), '#type' => 'fieldset', '#collapsible' => TRUE, @@ -477,7 +463,7 @@ function charts_settings_form($form, $defaults = [], $field_options = [], $paren '#attributes' => ['class' => ['chart-xaxis']], ]; - $form['xaxis']['xaxis_title'] = [ + $form['xaxis']['xaxis_title'] = [ '#title' => t('Custom title'), '#type' => 'textfield', '#default_value' => $options['xaxis_title'], @@ -500,24 +486,26 @@ function charts_settings_form($form, $defaults = [], $field_options = [], $paren '#parents' => array_merge($parents, ['xaxis_labels_rotation']), ]; - $form['yaxis'] = [ + $form['yaxis'] = [ '#title' => t('Vertical axis'), '#type' => 'fieldset', '#collapsible' => TRUE, '#collapsed' => TRUE, '#attributes' => ['class' => ['chart-yaxis']], ]; - $form['yaxis']['title'] = [ + $form['yaxis']['title'] = [ '#title' => t('Custom title'), '#type' => 'textfield', '#default_value' => $options['yaxis_title'], '#parents' => array_merge($parents, ['yaxis_title']), ]; - $form['yaxis']['minmax'] = [ + + $form['yaxis']['minmax'] = [ '#title' => t('Value range'), '#theme_wrappers' => ['form_element'], ]; - $form['yaxis']['minmax']['min'] = [ + + $form['yaxis']['minmax']['min'] = [ '#type' => 'textfield', '#attributes' => [ 'TYPE' => 'number', @@ -530,7 +518,7 @@ function charts_settings_form($form, $defaults = [], $field_options = [], $paren '#suffix' => ' ', '#theme_wrappers' => [], ]; - $form['yaxis']['minmax']['max'] = [ + $form['yaxis']['minmax']['max'] = [ '#type' => 'textfield', '#attributes' => [ 'TYPE' => 'number', @@ -543,7 +531,7 @@ function charts_settings_form($form, $defaults = [], $field_options = [], $paren '#theme_wrappers' => [], ]; - $form['yaxis']['prefix'] = [ + $form['yaxis']['prefix'] = [ '#title' => t('Value prefix'), '#type' => 'textfield', '#default_value' => $options['yaxis_prefix'], @@ -551,7 +539,7 @@ function charts_settings_form($form, $defaults = [], $field_options = [], $paren '#parents' => array_merge($parents, ['yaxis_prefix']), ]; - $form['yaxis']['suffix'] = [ + $form['yaxis']['suffix'] = [ '#title' => t('Value suffix'), '#type' => 'textfield', '#default_value' => $options['yaxis_suffix'], @@ -559,7 +547,7 @@ function charts_settings_form($form, $defaults = [], $field_options = [], $paren '#parents' => array_merge($parents, ['yaxis_suffix']), ]; - $form['yaxis']['decimal_count'] = [ + $form['yaxis']['decimal_count'] = [ '#title' => t('Decimal count'), '#type' => 'textfield', '#attributes' => [ @@ -597,9 +585,9 @@ function charts_settings_form($form, $defaults = [], $field_options = [], $paren /** * Menu callback; Configure the site-wide defaults for charts. * - * @param array $form + * @param mixed $form * Form. - * @param array $form_state + * @param mixed $form_state * Form State, Standard parameters for a form. * * @return mixed @@ -646,14 +634,13 @@ function charts_default_settings_form($form, $form_state) { /** * Submit handler for charts_default_settings_form(). * - * @param array $form + * @param mixed $form * Form. - * @param array $form_state + * @param mixed $form_state * Form State. */ function charts_default_settings_form_submit($form, $form_state) { - \Drupal::state() - ->set('charts_default_settings', $form_state['values']['charts_default_settings']); + \Drupal::state()->set('charts_default_settings', $form_state['values']['charts_default_settings']); } /** diff --git a/modules/charts_c3/charts_c3.module b/modules/charts_c3/charts_c3.module index f72fa7c355956f43de04a8afa809066506cc992f..2d73eac733a950d300aa4e7f36ecf1fb5091ef69 100644 --- a/modules/charts_c3/charts_c3.module +++ b/modules/charts_c3/charts_c3.module @@ -22,7 +22,7 @@ function charts_c3_charts_info() { 'line', 'pie', 'donut', - 'scatter' + 'scatter', ], ], ]; @@ -30,7 +30,7 @@ function charts_c3_charts_info() { /** * Implements hook_charts_type_info(). -*/ + */ function charts_c3_charts_type_info() { $chart_types['donut'] = [ 'label' => t('Donut'), diff --git a/modules/charts_c3/src/Charts/C3ChartsRender.php b/modules/charts_c3/src/Charts/C3ChartsRender.php index 4d08dd6233fb94324f42f322cde42931896f1640..062a4348e82961306ef437a737cff5f2bbf84c40 100644 --- a/modules/charts_c3/src/Charts/C3ChartsRender.php +++ b/modules/charts_c3/src/Charts/C3ChartsRender.php @@ -61,19 +61,12 @@ class C3ChartsRender implements ChartsRenderInterface { } // Sets the primary y axis. -/* - $yAxis = []; - $yAxis[$seriesData[0]['name']] = 'y'; -*/ $showAxis['show'] = TRUE; $showAxis['label'] = $options['yaxis_title']; $chartAxis->y = $showAxis; // Sets secondary axis from the first attachment only. if (!$noAttachmentDisplays && $attachmentDisplayOptions[0]['inherit_yaxis'] == 0) { -/* - $yAxis[$seriesData[1]['name']] = 'y2'; -*/ $showSecAxis['show'] = TRUE; $showSecAxis['label'] = $attachmentDisplayOptions[0]['style']['options']['yaxis_title']; $chartAxis->y2 = $showSecAxis; diff --git a/modules/charts_c3/src/Plugin/chart/CThreeCharts.php b/modules/charts_c3/src/Plugin/chart/CThreeCharts.php index db351ca0a7b14aac694e9eeac131957f5ed679ef..3fef33dc73018ee38706253bf4f4bd1081b00574 100644 --- a/modules/charts_c3/src/Plugin/chart/CThreeCharts.php +++ b/modules/charts_c3/src/Plugin/chart/CThreeCharts.php @@ -70,20 +70,12 @@ class CThreeCharts extends AbstractChart { $chartData->setLabels(FALSE); } - // Sets the primary y axis. -/* - $yAxis = []; - $yAxis[$seriesData[0]['name']] = 'y'; -*/ $showAxis['show'] = TRUE; $showAxis['label'] = $options['yaxis_title']; $chartAxis->y = $showAxis; // Sets secondary axis from the first attachment only. if (!$noAttachmentDisplays && $attachmentDisplayOptions[0]['inherit_yaxis'] == 0) { -/* - $yAxis[$seriesData[1]['name']] = 'y2'; -*/ $showSecAxis['show'] = TRUE; $showSecAxis['label'] = $attachmentDisplayOptions[0]['style']['options']['yaxis_title']; $chartAxis->y2 = $showSecAxis; diff --git a/modules/charts_google/src/Settings/Google/ChartAxes.php b/modules/charts_google/src/Settings/Google/ChartAxes.php index d2a6f0607006ed8d0f44e5a2d175616a44cb5634..bf47c07884d70c32a3f71d4339d20679559c861c 100644 --- a/modules/charts_google/src/Settings/Google/ChartAxes.php +++ b/modules/charts_google/src/Settings/Google/ChartAxes.php @@ -133,7 +133,7 @@ class ChartAxes implements \JsonSerializable { /** * Set Chart Axis property that specifies a title for the axis. * - * @param $value + * @param mixed $value * Title. */ public function setTitle($value) { diff --git a/modules/charts_google/src/Settings/Google/GoogleOptions.php b/modules/charts_google/src/Settings/Google/GoogleOptions.php index ba63f1bee1752f470afe7d1a2eb1e050527e6b57..fee23fefe1a63c0e0aec4585ae478fe45a3a1b97 100644 --- a/modules/charts_google/src/Settings/Google/GoogleOptions.php +++ b/modules/charts_google/src/Settings/Google/GoogleOptions.php @@ -70,7 +70,7 @@ class GoogleOptions implements \JsonSerializable { * Colors. * * The colors to use for the chart elements. An array of strings, where each - * element is an HTML color string + * element is an HTML color string. * * @var mixed */ @@ -296,6 +296,7 @@ class GoogleOptions implements \JsonSerializable { * Sets the Legend properties. * * @param mixed $legend + * Legend. */ public function setLegend($legend) { $this->legend = $legend; diff --git a/modules/charts_highcharts/src/Charts/HighchartsChartsRender.php b/modules/charts_highcharts/src/Charts/HighchartsChartsRender.php index efd13d9cd0061dc66b13972a09cc080731262257..d6f848a07b0d34965f1664dd4a6a43cf6d0f08c5 100644 --- a/modules/charts_highcharts/src/Charts/HighchartsChartsRender.php +++ b/modules/charts_highcharts/src/Charts/HighchartsChartsRender.php @@ -48,7 +48,7 @@ class HighchartsChartsRender implements ChartsRenderInterface { $value = str_replace('donut', 'pie', $value); } // Add innerSize to differentiate between donut and pie. - foreach ($seriesData as $key => &$value) { + foreach ($seriesData as &$value) { if ($typeOptions == 'pie') { $innerSize['showInLegend'] = 'true'; $innerSize['innerSize'] = '40%'; diff --git a/modules/charts_highcharts/src/Plugin/chart/Highchart.php b/modules/charts_highcharts/src/Plugin/chart/Highchart.php index d883dd717705e13ce1bce9c28ba40d9807a43c71..b7c14fb26fecb80722f7e518287b24de7540e8f6 100644 --- a/modules/charts_highcharts/src/Plugin/chart/Highchart.php +++ b/modules/charts_highcharts/src/Plugin/chart/Highchart.php @@ -62,7 +62,7 @@ class Highchart extends AbstractChart { $value = str_replace('donut', 'pie', $value); } // Add innerSize to differentiate between donut and pie. - foreach ($seriesData as $key => &$value) { + foreach ($seriesData as &$value) { if ($typeOptions == 'pie') { $innerSize['showInLegend'] = 'true'; $innerSize['innerSize'] = '40%'; diff --git a/src/Plugin/chart/ChartInterface.php b/src/Plugin/chart/ChartInterface.php index a63b42787c0ba2881531a07b52dbffc24b84a98b..05d590d40c0fc3353aa17187f8475b4f7b71b0e7 100644 --- a/src/Plugin/chart/ChartInterface.php +++ b/src/Plugin/chart/ChartInterface.php @@ -21,7 +21,8 @@ interface ChartInterface extends PluginInspectionInterface { * Return the name of the chart. * * @return string - * returns the name as a string. + * Returns the name as a string. */ public function getChartName(); + } diff --git a/src/Plugin/chart/ChartManager.php b/src/Plugin/chart/ChartManager.php index 99520888ea1d8403b834547e7366741dee80ef7c..be5b51efb77e1e4a0e415c325c536efedb8f6e6e 100644 --- a/src/Plugin/chart/ChartManager.php +++ b/src/Plugin/chart/ChartManager.php @@ -7,6 +7,8 @@ use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Extension\ModuleHandlerInterface; /** + * Chart Manager. + * * Provides the Chart plugin plugin manager and manages discovery and * instantiation of chart plugins. */ diff --git a/src/Util/Util.php b/src/Util/Util.php index 29e6f05a27312e75c7e26d78e2ed540ad6180628..7ea0c5b1cf167ad623506bba2e86bd3e8bd3621e 100644 --- a/src/Util/Util.php +++ b/src/Util/Util.php @@ -3,15 +3,12 @@ namespace Drupal\charts\Util; use Drupal\views\ViewExecutable; -use Drupal\Core\StringTranslation\StringTranslationTrait; /** * Util. */ class Util { - use StringTranslationTrait; - /** * Views Data. * @@ -118,7 +115,7 @@ class Util { $module_path = drupal_get_path('module', $moduleName); if (!file_exists($module_path . $libraryPath)) { $text = 'Charting libraries for ' . $moduleName . ' might not be installed. Run \'composer install\' for ' . $moduleName . ' sub-module.'; - drupal_set_message($this->t($text), 'error'); + drupal_set_message(t($text), 'error'); } }