php-histogram/examples/basic.php

26 lines
635 B
PHP
Raw Permalink Normal View History

2020-05-15 20:46:19 +00:00
<?php
require_once __DIR__."/../vendor/autoload.php";
$histogram = new NoccyLabs\Histogram\Output\TerminalHistogram(40);
$buffer = $histogram->getBuffer();
for ($n = 0; $n<40; $n++) {
$s = sin($n/5) + 1;
$buffer->pushSamples($s);
}
//$buffer->pushSamples(0.0, 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.5, 0.7, 0.9, 1.0, 1.1, 1.5, 1.0, 0.9, 0.7, null, 0.4, null, 0.3);
echo $histogram . "\n\n";
echo join("\n", $histogram->getMultiHistogram(3)) . "\n\n";
$histogram->setMax(2.0);
echo join("\n", $histogram->getMultiHistogram(3)) . "\n\n";
$histogram->setMax(5.0);
echo join("\n", $histogram->getMultiHistogram(3)) . "\n\n";