mirror of
https://github.com/seigler/neat-charts
synced 2025-07-26 17:06:09 +00:00
feat: add background fill, begin work on x-axis
This commit is contained in:
parent
eb9a5e9279
commit
d59dd86f14
6 changed files with 54 additions and 35 deletions
|
@ -1,18 +1,23 @@
|
|||
<?php
|
||||
require_once 'vendor/autoload.php';
|
||||
|
||||
$chartData = [];
|
||||
$offset = 100 * (rand()/getRandMax())**4;
|
||||
$scale = 100 * (rand()/getRandMax())**2;
|
||||
$volatility = 0.5 * (rand()/getRandMax())**3;
|
||||
for ($n = 0, $current = $offset + 0.5 * $scale; $n < 24; $n++) {
|
||||
$current -= $offset;
|
||||
$current *= 1 + $volatility * (rand()/getRandMax() - 0.5);
|
||||
$current += $offset;
|
||||
$chartData[$n] = $current;
|
||||
function randomData($count = 20, $offsetMax = 100) {
|
||||
$randomData = [];
|
||||
$duration = 60 * 5 + rand() * 60 * 60 * 24;
|
||||
$begin = time() - $duration;
|
||||
$offset = $offsetMax * (rand()/getRandMax())**2;
|
||||
$scale = max(0.25 * $offset, 100 * rand() / getRandMax());
|
||||
$volatility = 0.25 * (rand()/getRandMax())**3 + 0.25;
|
||||
for ($n = 0, $current = $offset + 0.5 * $scale; $n < $count; $n++) {
|
||||
$current -= $offset;
|
||||
$current *= 1 + $volatility * (rand()/getRandMax() - 0.5);
|
||||
$current += $offset;
|
||||
$randomData[$begin + $duration / $count * $n] = $current;
|
||||
}
|
||||
return $randomData;
|
||||
}
|
||||
|
||||
$chart = new NeatCharts\LineChart($chartData, [
|
||||
$chart = new NeatCharts\LineChart(randomData(), [
|
||||
'width'=>500,
|
||||
'height'=>400,
|
||||
'lineColor'=>'#00F',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue