private function AxesTime::getData in Flot 8
Fetch the raw data from the data file.
File
- flot_examples/
src/ Controller/ AxesTime.php, line 85
Class
- AxesTime
- Display a chart to demontrate date/time handling on the axes.
Namespace
Drupal\flot_examples\ControllerCode
private function getData($filename) {
$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}");
$data = [];
while (!feof($file)) {
$line = fgets($file);
$values = explode(', ', $line);
if (count($values) == 2) {
$data[] = [
$values[0],
$values[1],
];
}
}
fclose($file);
return $data;
}