You are here

public function Symbols::content in Flot 8

Symbols.

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

File

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

Class

Symbols
Generate a chart using different point symbols.

Namespace

Drupal\flot_examples\Controller

Code

public function content() {
  $data = [];
  $series = $this
    ->generate(2, 1.8);
  $data[] = [
    'data' => $series,
    'points' => [
      'symbol' => 'circle',
    ],
  ];
  $series = $this
    ->generate(3, 1.5);
  $data[] = [
    'data' => $series,
    'points' => [
      'symbol' => 'square',
    ],
  ];
  $data[] = [
    'data' => $this
      ->generate(4, 0.9),
    'points' => [
      'symbol' => 'diamond',
    ],
  ];
  $data[] = [
    'data' => $this
      ->generate(6, 1.4),
    'points' => [
      'symbol' => 'triangle',
    ],
  ];
  $data[] = [
    'data' => $this
      ->generate(7, 1.1),
    'points' => [
      'symbol' => 'cross',
    ],
  ];
  $options = [
    'series' => [
      'points' => [
        'show' => TRUE,
        'radius' => 3,
      ],
    ],
    'grid' => [
      'hoverable' => TRUE,
    ],
  ];
  $text = [];
  $text[] = $this
    ->t('Points can be marked in several ways, with circles being the built-in default. For other point types, you can define a callback function to draw the symbol. Some common symbols are available in the symbol plugin.');
  $output[] = [
    '#type' => 'flot',
    '#theme' => 'flot_examples',
    '#options' => $options,
    '#data' => $data,
    '#text' => $text,
  ];
  return $output;
}