Beispiel #1
0
 /**
  * @param string $filepath
  * @return array
  */
 public function convertToArray($filepath)
 {
     $reader = Reader::createFromPath($filepath);
     $reader->setDelimiter(',');
     $date = $reader->setOffset(5)->fetchColumn(0);
     $mbps = $reader->setOffset(5)->fetchColumn(5);
     $date = array_slice($date, 0, count($mbps));
     $data_unprocessed = array_combine($date, $mbps);
     $data = [];
     foreach ($data_unprocessed as $thisDate => $thisMbps) {
         $datetime = new \DateTime($thisDate);
         $index1 = Helper::hashToFirstIndex($datetime);
         $index2 = Helper::hashToSecondIndex($datetime);
         $time = Helper::indexToTime($index2);
         //            $data[$index1][$index2] = ['mbps' => floatval($thisMbps), 'time' => $time_str];
         $data[$index1][$index2] = floatval($thisMbps);
     }
     return $data;
 }
Beispiel #2
0
 /**
  * @dataProvider secondIndexProvider
  */
 public function testIndexToSecondIndex($timestamp, $expectedIndex)
 {
     $datetime = new \DateTime($timestamp);
     $result = Helper::hashToSecondIndex($datetime);
     $this->assertSame($expectedIndex, $result, "Helper::hashToSecondIndex('{$timestamp}') should be {$expectedIndex}.");
 }
Beispiel #3
0
            <?php 
foreach ($keys as $key) {
    $year = substr($key, 0, 4);
    $month = substr($key, 4, 2);
    $day = substr($key, 6, 2);
    $label = "{$day}.{$month}.{$year}";
    echo "\t\t\tdata.addColumn('number', '" . $label . "');" . PHP_EOL;
}
?>

            data.addRows([
                <?php 
//[13,  4.8,  6.3,  3.6],
// [14,  4.2,  6.2,  3.4]
foreach (range(0, 95) as $index) {
    $date_str = \JK\DslAnalytics\Helper::indexToTimeString($index);
    $output = "\t\t\t\t[\"{$date_str}\", ";
    $speeds = [];
    foreach ($keys as $key) {
        $speeds[] = isset($data[$key][$index]) ? $data[$key][$index] : 'null';
    }
    $output .= join(', ', $speeds);
    $output .= '],';
    echo $output . PHP_EOL;
}
?>
            ]);

            var options = {
                chart: {
                    title: 'Download-Bandbreite im Tagesverlauf',