You are here

public function SeriesToggle::content in Flot 8

Function seriesToggle.

1 string reference to 'SeriesToggle::content'
flot_examples.routing.yml in flot_examples/flot_examples.routing.yml
flot_examples/flot_examples.routing.yml

File

flot_examples/src/Controller/SeriesToggle.php, line 15

Class

SeriesToggle
Display a chart demonstrating hiding series.

Namespace

Drupal\flot_examples\Controller

Code

public function content() {
  $data = $this::getData();
  $data['usa']['label'] = $this
    ->t('USA');
  $data['russia']['label'] = $this
    ->t('Russia');
  $data['uk']['label'] = $this
    ->t('UK');
  $data['germany']['label'] = $this
    ->t('Germany');
  $data['denmark']['label'] = $this
    ->t('Demmark');
  $data['sweden']['label'] = $this
    ->t('Sweden');
  $data['norway']['label'] = $this
    ->t('Norway');
  $options = [
    'yaxis' => [
      'min' => 0,
    ],
    'xaxis' => [
      'tickDecimals' => 0,
    ],
  ];
  $text = [];
  $array = [
    ':one' => 'http://www.sipri.org/',
  ];
  $text[] = $this
    ->t('This example shows military budgets for various countries in constant (2005) million US dollars (source: <a href=":one">SIPRI</a>).', $array);
  $text[] = $this
    ->t("Since all data is available client-side, it's pretty easy to make the plot interactive. Try turning countries on and off with the checkboxes next to the plot.");
  $output['flot'] = [
    '#type' => 'flot',
    '#theme' => 'flot_examples_series_toggle',
    '#options' => $options,
    '#data' => $data,
    '#text' => $text,
  ];
  return $output;
}