You are here

public function Ajax::json2 in Flot 8

Function realtime.

1 string reference to 'Ajax::json2'
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 110

Class

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

Namespace

Drupal\flot_examples\Controller

Code

public function json2($id) {
  $data_set = [
    [
      1999,
      -0.1,
    ],
    [
      2000,
      2.9,
    ],
    [
      2001,
      0.2,
    ],
    [
      2002,
      0.3,
    ],
    [
      2003,
      1.4,
    ],
    [
      2004,
      2.7,
    ],
    [
      2005,
      1.9,
    ],
    [
      2006,
      2.0,
    ],
    [
      2007,
      2.3,
    ],
    [
      2008,
      -0.7,
    ],
  ];
  $data_slice = array_slice($data_set, 0, $id);
  $data = array(
    'label' => 'Japan',
    'data' => $data_slice,
  );
  return new JsonResponse($data);
}