You are here

protected function ChartsPluginStyleChart::defineOptions in Charts 8

Same name and namespace in other branches
  1. 8.4 src/Plugin/views/style/ChartsPluginStyleChart.php \Drupal\charts\Plugin\views\style\ChartsPluginStyleChart::defineOptions()
  2. 8.3 src/Plugin/views/style/ChartsPluginStyleChart.php \Drupal\charts\Plugin\views\style\ChartsPluginStyleChart::defineOptions()
  3. 5.0.x src/Plugin/views/style/ChartsPluginStyleChart.php \Drupal\charts\Plugin\views\style\ChartsPluginStyleChart::defineOptions()

Set default options.

Overrides StylePluginBase::defineOptions

File

src/Plugin/views/style/ChartsPluginStyleChart.php, line 34

Class

ChartsPluginStyleChart
Style plugin to render view as a chart.

Namespace

Drupal\charts\Plugin\views\style

Code

protected function defineOptions() {
  $options = parent::defineOptions();

  // Get the default chart values.
  $defaults = \Drupal::state()
    ->get('charts_default_settings', array());
  $defaults += charts_default_settings();
  foreach ($defaults as $default_key => $default_value) {
    $options[$default_key]['default'] = $default_value;
  }

  // Remove the default setting for chart type so it can be inherited if this
  // is a chart extension type.
  if ($this->view->style_plugin === 'chart_extension') {
    $options['type']['default'] = NULL;
  }
  $options['path'] = array(
    'default' => 'charts',
  );
  return $options;
}