From 0b548c6fabcdb0fafda88a386ff54434f274e658 Mon Sep 17 00:00:00 2001
From: Daniel Cothran <daniel@andile.co>
Date: Fri, 23 Feb 2018 01:11:43 -0500
Subject: [PATCH] Removed render classes in favor of plugins, which had taken
 over the functionality already. Also renamed the plugins to be more
 consistent.

---
 .../charts_c3/src/Charts/C3ChartsRender.php   | 120 ------
 .../Plugin/chart/{CThreeCharts.php => C3.php} |   7 +-
 .../src/Charts/GoogleChartsRender.php         | 385 ------------------
 .../chart/{GoogleCharts.php => Google.php}    |  11 +-
 .../src/Charts/HighchartsChartsRender.php     | 217 ----------
 .../chart/{Highchart.php => Highcharts.php}   |   4 +-
 6 files changed, 12 insertions(+), 732 deletions(-)
 delete mode 100644 modules/charts_c3/src/Charts/C3ChartsRender.php
 rename modules/charts_c3/src/Plugin/chart/{CThreeCharts.php => C3.php} (95%)
 delete mode 100644 modules/charts_google/src/Charts/GoogleChartsRender.php
 rename modules/charts_google/src/Plugin/chart/{GoogleCharts.php => Google.php} (98%)
 delete mode 100644 modules/charts_highcharts/src/Charts/HighchartsChartsRender.php
 rename modules/charts_highcharts/src/Plugin/chart/{Highchart.php => Highcharts.php} (98%)

diff --git a/modules/charts_c3/src/Charts/C3ChartsRender.php b/modules/charts_c3/src/Charts/C3ChartsRender.php
deleted file mode 100644
index 786291b..0000000
--- a/modules/charts_c3/src/Charts/C3ChartsRender.php
+++ /dev/null
@@ -1,120 +0,0 @@
-<?php
-
-namespace Drupal\charts_c3\Charts;
-
-use Drupal\charts\Charts\ChartsRenderInterface;
-use Drupal\charts\Util\Util;
-use Drupal\charts_c3\Settings\CThree\ChartType;
-use Drupal\charts_c3\Settings\CThree\CThree;
-use Drupal\charts_c3\Settings\CThree\ChartTitle;
-use Drupal\charts_c3\Settings\CThree\ChartData;
-use Drupal\charts_c3\Settings\CThree\ChartColor;
-use Drupal\charts_c3\Settings\CThree\ChartAxis;
-
-/**
- * C3 Charts Render.
- */
-class C3ChartsRender implements ChartsRenderInterface {
-
-  /**
-   * Construct.
-   */
-  public function __construct() {
-    Util::checkMissingLibrary('libraries/c3/c3.min.js');
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function chartsRenderCharts(array $options = [], array $categories = [], array $seriesData = [], array $attachmentDisplayOptions = [], array &$variables = [], $chartId = '') {
-    $noAttachmentDisplays = count($attachmentDisplayOptions) === 0;
-    $types = [];
-
-    // @todo - make this work for more that one attachment.
-    for ($i = 1; $i <= count($attachmentDisplayOptions); $i++) {
-      if ($attachmentDisplayOptions[$i - 1]['style']['options']['type'] == 'column') {
-        $types[$seriesData[$i]['name']] = 'bar';
-      }
-      else {
-        $types[$seriesData[$i]['name']] = $attachmentDisplayOptions[$i - 1]['style']['options']['type'];
-      }
-    }
-    $c3Data = [];
-    for ($i = 0; $i < count($seriesData); $i++) {
-      $c3DataTemp = $seriesData[$i]['data'];
-      array_unshift($c3DataTemp, $seriesData[$i]['name']);
-      array_push($c3Data, $c3DataTemp);
-    }
-
-    $c3Chart = new ChartType();
-    $c3Chart->setType($options['type']);
-    $c3ChartTitle = new ChartTitle();
-    $c3ChartTitle->setText($options['title']);
-    $chartAxis = new ChartAxis();
-    $c3 = new CThree();
-    $bindTo = '#' . $chartId;
-    $c3->setBindTo($bindTo);
-    $c3->setTitle($c3ChartTitle);
-    $chartData = new ChartData();
-    if ($noAttachmentDisplays > 0) {
-      $chartData->setLabels(FALSE);
-    }
-
-    // Sets the primary y axis.
-    $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) {
-      $showSecAxis['show'] = TRUE;
-      $showSecAxis['label'] = $attachmentDisplayOptions[0]['style']['options']['yaxis_title'];
-      $chartAxis->y2 = $showSecAxis;
-    }
-
-    // Sets the chart type.
-    $chartData->setType($options['type']);
-    $c3->setData($chartData);
-    if ($options['type'] == 'bar') {
-      $chartAxis->setRotated(TRUE);
-      array_unshift($categories, 'x');
-      array_push($c3Data, $categories);
-      $chartData->setColumns($c3Data);
-    }
-    elseif ($options['type'] == 'column') {
-      $chartData->setType('bar');
-      $chartAxis->setRotated(FALSE);
-      array_unshift($categories, 'x');
-      array_push($c3Data, $categories);
-      $chartData->setColumns($c3Data);
-    }
-    elseif ($options['type'] == 'pie' || $options['type'] == 'donut') {
-      $chartData->setColumns($c3Data);
-    }
-    else {
-      array_unshift($categories, 'x');
-      array_push($c3Data, $categories);
-      $chartData->setColumns($c3Data);
-    }
-    $chartData->types = $types;
-
-    if ($options['type'] != 'pie' && $options['type'] != 'donut') {
-      $c3->setAxis($chartAxis);
-    }
-
-    $chartColor = new ChartColor();
-    $seriesColors = [];
-    for ($i = 0; $i < count($seriesData); $i++) {
-      $seriesColor = $seriesData[$i]['color'];
-      array_push($seriesColors, $seriesColor);
-    }
-    $chartColor->setPattern($seriesColors);
-    $c3->setColor($chartColor);
-
-    $variables['chart_type'] = 'c3';
-    $variables['content_attributes']['data-chart'][] = json_encode($c3);
-    $variables['attributes']['id'][0] = $chartId;
-    $variables['attributes']['class'][] = 'charts-c3';
-  }
-
-}
diff --git a/modules/charts_c3/src/Plugin/chart/CThreeCharts.php b/modules/charts_c3/src/Plugin/chart/C3.php
similarity index 95%
rename from modules/charts_c3/src/Plugin/chart/CThreeCharts.php
rename to modules/charts_c3/src/Plugin/chart/C3.php
index 0a9fda2..f4d9ca2 100644
--- a/modules/charts_c3/src/Plugin/chart/CThreeCharts.php
+++ b/modules/charts_c3/src/Plugin/chart/C3.php
@@ -15,13 +15,13 @@ use Drupal\charts_c3\Settings\CThree\ChartAxis;
  *
  * @Chart(
  *   id = "c3",
- *   name = @Translation("C3 Charts")
+ *   name = @Translation("C3")
  * )
  */
