This repository has been archived by the owner on Nov 10, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
SVGGraphMultiRadarGraph.php
115 lines (104 loc) · 3.67 KB
/
SVGGraphMultiRadarGraph.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
/**
* Copyright (C) 2011-2015 Graham Breach
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* For more information, please contact <[email protected]>
*/
require_once 'SVGGraphRadarGraph.php';
require_once 'SVGGraphMultiGraph.php';
/**
* MultiRadarGraph - multiple radar graphs on one plot
*/
class MultiRadarGraph extends RadarGraph {
protected function Draw()
{
$body = $this->Grid();
$plots = '';
$y_axis = $this->y_axes[$this->main_y_axis];
$chunk_count = count($this->multi_graph);
$this->ColourSetup($this->multi_graph->ItemsCount(-1), $chunk_count);
for($i = 0; $i < $chunk_count; ++$i) {
$bnum = 0;
$cmd = 'M';
$path = '';
$attr = array('fill' => 'none');
$fill = $this->ArrayOption($this->fill_under, $i);
$dash = $this->ArrayOption($this->line_dash, $i);
$stroke_width = $this->ArrayOption($this->line_stroke_width, $i);
$fill_style = null;
if($fill) {
$attr['fill'] = $this->GetColour(null, 0, $i);
$fill_style = array('fill' => $attr['fill']);
$opacity = $this->ArrayOption($this->fill_opacity, $i);
if($opacity < 1.0) {
$attr['fill-opacity'] = $opacity;
$fill_style['fill-opacity'] = $opacity;
}
}
if(!is_null($dash))
$attr['stroke-dasharray'] = $dash;
$attr['stroke-width'] = $stroke_width <= 0 ? 1 : $stroke_width;
foreach($this->multi_graph[$i] as $item) {
$point_pos = $this->GridPosition($item->key, $bnum);
if(!is_null($item->value) && !is_null($point_pos)) {
$val = $y_axis->Position($item->value);
if(!is_null($val)) {
$angle = $this->arad + $point_pos / $this->g_height;
$x = $this->xc + ($val * sin($angle));
$y = $this->yc + ($val * cos($angle));
$path .= "$cmd$x $y ";
// no need to repeat same L command
$cmd = $cmd == 'M' ? 'L' : '';
$marker_id = $this->MarkerLabel($i, $bnum, $item, $x, $y);
$extra = empty($marker_id) ? NULL : array('id' => $marker_id);
$this->AddMarker($x, $y, $item, $extra, $i);
}
}
++$bnum;
}
if($path != '') {
$attr['stroke'] = $this->GetColour(null, 0, $i, true);
$this->line_styles[] = $attr;
$this->fill_styles[] = $fill_style;
$path .= "z";
$attr['d'] = $path;
if($this->semantic_classes)
$attr['class'] = "series{$i}";
$plots .= $this->Element('path', $attr);
}
}
$group = array();
$this->ClipGrid($group);
if($this->semantic_classes)
$group['class'] = "series";
$body .= $this->Element('g', $group, NULL, $plots);
$body .= $this->Axes();
$body .= $this->CrossHairs();
$body .= $this->DrawMarkers();
return $body;
}
/**
* construct multigraph
*/
public function Values($values)
{
parent::Values($values);
if(!$this->values->error)
$this->multi_graph = new MultiGraph($this->values, $this->force_assoc,
$this->require_integer_keys);
}
}