forked from kenjis/php-framework-benchmark
/
make_graph.php
42 lines (36 loc) · 1.44 KB
/
make_graph.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
require __DIR__ . '/php-recipe-2nd/make_chart_parts.php';
function make_graph($id, $title, $hAxis_title)
{
global $results;
$barColors = array(
'DarkBlue', 'DarkCyan', 'DarkGoldenRod', 'DarkGray', 'DarkGreen',
'DarkKhaki', 'DarkMagenta', 'DarkOliveGreen', 'DarkOrange', 'DarkOrchid',
'DarkRed', 'DarkSalmon', 'DarkSeaGreen', 'DarkSlateBlue', 'DarkSlateGray',
'DarkBlue', 'DarkCyan', 'DarkGoldenRod', 'DarkGray', 'DarkGreen',
'DarkKhaki', 'DarkMagenta', 'DarkOliveGreen', 'DarkOrange', 'DarkOrchid',
'DarkRed', 'DarkSalmon', 'DarkSeaGreen', 'DarkSlateBlue', 'DarkSlateGray',
);
$graphWidth = 1100;
$graphHeight = 400;
$data = array();
$data[] = array('', $id, array('role' => 'style')); // header
$colors = $barColors;
foreach ($results as $fw => $result) {
$data[] = array($fw, $result[$id], array_shift($colors));
}
//var_dump($data); exit;
$options = array(
'title' => $title,
'titleTextStyle' => array('fontSize' => 16),
'hAxis' => array('title' => $hAxis_title,
'titleTextStyle' => array('bold' => true)),
'vAxis' => array('minValue' => 0, 'maxValue' => 0.01),
'width' => $graphWidth,
'height' => $graphHeight,
'bar' => array('groupWidth' => '90%'),
'legend' => array('position' => 'none')
);
$type = 'ColumnChart';
return makeChartParts($data, $options, $type);
}