Commit 3e47f430 authored by Daniel Cothran's avatar Daniel Cothran
Browse files

Issue #3277589 by nikathone, andileco: Clean up code documentation, add return types, etc.

parent 3ee2a80b
Loading
Loading
Loading
Loading
+23 −13
Changes for modules/charts_api_example/src/Controller/ChartsApiExample.php: 23 added lines, 13 removed lines.
Original line number Diff line number Diff line
@@ -103,7 +103,12 @@ class ChartsApiExample extends ControllerBase {
    $xaxis = [
      '#type' => 'chart_xaxis',
      '#title' => $this->t('Months'),
      '#labels' => [$this->t('January 2021'), $this->t('February 2021'), $this->t('March 2021'), $this->t('April 2021')],
      '#labels' => [
        $this->t('January 2021'),
        $this->t('February 2021'),
        $this->t('March 2021'),
        $this->t('April 2021'),
      ],
    ];

    // Define a y-axis to be used in multiple examples.
@@ -117,12 +122,15 @@ class ChartsApiExample extends ControllerBase {
      $charts_container['content'][$type] = [
        '#type' => 'chart',
        '#tooltips' => $charts_settings->get('charts_default_settings.display.tooltips'),
        '#title' => $this->t('@library @type Chart', ['@library' => ucfirst($library), '@type' => ucfirst($type)]),
        '#title' => $this->t('@library @type Chart', [
          '@library' => ucfirst($library), '@type' => ucfirst($type)
        ]),
        '#chart_type' => $type,
        'series' => $series,
        'x_axis' => $xaxis,
        'y_axis' => $yaxis,
        '#raw_options' => [], // e.g. ['chart' => ['backgroundColor' => '#000000']],
        '#raw_options' => [],
        // e.g. ['chart' => ['backgroundColor' => '#000000']].
      ];
    }

@@ -141,7 +149,7 @@ class ChartsApiExample extends ControllerBase {
      ],
      'x_axis' => $xaxis,
      'y_axis' => $yaxis,
      '#raw_options' => [], // e.g. ['chart' => ['backgroundColor' => '#000000']],
      '#raw_options' => [],
    ];

    // Stacked Area Chart from a local CSV file.
@@ -188,7 +196,8 @@ class ChartsApiExample extends ControllerBase {
          'scales' => [
            'x' => [
              'ticks' => [
                'autoSkip' => TRUE],
                'autoSkip' => TRUE
              ],
            ],
          ],
        ],
@@ -222,7 +231,7 @@ class ChartsApiExample extends ControllerBase {
      'x_axis' => $xaxis,
      'y_axis' => $yaxis,
      '#stacking' => TRUE,
      '#raw_options' => [], // e.g. ['chart' => ['backgroundColor' => '#000000']],
      '#raw_options' => [],
    ];

    // Combination chart (column and line).
@@ -241,7 +250,7 @@ class ChartsApiExample extends ControllerBase {
      ],
      'x_axis' => $xaxis,
      'y_axis' => $yaxis,
      '#raw_options' => [], // e.g. ['chart' => ['backgroundColor' => '#000000']],
      '#raw_options' => [],
    ];

    // Combination chart (column and line) with secondary Y-Axis.
@@ -266,7 +275,7 @@ class ChartsApiExample extends ControllerBase {
        '#title' => $this->t('Secondary Y-Axis'),
        '#opposite' => TRUE,
      ],
      '#raw_options' => [], // e.g. ['chart' => ['backgroundColor' => '#000000']],
      '#raw_options' => [],
    ];

    // Radar chart. Not supported by C3.js or Google Charts (natively).
@@ -280,7 +289,7 @@ class ChartsApiExample extends ControllerBase {
        'x_axis' => $xaxis,
        'y_axis' => $yaxis,
        '#polar' => TRUE,
        '#raw_options' => [], // e.g. ['chart' => ['backgroundColor' => '#000000']],
        '#raw_options' => [],
      ];
    }

@@ -305,7 +314,7 @@ class ChartsApiExample extends ControllerBase {
          '#title' => $this->t('Speed'),
          '#data' => [65],
        ],
        '#raw_options' => [], // e.g. ['chart' => ['backgroundColor' => '#000000']],
        '#raw_options' => [],
      ];
    }

