You are here

class ChartsTypeInfo in Charts 8.3

Hierarchy

Expanded class hierarchy of ChartsTypeInfo

5 files declare their use of ChartsTypeInfo
ChartsBaseSettingsForm.php in src/Settings/ChartsBaseSettingsForm.php
ChartsBaseSettingsFormTest.php in tests/src/Unit/Settings/ChartsBaseSettingsFormTest.php
ChartsPluginStyleChart.php in src/Plugin/views/style/ChartsPluginStyleChart.php
ChartsTypeInfoTest.php in tests/src/Unit/Settings/ChartsTypeInfoTest.php
ExposedChartType.php in src/Plugin/views/field/ExposedChartType.php

File

src/Settings/ChartsTypeInfo.php, line 8

Namespace

Drupal\charts\Settings
View source
class ChartsTypeInfo {
  use StringTranslationTrait;
  public function __construct() {
    $translation = \Drupal::service('string_translation');
    $this
      ->setStringTranslation($translation);
  }

  /**
   * Get charts types info.
   *
   * @return array
   *   Chart types.
   */
  public function chartsChartsTypeInfo() {
    $chart_types['area'] = [
      'label' => $this
        ->t('Area'),
      'axis' => ChartsInterface::CHARTS_DUAL_AXIS,
      'stacking' => TRUE,
    ];
    $chart_types['bar'] = [
      'label' => $this
        ->t('Bar'),
      'axis' => ChartsInterface::CHARTS_DUAL_AXIS,
      'axis_inverted' => TRUE,
      'stacking' => TRUE,
    ];
    $chart_types['column'] = [
      'label' => $this
        ->t('Column'),
      'axis' => ChartsInterface::CHARTS_DUAL_AXIS,
      'stacking' => TRUE,
    ];
    $chart_types['donut'] = [
      'label' => $this
        ->t('Donut'),
      'axis' => ChartsInterface::CHARTS_SINGLE_AXIS,
    ];
    $chart_types['gauge'] = [
      'label' => $this
        ->t('Gauge'),
      'axis' => ChartsInterface::CHARTS_SINGLE_AXIS,
      'stacking' => FALSE,
    ];
    $chart_types['line'] = [
      'label' => $this
        ->t('Line'),
      'axis' => ChartsInterface::CHARTS_DUAL_AXIS,
    ];
    $chart_types['pie'] = [
      'label' => $this
        ->t('Pie'),
      'axis' => ChartsInterface::CHARTS_SINGLE_AXIS,
    ];
    $chart_types['scatter'] = [
      'label' => $this
        ->t('Scatter'),
      'axis' => ChartsInterface::CHARTS_DUAL_AXIS,
    ];
    $chart_types['spline'] = [
      'label' => $this
        ->t('Spline'),
      'axis' => ChartsInterface::CHARTS_DUAL_AXIS,
    ];
    return $chart_types;
  }
  public function getChartTypes() {
    $chart_types = $this
      ->chartsChartsTypeInfo();
    $type_options = [];
    foreach ($chart_types as $chart_type => $chart_type_info) {
      $type_options[$chart_type] = $chart_type_info['label'];
    }
    return $type_options;
  }

  /**
   * Retrieve a specific chart type.
   *
   * @param string $chart_type
   *   The type of chart selected for display.
   *
   * @return mixed
   *   If not false, returns an array of values from charts_charts_type_info.
   */
  public function getChartType($chart_type) {
    $types = $this
      ->chartsChartsTypeInfo();
    return isset($types[$chart_type]) ? $types[$chart_type] : FALSE;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ChartsTypeInfo::chartsChartsTypeInfo public function Get charts types info.
ChartsTypeInfo::getChartType public function Retrieve a specific chart type.
ChartsTypeInfo::getChartTypes public function
ChartsTypeInfo::__construct public function
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.