/** * Chart showing the % places filled for each event */ private function produceCompetitionsFilledChart($competitions) { $competitionsChart = new Lavacharts(); $competitionsTable = $competitionsChart->DataTable(); $competitionsTable->addStringColumn('Competition')->addNumberColumn('Percent full'); foreach ($competitions as $competition) { $max = 0; $entries = 0; foreach ($competition->details()->get() as $detail) { $entries += $detail->entries()->get()->count(); $max += $detail->max; } if ($max > 0 && $entries > 0) { $percentage = sprintf('%0.2f', $entries / $max * 100); $competitionsTable->addRow([$competition->name, $percentage]); } } $competitionsChart->BarChart('CompetitionsFilled', $competitionsTable, ['title' => 'Places already filled (%) for each competition', 'legend' => ['position' => 'bottom'], 'max' => 100, 'min' => 0, 'height' => 350]); return $competitionsChart; }
<?php use BenchmarkPHP\UserAgentParser\Helper; use Khill\Lavacharts\Lavacharts; require_once __DIR__ . '/vendor/autoload.php'; $results = json_decode(file_get_contents('cache/benchmark-results.json'), true); $lava = new Lavacharts(); $data = $lava->DataTable(); $data->addStringColumn('User Agent Parser')->addNumberColumn('Execution Time (s)')->addNumberColumn('Memory Used (MB)'); foreach ($results as $libraryName => $result) { $data->addRow([$libraryName, round($result['time'], 2), round($result['memory'] / (1024 * 1024), 2)]); } $lava->BarChart('Benchmark Results', $data, ['title' => 'User Agent Parser Benchmark', 'barGroupWidth' => 50]); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> <meta name="description" content=""> <meta name="author" content=""> <link rel="icon" href=""> <title>Starter Template for Bootstrap</title> <!-- Bootstrap core CSS --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous"> <!-- Optional theme -->