-class CThreeCharts extends AbstractChart {
+class C3 extends AbstractChart {
 
   /**
-   * Creates a JSON Object formatted for Google charts to use.
+   * Creates a JSON Object formatted for C3 Charts JavaScript to use.
    *
    * @param mixed $options
    *   Options.
@@ -70,6 +70,7 @@ class CThreeCharts extends AbstractChart {
       $chartData->setLabels(FALSE);
     }
 
+    // Sets the primary y axis.
     $showAxis['show'] = TRUE;
     $showAxis['label'] = $options['yaxis_title'];
     $chartAxis->y = $showAxis;
diff --git a/modules/charts_google/src/Charts/GoogleChartsRender.php b/modules/charts_google/src/Charts/GoogleChartsRender.php
deleted file mode 100644
index f0d23c5..0000000
--- a/modules/charts_google/src/Charts/GoogleChartsRender.php
+++ /dev/null
@@ -1,385 +0,0 @@
-<?php
-
-namespace Drupal\charts_google\Charts;
-
-use Drupal\charts\Charts\ChartsRenderInterface;
-use Drupal\charts\Util\Util;
-use Drupal\charts_google\Settings\Google\GoogleOptions;
-use Drupal\charts_google\Settings\Google\ChartType;
-use Drupal\charts_google\Settings\Google\ChartArea;
-use Drupal\charts_google\Settings\Google\ChartAxes;
-
-/**
- * Google Charts Render.
- */
-class GoogleChartsRender implements ChartsRenderInterface {
-
-  /**
-   * Construct.
-   */
-  public function __construct() {
-    Util::checkMissingLibrary('libraries/google_charts/loader.js');
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function chartsRenderCharts(array $options = [], array $categories = [], array $seriesData = [], array $attachmentDisplayOptions = [], array &$variables = [], $chartId = '') {
-
-    $categoriesCount = count($categories);
-    $seriesCount = count($seriesData);
-
-    // Creates an array of the length of the series data.
-    $dataCount = [];
-    for ($x = 0; $x < $seriesCount; $x++) {
-      $dataCountTemp = count($seriesData[$x]['data']);
-      array_push($dataCount, $dataCountTemp);
-    }
-
-    $dataTable = [];
-    for ($j = 0; $j < $categoriesCount; $j++) {
-      $rowDataTable = [];
-      for ($i = 0; $i < $seriesCount; $i++) {
-        $rowDataTabletemp = $seriesData[$i]['data'][$j];
-        array_push($rowDataTable, $rowDataTabletemp);
-      }
-      array_unshift($rowDataTable, $categories[$j]);
-      array_push($dataTable, $rowDataTable);
-    }
-
-    $dataTableHeader = [];
-    for ($r = 0; $r < $seriesCount; $r++) {
-      array_push($dataTableHeader, $seriesData[$r]['name']);
-    }
-    array_unshift($dataTableHeader, 'label');
-    array_unshift($dataTable, $dataTableHeader);
-
-    $googleOptions = $this->createChartsOptions($options, $seriesData, $attachmentDisplayOptions);
-    $googleChartType = $this->createChartType($options);
-    $variables['chart_type'] = 'google';
-    $variables['attributes']['class'][0] = 'charts-google';
-    $variables['attributes']['id'][0] = $chartId;
-    $variables['content_attributes']['data-chart'][] = json_encode($dataTable);
-    $variables['attributes']['google-options'][1] = json_encode($googleOptions);
-    $variables['attributes']['google-chart-type'][2] = json_encode($googleChartType);
-
-  }
-
-  /**
-   * Create charts options.
-   *
-   * @param array $options
-   *   Options.
-   * @param array $seriesData
-   *   Series data.
-   * @param array $attachmentDisplayOptions
-   *   Attachment Display Options.
-   *
-   * @return \Drupal\charts_google\Settings\Google\GoogleOptions
-   *   GoogleOptions object with chart options or settings to be used by google
-   *   visualization framework.
-   */
-  private function createChartsOptions(array $options = [], array $seriesData = [], array $attachmentDisplayOptions = []) {
-    $noAttachmentDisplays = count($attachmentDisplayOptions) === 0;
-
-    $chartSelected = [];
-    $seriesTypes = [];
-
-    $firstVaxis = new ChartAxes();
-
-    if (isset($options['yaxis_min'])) {
-      $firstVaxis->setMinValue($options['yaxis_min']);
-    }
-
-    if (isset($options['yaxis_view_min'])) {
-      $firstVaxis->setViewWindowValue('min', $options['yaxis_view_min']);
-    }
-
-    if (isset($options['yaxis_view_max'])) {
-      $firstVaxis->setViewWindowValue('max', $options['yaxis_view_max']);
-    }
-
-    if (isset($options['yaxis_max'])) {
-      $firstVaxis->setMaxValue($options['yaxis_max']);
-    }
-
-    // A format string for numeric or date axis labels.
-    if (isset($options['yaxis_title'])) {
-      $firstVaxis->setTitle($options['yaxis_title']);
-    }
-
-    if (isset($options['yaxis_title_color'])) {
-      $firstVaxis->setTitleTextStyleValue('color', $options['yaxis_title_color']);
-    }
-
-    if (isset($options['yaxis_title_font'])) {
-      $firstVaxis->setTitleTextStyleValue('fontName', $options['yaxis_title_font']);
-    }
-
-    if (isset($options['yaxis_title_size'])) {
-      $firstVaxis->setTitleTextStyleValue('fontSize', $options['yaxis_title_size']);
-    }
-
-    if (isset($options['yaxis_title_bold'])) {
-      $firstVaxis->setTitleTextStyleValue('bold', $options['yaxis_title_bold']);
-    }
-
-    if (isset($options['yaxis_title_italic'])) {
-      $firstVaxis->setTitleTextStyleValue('italic', $options['yaxis_title_italic']);
-    }
-
-    // Axis title position.
-    if (isset($options['yaxis_title_position'])) {
-      $firstVaxis->setTextPosition($options['yaxis_title_position']);
-    }
-
-    if (isset($options['yaxis_baseline'])) {
-      $firstVaxis->setBaseline($options['yaxis_baseline']);
-    }
-
-    if (isset($options['yaxis_baseline_color'])) {
-      $firstVaxis->setBaselineColor($options['yaxis_baseline_color']);
-    }
-
-    if (isset($options['yaxis_direction'])) {
-      $firstVaxis->setDirection($options['yaxis_direction']);
-    }
-
-    // A format string for numeric or date axis labels.
-    if (isset($options['yaxis_format'])) {
-      $firstVaxis->setFormat($options['yaxis_format']);
-    }
-
-    if (isset($options['yaxis_view_window_mode'])) {
-      $firstVaxis->setViewWindowMode($options['yaxis_view_window_mode']);
-    }
-
-    $firstHaxis = new ChartAxes();
-
-    if (isset($options['xaxis_min'])) {
-      $firstHaxis->setMinValue($options['xaxis_min']);
-    }
-
-    if (isset($options['xaxis_view_min'])) {
-      $firstHaxis->setViewWindowValue('min', $options['xaxis_view_min']);
-    }
-
-    if (isset($options['xaxis_view_max'])) {
-      $firstHaxis->setViewWindowValue('max', $options['xaxis_view_max']);
-    }
-
-    if (isset($options['xaxis_max'])) {
-      $firstHaxis->setMaxValue($options['xaxis_max']);
-    }
-
-    // A format string for numeric or date axis labels.
-    if (isset($options['xaxis_title'])) {
-      $firstHaxis->setTitle($options['xaxis_title']);
-    }
-
-    if (isset($options['xaxis_title_color'])) {
-      $firstHaxis->setTitleTextStyleValue('color', $options['xaxis_title_color']);
-    }
-
-    if (isset($options['xaxis_title_font'])) {
-      $firstHaxis->setTitleTextStyleValue('fontName', $options['xaxis_title_font']);
-    }
-
-    if (isset($options['xaxis_title_size'])) {
-      $firstHaxis->setTitleTextStyleValue('fontSize', $options['xaxis_title_size']);
-    }
-
-    if (isset($options['xaxis_title_bold'])) {
-      $firstHaxis->setTitleTextStyleValue('bold', $options['xaxis_title_bold']);
-    }
-
-    if (isset($options['xaxis_title_italic'])) {
-      $firstHaxis->setTitleTextStyleValue('italic', $options['xaxis_title_italic']);
-    }
-
-    // Axis title position.
-    if (isset($options['xaxis_title_position'])) {
-      $firstHaxis->setTextPosition($options['xaxis_title_position']);
-    }
-
-    if (isset($options['xaxis_baseline'])) {
-      $firstHaxis->setBaseline($options['xaxis_baseline']);
-    }
-
-    if (isset($options['xaxis_baseline_color'])) {
-      $firstHaxis->setBaselineColor($options['xaxis_baseline_color']);
-    }
-
-    if (isset($options['xaxis_direction'])) {
-      $firstHaxis->setDirection($options['xaxis_direction']);
-    }
-
-    // A format string for numeric or date axis labels.
-    if (isset($options['xaxis_format'])) {
-      $firstHaxis->setFormat($options['xaxis_format']);
-    }
-
-    if (isset($options['xaxis_view_window_mode'])) {
-      $firstHaxis->setViewWindowMode($options['xaxis_view_window_mode']);
-    }
-
-    $vAxes = [];
-    $hAxes = [];
-
-    array_push($vAxes, $firstVaxis);
-    array_push($hAxes, $firstHaxis);
-
-    // Sets secondary axis from the first attachment only.
-    if (!$noAttachmentDisplays && $attachmentDisplayOptions[0]['inherit_yaxis'] == 0) {
-      $secondVaxis = new ChartAxes();
-      $secondVaxis->setTitle($attachmentDisplayOptions[0]['style']['options']['yaxis_title']);
-      array_push($vAxes, $secondVaxis);
-    }
-
-    array_push($chartSelected, $options['type']);
-
-    // @todo: make sure this works for more than one attachment.
-    for ($i = 0; $i < count($attachmentDisplayOptions); $i++) {
-      $attachmentChartType = $attachmentDisplayOptions[$i]['style']['options']['type'];
-
-      if ($attachmentChartType == 'column') {
-        $attachmentChartType = 'bars';
-      }
-
-      if ($attachmentDisplayOptions[$i]['inherit_yaxis'] == 0 && $i == 0) {
-        $seriesTypes[$i + 1] = [
-          'type'            => $attachmentChartType,
-          'targetAxisIndex' => 1,
-        ];
-      }
-      else {
-        $seriesTypes[$i + 1] = ['type' => $attachmentChartType];
-      }
-
-      array_push($chartSelected, $attachmentChartType);
-    }
-
-    $chartSelected = array_unique($chartSelected);
-    $googleOptions = new GoogleOptions();
-
-    if (count($chartSelected) > 1) {
-      $parentChartType = $options['type'];
-
-      if ($parentChartType == 'column') {
-        $parentChartType = 'bars';
-      }
-
-      $googleOptions->seriesType = $parentChartType;
-      $googleOptions->series = $seriesTypes;
-    }
-
-    $googleOptions->setTitle($options['title']);
-
-    if (isset($options['subtitle'])) {
-      $googleOptions->setSubTitle($options['subtitle']);
-    }
-
-    $googleOptions->setVerticalAxes($vAxes);
-    $googleOptions->setHorizontalAxes($hAxes);
-
-    if (in_array('donut', $chartSelected)) {
-      $googleOptions->pieHole = '0.5';
-    }
-
-    $chartArea = new ChartArea();
-
-    // Chart Area width.
-    if (isset($options['chart_area']['width'])) {
-      $chartArea->setWidth($options['chart_area']['width']);
-    }
-
-    // Chart Area height.
-    if (isset($options['chart_area']['height'])) {
-      $chartArea->setHeight($options['chart_area']['height']);
-    }
-
-    // Chart Area padding top.
-    if (isset($options['chart_area']['top'])) {
-      $chartArea->setPaddingTop($options['chart_area']['top']);
-    }
-
-    // Chart Area padding left.
-    if (isset($options['chart_area']['left'])) {
-      $chartArea->setPaddingLeft($options['chart_area']['left']);
-    }
-
-    $seriesColors = [];
-    for ($i = 0; $i < count($seriesData); $i++) {
-      $seriesColor = $seriesData[$i]['color'];
-      array_push($seriesColors, $seriesColor);
-    }
-    $googleOptions->setColors($seriesColors);
-
-    // Width of the chart, in pixels.
-    if (isset($options['width'])) {
-      $googleOptions->setWidth($options['width']);
-    }
-
-    // Height of the chart, in pixels.
-    if (isset($options['height'])) {
-      $googleOptions->setHeight($options['height']);
-    }
-
-    // Determines if chart is three-dimensional.
-    if (isset($options['three_dimensional'])) {
-      $googleOptions->setThreeDimensional($options['three_dimensional']);
-    }
-
-    // Determines if chart is stacked.
-    if (!empty($options['grouping'])) {
-      $options['grouping'] = TRUE;
-      $googleOptions->setStacking($options['grouping']);
-    }
-
-    // 'legend' can be a string (for position) or an array with legend
-    // properties: [position: 'top', textStyle: [color: 'blue', fontSize: 16]].
-    if (isset($options['legend'])) {
-      $googleOptions->setLegend($options['legend']);
-    }
-
-    // Set legend position.
-    if (isset($options['legend_position'])) {
-      if (empty($options['legend_position'])) {
-        $options['legend_position'] = 'none';
-        $googleOptions->setLegend($options['legend_position']);
-      }
-      else {
-        $googleOptions->setLegend($options['legend_position']);
-      }
-    }
-
-    // Where to place the chart title, compared to the chart area.
-    if (isset($options['title_position'])) {
-      $googleOptions->setTitlePosition($options['title_position']);
-    }
-
-    // Where to place the axis titles, compared to the chart area.
-    if (isset($options['axis_titles_position'])) {
-      $googleOptions->setAxisTitlesPosition($options['axis_titles_position']);
-    }
-
-    return $googleOptions;
-  }
-
-  /**
-   * Create Chart Type.
-   *
-   * @param array $options
-   *   Options.
-   *
-   * @return \Drupal\charts_google\Settings\Google\ChartType
-   *   ChartType.
-   */
-  private function createChartType(array $options = []) {
-    $googleChartType = new ChartType();
-    $googleChartType->setChartType($options['type']);
-
-    return $googleChartType;
-  }
-
-}
diff --git a/modules/charts_google/src/Plugin/chart/GoogleCharts.php b/modules/charts_google/src/Plugin/chart/Google.php
similarity index 98%
rename from modules/charts_google/src/Plugin/chart/GoogleCharts.php
rename to modules/charts_google/src/Plugin/chart/Google.php
index 679893f..ed66022 100644
--- a/modules/charts_google/src/Plugin/chart/GoogleCharts.php
+++ b/modules/charts_google/src/Plugin/chart/Google.php
@@ -13,13 +13,13 @@ use Drupal\charts_google\Settings\Google\ChartAxes;
  *
  * @Chart(
  *   id = "google",
- *   name = @Translation("Google charts")
+ *   name = @Translation("Google")
  * )
  */
-class GoogleCharts extends AbstractChart {
+class Google extends AbstractChart {
 
   /**
-   * Creates a JSON Object formatted for Google charts to use.
+   * Creates a JSON Object formatted for Google Charts JavaScript to use.
    *
    * @param mixed $options
    *   Options.
@@ -72,6 +72,7 @@ class GoogleCharts extends AbstractChart {
     $variables['content_attributes']['data-chart'][] = json_encode($dataTable);
     $variables['attributes']['google-options'][1] = json_encode($googleOptions);
     $variables['attributes']['google-chart-type'][2] = json_encode($googleChartType);
+
   }
 
   /**
@@ -92,7 +93,7 @@ class GoogleCharts extends AbstractChart {
     $noAttachmentDisplays = count($attachmentDisplayOptions) === 0;
 
     $chartSelected = [];
-    $seriesTypes   = [];
+    $seriesTypes = [];
 
     $firstVaxis = new ChartAxes();
 
@@ -279,7 +280,7 @@ class GoogleCharts extends AbstractChart {
       }
 
       $googleOptions->seriesType = $parentChartType;
-      $googleOptions->series     = $seriesTypes;
+      $googleOptions->series = $seriesTypes;
     }
 
     $googleOptions->setTitle($options['title']);
diff --git a/modules/charts_highcharts/src/Charts/HighchartsChartsRender.php b/modules/charts_highcharts/src/Charts/HighchartsChartsRender.php
deleted file mode 100644
index 0a0e65e..0000000
--- a/modules/charts_highcharts/src/Charts/HighchartsChartsRender.php
+++ /dev/null
@@ -1,217 +0,0 @@
-<?php
-
-namespace Drupal\charts_highcharts\Charts;
-
-use Drupal\charts\Charts\ChartsRenderInterface;
-use Drupal\charts\Util\Util;
-use Drupal\charts_highcharts\Settings\Highcharts\Chart;
-use Drupal\charts_highcharts\Settings\Highcharts\ChartTitle;
-use Drupal\charts_highcharts\Settings\Highcharts\ExportingOptions;
-use Drupal\charts_highcharts\Settings\Highcharts\PlotOptionsStacking;
-use Drupal\charts_highcharts\Settings\Highcharts\Xaxis;
-use Drupal\charts_highcharts\Settings\Highcharts\XaxisTitle;
-use Drupal\charts_highcharts\Settings\Highcharts\ChartLabel;
-use Drupal\charts_highcharts\Settings\Highcharts\YaxisLabel;
-use Drupal\charts_highcharts\Settings\Highcharts\Yaxis;
-use Drupal\charts_highcharts\Settings\Highcharts\YaxisTitle;
-use Drupal\charts_highcharts\Settings\Highcharts\PlotOptions;
-use Drupal\charts_highcharts\Settings\Highcharts\PlotOptionsSeries;
-use Drupal\charts_highcharts\Settings\Highcharts\PlotOptionsSeriesDataLabels;
-use Drupal\charts_highcharts\Settings\Highcharts\Tooltip;
-use Drupal\charts_highcharts\Settings\Highcharts\ChartCredits;
-use Drupal\charts_highcharts\Settings\Highcharts\ChartLegend;
-use Drupal\charts_highcharts\Settings\Highcharts\Highcharts;
-
-/**
- * Highcharts Charts Render.
- */
-class HighchartsChartsRender implements ChartsRenderInterface {
-
-  /**
-   * Construct.
-   */
-  public function __construct() {
-    Util::checkMissingLibrary('libraries/highcharts/highcharts.js');
-    Util::checkMissingLibrary('libraries/highcharts_accessibility/accessibility.js');
-    Util::checkMissingLibrary('libraries/highcharts_export-data/export-data.js');
-    Util::checkMissingLibrary('libraries/highcharts_exporting/exporting.js');
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function chartsRenderCharts(array $options = [], array $categories = [], array $seriesData = [], array $attachmentDisplayOptions = [], array &$variables = [], $chartId = '') {
-    $noAttachmentDisplays = count($attachmentDisplayOptions) === 0;
-
-    $chart = new Chart();
-    $typeOptions = $options['type'];
-    // @todo: make this so that it happens if any display uses donut.
-    if ($typeOptions == 'donut') {
-      $typeOptions = 'pie';
-      // Remove donut from seriesData.
-      foreach ($seriesData as &$value) {
-        $value = str_replace('donut', 'pie', $value);
-      }
-      // Add innerSize to differentiate between donut and pie.
-      foreach ($seriesData as &$value) {
-        if ($typeOptions == 'pie') {
-          $innerSize['showInLegend'] = 'true';
-          $innerSize['innerSize'] = '40%';
-          $chartPlacement = array_search($value, $seriesData);
-          $seriesData[$chartPlacement] = array_merge($innerSize, $seriesData[$chartPlacement]);
-        }
-      }
-    }
-    $chart->setType($typeOptions);
-
-    // Set chart width.
-    if (isset($options['width'])) {
-      $chart->setWidth($options['width']);
-    }
-
-    // Set chart height.
-    if (isset($options['height'])) {
-      $chart->setHeight($options['height']);
-    }
-
-    // Set chart title.
-    $chartTitle = new ChartTitle();
-    if (isset($options['title'])) {
-      $chartTitle->setText($options['title']);
-    }
-
-    // Set background color.
-    if (isset($options['background'])) {
-      $chart->setBackgroundColor($options['background']);
-    }
-
-    // Set polar plotting.
-    if (isset($options['polar'])) {
-      $chart->setPolar($options['polar']);
-    }
-
-    // Set title position.
-    if (isset($options['title_position'])) {
-      if ($options['title_position'] == 'in') {
-        $chartTitle->setVerticalAlign('middle');
-      }
-      else {
-        $chartTitle->setVerticalAlign('top');
-      }
-    }
-
-    $chartXaxis = new Xaxis();
-    $chartLabels = new ChartLabel();
-
-    // Set x-axis label rotation.
-    if (isset($options['xaxis_labels_rotation'])) {
-      $chartLabels->setRotation($options['xaxis_labels_rotation']);
-    }
-
-    $chartXaxis->setCategories($categories);
-
-    // Set x-axis title.
-    $xAxisTitle = new XaxisTitle();
-    if (isset($options['xaxis_title'])) {
-      $xAxisTitle->setText($options['xaxis_title']);
-    }
-    $chartXaxis->setTitle($xAxisTitle);
-    $chartXaxis->setLabels($chartLabels);
-    $yaxisLabels = new YaxisLabel();
-    $chartYaxis = new Yaxis();
-    $yAxes = [];
-    $yAxisTitle = new YaxisTitle();
-    $yAxisTitle->setText($options['yaxis_title']);
-    if (is_numeric($options['yaxis_min'])) {
-      $chartYaxis->min = $options['yaxis_min'];
-    }
-    if (is_numeric($options['yaxis_max'])) {
-      $chartYaxis->max = $options['yaxis_max'];
-    }
-
-    $chartYaxis->setLabels($yaxisLabels);
-    $chartYaxis->setTitle($yAxisTitle);
-    array_push($yAxes, $chartYaxis);
-
-    // Chart libraries tend to support only one secondary axis.
-    if (!$noAttachmentDisplays && $attachmentDisplayOptions[0]['inherit_yaxis'] == 0) {
-      $chartYaxisSecondary = new Yaxis();
-      $yAxisTitleSecondary = new YaxisTitle();
-      $yAxisTitleSecondary->setText($attachmentDisplayOptions[0]['style']['options']['yaxis_title']);
-      $chartYaxisSecondary->setTitle($yAxisTitleSecondary);
-      $chartYaxisSecondary->setLabels($yaxisLabels);
-      $chartYaxisSecondary->opposite = 'true';
-      if (!empty($attachmentDisplayOptions[0]['style']['options']['yaxis_min'])) {
-        $chartYaxisSecondary->min = $attachmentDisplayOptions[0]['style']['options']['yaxis_min'];
-      }
-      if (!empty($attachmentDisplayOptions[0]['style']['options']['yaxis_max'])) {
-        $chartYaxisSecondary->max = $attachmentDisplayOptions[0]['style']['options']['yaxis_max'];
-      }
-      array_push($yAxes, $chartYaxisSecondary);
-    }
-
-    // Set plot options.
-    $plotOptions = new PlotOptions();
-    $plotOptionsStacking = new PlotOptionsStacking();
-    $plotOptionsSeries = new PlotOptionsSeries();
-    $plotOptionsSeriesDataLabels = new PlotOptionsSeriesDataLabels();
-    // Set plot options if stacked chart.
-    if (!empty($options['grouping'])) {
-      $plotOptions->setPlotSeries($plotOptionsStacking);
-      $plotOptionsStacking->setDataLabels($plotOptionsSeriesDataLabels);
-    }
-    else {
-      $plotOptions->setPlotSeries($plotOptionsSeries);
-      $plotOptionsSeries->setDataLabels($plotOptionsSeriesDataLabels);
-    }
-    if (isset($options['data_labels'])) {
-      $plotOptionsSeriesDataLabels->setEnabled($options['data_labels']);
-    }
-
-    // Set Tooltip.
-    $chartTooltip = new Tooltip();
-    if (isset($options['tooltips'])) {
-      $chartTooltip->setEnabled($options['tooltips']);
-    }
-    $chartCredits = new ChartCredits();
-
-    // Set charts legend.
-    $chartLegend = new ChartLegend();
-    if (empty($options['legend_position'])) {
-      $chartLegend->setEnabled(FALSE);
-    }
-    elseif (in_array($options['legend_position'], ['left', 'right'])) {
-      $chartLegend->setAlign($options['legend_position']);
-      $chartLegend->setVerticalAlign('top');
-      if ($options['legend_position'] == 'left') {
-        $chartLegend->setX('0');
-      }
-    }
-    else {
-      $chartLegend->setVerticalAlign($options['legend_position']);
-      $chartLegend->setAlign('center');
-      $chartLegend->setX('0');
-      $chartLegend->setY('0');
-    }
-
-    // Set exporting options.
-    $exporting = new ExportingOptions($options['exporting'] ?: []);
-
-    $highchart = new Highcharts();
-    $highchart->setChart($chart);
-    $highchart->setTitle($chartTitle);
-    $highchart->setAxisX($chartXaxis);
-    $highchart->setAxisY($chartYaxis);
-    $highchart->setTooltip($chartTooltip);
-    $highchart->setPlotOptions($plotOptions);
-    $highchart->setCredits($chartCredits);
-    $highchart->setLegend($chartLegend);
-    $highchart->setSeries($seriesData);
-    $highchart->setExporting($exporting);
-    $variables['chart_type'] = 'highcharts';
-    $variables['content_attributes']['data-chart'][] = json_encode($highchart);
-    $variables['attributes']['id'][0] = $chartId;
-    $variables['attributes']['class'][] = 'charts-highchart';
-  }
-
-}
diff --git a/modules/charts_highcharts/src/Plugin/chart/Highchart.php b/modules/charts_highcharts/src/Plugin/chart/Highcharts.php
similarity index 98%
rename from modules/charts_highcharts/src/Plugin/chart/Highchart.php
rename to modules/charts_highcharts/src/Plugin/chart/Highcharts.php
index 0b802e6..786f864 100644
--- a/modules/charts_highcharts/src/Plugin/chart/Highchart.php
+++ b/modules/charts_highcharts/src/Plugin/chart/Highcharts.php
@@ -29,10 +29,10 @@ use Drupal\charts_highcharts\Settings\Highcharts\Highcharts;
  *   name = @Translation("Highcharts")
  * )
  */
-class Highchart extends AbstractChart {
+class Highcharts extends AbstractChart {
 
   /**
-   * Creates a JSON Object formatted for Google charts to use.
+   * Creates a JSON Object formatted for Highcharts JavaScript to use.
    *
    * @param mixed $options
    *   Options.
-- 
GitLab