@@ -330,7 +339,7 @@ class ChartsApiExample extends ControllerBase {
        '#title' => $this->t('Weight'),
      ],
      '#stacking' => TRUE,
      '#raw_options' => [], // e.g. ['chart' => ['backgroundColor' => '#000000']],
      '#raw_options' => [],
    ];

    if ($library === 'highcharts') {
@@ -344,7 +353,6 @@ class ChartsApiExample extends ControllerBase {
        'x_axis' => $xaxis,
        'y_axis' => $yaxis,
        '#raw_options' => [],
        // e.g. ['chart' => ['backgroundColor' => '#000000']],
      ];

      $charts_container['content']['js_override'] = [
@@ -358,7 +366,6 @@ class ChartsApiExample extends ControllerBase {
        'x_axis' => $xaxis,
        'y_axis' => $yaxis,
        '#raw_options' => [],
        // e.g. ['chart' => ['backgroundColor' => '#000000']],
      ];
    }

@@ -366,7 +373,10 @@ class ChartsApiExample extends ControllerBase {
  }

  /**
   * Returns the CSV contents in an array with data organized by column.
   *
   * @return array $all_rows
   *   The array of rows.
   */
  private function getCsvContents() {
    $file_path = $this->moduleList->getPath('charts_api_example');
+9 −3
Changes for modules/charts_billboard/README.md: 9 added lines, 3 removed lines.
Original line number Diff line number Diff line
#Installation Using Composer (recommended)

If you use Composer to manage dependencies, edit your site's `composer.json` file as follows.
If you use Composer to manage dependencies, edit your site's "composer.json"
file as follows.

  1. Run `composer require --prefer-dist composer/installers` to ensure that you have the "composer/installers" package installed. This package facilitates the installation of packages into directories other than "/vendor" (e.g. "/libraries") using Composer.
1. Run `composer require --prefer-dist composer/installers` to ensure that
you have the "composer/installers" package installed. This package facilitates
the installation of packages into directories other than "/vendor" (e.g.
"/libraries") using Composer.

2. Add the following to the "installer-paths" section of "composer.json":

@@ -44,4 +48,6 @@ If you use Composer to manage dependencies, edit your site's `composer.json` fil
             }
         }

  4. Run `composer require --prefer-dist billboardjs/billboard:3.4.1 d3/d3:4.9.1` - you should find that new directories have been created under "/libraries"
4. Run
`composer require --prefer-dist billboardjs/billboard:3.4.1 d3/d3:4.9.1`
you should find that new directories have been created under "/libraries"
+1 −2
Changes for modules/charts_billboard/charts_billboard.install: 1 added line, 2 removed lines.
Original line number Diff line number Diff line
<?php

/**
 * @file
 * Installation and uninstallation functions.
@@ -41,7 +42,6 @@ function charts_billboard_requirements($phase) {
 * @return string
 *   The location of the library, or FALSE if the library isn't installed.
 */

function charts_billboard_find_library() {
  // The following logic is taken from libraries_get_libraries()
  $searchdir = [];
@@ -68,4 +68,3 @@ function charts_billboard_find_library() {

  return FALSE;
}
+4 −2
Changes for modules/charts_billboard/src/Plugin/chart/Library/Billboard.php: 4 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -225,7 +225,9 @@ class Billboard extends ChartBase implements ContainerFactoryPluginInterface {
    $chart_definition['data']['type'] = $type;
    // Merge in chart raw options.
    if (!empty($element['#raw_options'])) {
      $chart_definition = NestedArray::mergeDeepArray([$element['#raw_options'], $chart_definition]);
      $chart_definition = NestedArray::mergeDeepArray([
        $element['#raw_options'], $chart_definition
      ]);
    }

    return $chart_definition;
@@ -265,7 +267,7 @@ class Billboard extends ChartBase implements ContainerFactoryPluginInterface {
          }
        }
        else {
          $chart_definition['data']['columns'] = array_map(NULL, $categories, $chart_definition['data']['columns']);;
          $chart_definition['data']['columns'] = array_map(NULL, $categories, $chart_definition['data']['columns']);
        }
      }
      if ($type === 'chart_yaxis') {
+9 −4
Changes for modules/charts_c3/README.md: 9 added lines, 4 removed lines.
Original line number Diff line number Diff line
#Installation using Composer (recommended)
#Installation Using Composer (recommended)

If you use Composer to manage dependencies, edit your site's `composer.json` file as follows.
If you use Composer to manage dependencies, edit your site's "composer.json"
file as follows.

1. Run `composer require --prefer-dist composer/installers` to ensure that you have the "composer/installers" package installed. This package facilitates the installation of packages into directories other than "/vendor" (e.g. "/libraries") using Composer.
1. Run `composer require --prefer-dist composer/installers` to ensure that
   you have the "composer/installers" package installed. This package facilitates
   the installation of packages into directories other than "/vendor" (e.g.
   "/libraries") using Composer.

2. Add the following to the "installer-paths" section of "composer.json":

@@ -44,4 +48,5 @@ If you use Composer to manage dependencies, edit your site's `composer.json` fil
            }
        }

4. Run `composer require --prefer-dist c3js/c3:0.7.20 d3/d3:4.9.1` - you should find that new directories have been created under "/libraries"
4. Run `composer require --prefer-dist c3js/c3:0.7.20 d3/d3:4.9.1` -
you should find that new directories have been created under "/libraries"
Loading