A simple interface for Downsampling algorithms
Add the webit/downsampling into composer.json
{
"require": {
"php": ">=7.1",
"webit/downsampling": "^2.0.0"
}
}
use Webit\DownSampling\DownSampler\LargestTriangleThreeBucketsDownSampler;
$data = array();
for ($i=0; $i < 500; $i++) {
$data[] = [$i, mt_rand(0, 200)];
}
$sampler = new LargestTriangleThreeBucketsDownSampler();
$sampled = $sampler->sampleDown($data, 100);
echo count($sampled); // displays 100
- Largest-Triangle-Three-Buckets or LTTB (PHP port of flot-downsample, see: https://github.com/sveinn-steinarsson/flot-downsample)