You are here

private function ParagraphsTableFormatter::googleChartsOption in Paragraphs table 8

Support google chart.

2 calls to ParagraphsTableFormatter::googleChartsOption()
ParagraphsTableFormatter::settingsForm in src/Plugin/Field/FieldFormatter/ParagraphsTableFormatter.php
Returns a form to configure settings for the formatter.
ParagraphsTableFormatter::viewElements in src/Plugin/Field/FieldFormatter/ParagraphsTableFormatter.php
Builds a renderable array for a field value.

File

src/Plugin/Field/FieldFormatter/ParagraphsTableFormatter.php, line 1013

Class

ParagraphsTableFormatter
Plugin implementation of the 'paragraphs_table_formatter' formatter.

Namespace

Drupal\paragraphs_table\Plugin\Field\FieldFormatter

Code

private function googleChartsOption($option = FALSE) {
  $options = [
    'BarChart' => [
      'title' => $this
        ->t('Bar'),
      'option' => [
        'bar' => [
          'groupWidth' => "95%",
        ],
        'legend' => [
          'position' => "none",
        ],
      ],
    ],
    'BubbleChart' => [
      'title' => $this
        ->t('Bubble'),
      'option' => [
        'bubble' => [
          'textStyle' => [
            'fontSize' => 11,
          ],
        ],
      ],
    ],
    'LineChart' => [
      'title' => $this
        ->t('Line'),
      'option' => [
        'legend' => [
          'position' => "bottom",
        ],
        'curveType' => 'function',
      ],
    ],
    'ColumnChart' => [
      'title' => $this
        ->t('Column'),
      'option' => [
        'bar' => [
          'groupWidth' => "95%",
        ],
        'legend' => [
          'position' => "none",
        ],
      ],
    ],
    'ComboChart' => [
      'title' => $this
        ->t('Combo'),
      'option' => [
        'seriesType' => 'bars',
      ],
    ],
    'PieChart' => [
      'title' => $this
        ->t('Pie'),
      'option' => [
        'is3D' => TRUE,
      ],
    ],
    'ScatterChart' => [
      'title' => $this
        ->t('Scatter'),
      'option' => [
        'legend' => [
          'position' => "none",
        ],
      ],
    ],
    'SteppedAreaChart' => [
      'title' => $this
        ->t('Stepped Area'),
      'option' => [
        'isStacked' => TRUE,
      ],
    ],
    'AreaChart' => [
      'title' => $this
        ->t('Area'),
      'option' => [
        'legend' => [
          'position' => "top",
          'maxLines' => 3,
        ],
        'isStacked' => 'relative',
      ],
    ],
    'Histogram' => [
      'title' => $this
        ->t('Histogram'),
      'option' => [
        'legend' => [
          'position' => "top",
          'maxLines' => 3,
        ],
        'interpolateNulls' => FALSE,
      ],
    ],
    'CandlestickChart' => [
      'title' => $this
        ->t('Candlestick'),
      'option' => [
        'notHeader' => TRUE,
        'legend' => 'none',
        'bar' => [
          'groupWidth' => '100%',
        ],
      ],
    ],
  ];
  if ($option) {
    return $options[$option]['option'];
  }
  $titleOptions = [];
  foreach ($options as $type => $option) {
    $titleOptions[$type] = $option['title'];
  }
  return $titleOptions;
}