private function Canvas::getData in Flot 8
Fetch the raw data from the data file.
File
- flot_examples/
src/ Controller/ Canvas.php, line 61
Class
- Canvas
- Display a chart in canvas mode.
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;
}