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