You are here

public function Ajax::json1 in Flot 8

Function realtime.

1 string reference to 'Ajax::json1'
flot_examples.routing.yml in flot_examples/flot_examples.routing.yml
flot_examples/flot_examples.routing.yml

File

flot_examples/src/Controller/Ajax.php, line 93

Class

Ajax
Displays a graph to demonstrate the AJAX capabilities of FLOT.

Namespace

Drupal\flot_examples\Controller

Code

public function json1($id) {
  $data_set = [
    [
      1999,
      3.0,
    ],
    [
      2000,
      3.9,
    ],
    [
      2001,
      2.0,
    ],
    [
      2002,
      1.2,
    ],
    [
      2003,
      1.3,
    ],
    [
      2004,
      2.5,
    ],
    [
      2005,
      2.0,
    ],
    [
      2006,
      3.1,
    ],
    [
      2007,
      2.9,
    ],
    [
      2008,
      0.9,
    ],
  ];
  $data_slice = array_slice($data_set, 0, $id);
  $data = array(
    'label' => 'Europe (EU27)',
    'data' => $data_slice,
  );
  return new JsonResponse($data);
}