You are here

private function AxesMultiple::getData in Flot 8

Fetch the raw data from the data file.

File

flot_examples/src/Controller/AxesMultiple.php, line 52

Class

AxesMultiple
Displays a graph to demonstrate multiple axes.

Namespace

Drupal\flot_examples\Controller

Code

private function getData($filename) {
  $data = [];
  $file_path = DRUPAL_ROOT . '/' . drupal_get_path('module', 'flot_examples') . '/src/Controller/' . $filename;
  $file = fopen($file_path, "r") or die("Unable to open file: {$file_path}");
  while (!feof($file)) {
    $line = fgets($file);
    $values = explode(', ', $line);
    if (count($values) == 2) {
      $data[] = [
        $values[0],
        $values[1],
      ];
    }
  }
  fclose($file);
  return $data;
}