private function Visitors::getData in Flot 8
Fetch the data from the raw text file.
File
- flot_examples/
src/ Controller/ Visitors.php, line 66
Class
- Visitors
- Demonstrate using two plots to control zooming in and out.
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;
}