11 function makeSVG($tag, $type, $value, $max, $min, $optimum, $low, $high)
14 if ($tag == 'meter') {
17 /////////////////////////////////////////////////////////////////////////////////////
18 ///////// CUSTOM <meter type="2">
19 /////////////////////////////////////////////////////////////////////////////////////
22 $border_radius = 0.143; // Factor of Height
24 $svg = '<?xml version="1.0" encoding="UTF-8"?>
25 <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
26 <svg width="' . $w . 'px" height="' . $h . 'px" viewBox="0 0 ' . $w . ' ' . $h . '" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" ><g>
30 <linearGradient id="GrGRAY" x1="0" y1="0" x2="0" y2="1" gradientUnits="boundingBox">
31 <stop offset="0%" stop-color="rgb(222, 222, 222)" />
32 <stop offset="20%" stop-color="rgb(232, 232, 232)" />
33 <stop offset="25%" stop-color="rgb(232, 232, 232)" />
34 <stop offset="100%" stop-color="rgb(182, 182, 182)" />
39 $svg .= '<rect x="0" y="0" width="' . $w . '" height="' . $h . '" fill="#f4f4f4" stroke="none" />';
42 //if ($low && $high && ($low != $min || $high != $max)) {
44 $barx = (($low - $min) / ($max - $min) ) * $w;
45 $barw = (($high - $low) / ($max - $min) ) * $w;
46 $svg .= '<rect x="' . $barx . '" y="0" width="' . $barw . '" height="' . $h . '" fill="url(#GrGRAY)" stroke="#888888" stroke-width="0.5px" />';
49 // OPTIMUM Marker (? AVERAGE)
51 $barx = (($optimum - $min) / ($max - $min) ) * $w;
54 $svg .= '<rect x="' . $barx . '" y="0" rx="' . ($h * $border_radius) . 'px" ry="' . ($h * $border_radius) . 'px" width="' . $barw . '" height="' . $h . '" fill="' . $barcol . '" stroke="none" />';
59 if ($min != $low && $value < $low) {
61 } else if ($max != $high && $value > $high) {
66 $cx = (($value - $min) / ($max - $min) ) * $w;
70 $svg .= '<ellipse fill="' . $col . '" stroke="#000000" stroke-width="0.5px" cx="' . $cx . '" cy="' . $cy . '" rx="' . $rx . '" ry="' . $ry . '"/>';
74 $svg .= '<rect x="0" y="0" width="' . $w . '" height="' . $h . '" fill="none" stroke="#888888" stroke-width="0.5px" />';
77 } else if ($type == '3') {
78 /////////////////////////////////////////////////////////////////////////////////////
79 ///////// CUSTOM <meter type="2">
80 /////////////////////////////////////////////////////////////////////////////////////
83 $border_radius = 0.143; // Factor of Height
85 $svg = '<?xml version="1.0" encoding="UTF-8"?>
86 <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
87 <svg width="' . $w . 'px" height="' . $h . 'px" viewBox="0 0 ' . $w . ' ' . $h . '" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" ><g>
91 <linearGradient id="GrGRAY" x1="0" y1="0" x2="0" y2="1" gradientUnits="boundingBox">
92 <stop offset="0%" stop-color="rgb(222, 222, 222)" />
93 <stop offset="20%" stop-color="rgb(232, 232, 232)" />
94 <stop offset="25%" stop-color="rgb(232, 232, 232)" />
95 <stop offset="100%" stop-color="rgb(182, 182, 182)" />
100 $svg .= '<rect x="0" y="0" width="' . $w . '" height="' . $h . '" fill="#f4f4f4" stroke="none" />';
102 // LOW to HIGH region
103 if ($low && $high && ($low != $min ||
$high != $max)) {
104 //if ($low && $high) {
105 $barx = (($low - $min) / ($max - $min) ) * $w;
106 $barw = (($high - $low) / ($max - $min) ) * $w;
107 $svg .= '<rect x="' . $barx . '" y="0" width="' . $barw . '" height="' . $h . '" fill="url(#GrGRAY)" stroke="#888888" stroke-width="0.5px" />';
110 // OPTIMUM Marker (? AVERAGE)
112 $barx = (($optimum - $min) / ($max - $min) ) * $w;
115 $svg .= '<rect x="' . $barx . '" y="0" rx="' . ($h * $border_radius) . 'px" ry="' . ($h * $border_radius) . 'px" width="' . $barw . '" height="' . $h . '" fill="' . $barcol . '" stroke="none" />';
120 if ($min != $low && $value < $low) {
122 } else if ($max != $high && $value > $high) {
127 $cx = (($value - $min) / ($max - $min) ) * $w;
131 $svg .= '<ellipse fill="' . $col . '" stroke="#000000" stroke-width="0.5px" cx="' . $cx . '" cy="' . $cy . '" rx="' . $rx . '" ry="' . $ry . '"/>';
135 $svg .= '<rect x="0" y="0" width="' . $w . '" height="' . $h . '" fill="none" stroke="#888888" stroke-width="0.5px" />';
137 $svg .= '</g></svg>';
139 /////////////////////////////////////////////////////////////////////////////////////
140 ///////// DEFAULT <meter>
141 /////////////////////////////////////////////////////////////////////////////////////
144 $border_radius = 0.143; // Factor of Height
146 $svg = '<?xml version="1.0" encoding="UTF-8"?>
147 <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
148 <svg width="' . $w . 'px" height="' . $h . 'px" viewBox="0 0 ' . $w . ' ' . $h . '" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" ><g>
151 <linearGradient id="GrGRAY" x1="0" y1="0" x2="0" y2="1" gradientUnits="boundingBox">
152 <stop offset="0%" stop-color="rgb(222, 222, 222)" />
153 <stop offset="20%" stop-color="rgb(232, 232, 232)" />
154 <stop offset="25%" stop-color="rgb(232, 232, 232)" />
155 <stop offset="100%" stop-color="rgb(182, 182, 182)" />
158 <linearGradient id="GrRED" x1="0" y1="0" x2="0" y2="1" gradientUnits="boundingBox">
159 <stop offset="0%" stop-color="rgb(255, 162, 162)" />
160 <stop offset="20%" stop-color="rgb(255, 218, 218)" />
161 <stop offset="25%" stop-color="rgb(255, 218, 218)" />
162 <stop offset="100%" stop-color="rgb(255, 0, 0)" />
165 <linearGradient id="GrGREEN" x1="0" y1="0" x2="0" y2="1" gradientUnits="boundingBox">
166 <stop offset="0%" stop-color="rgb(102, 230, 102)" />
167 <stop offset="20%" stop-color="rgb(218, 255, 218)" />
168 <stop offset="25%" stop-color="rgb(218, 255, 218)" />
169 <stop offset="100%" stop-color="rgb(0, 148, 0)" />
172 <linearGradient id="GrBLUE" x1="0" y1="0" x2="0" y2="1" gradientUnits="boundingBox">
173 <stop offset="0%" stop-color="rgb(102, 102, 230)" />
174 <stop offset="20%" stop-color="rgb(238, 238, 238)" />
175 <stop offset="25%" stop-color="rgb(238, 238, 238)" />
176 <stop offset="100%" stop-color="rgb(0, 0, 128)" />
179 <linearGradient id="GrORANGE" x1="0" y1="0" x2="0" y2="1" gradientUnits="boundingBox">
180 <stop offset="0%" stop-color="rgb(255, 186, 0)" />
181 <stop offset="20%" stop-color="rgb(255, 238, 168)" />
182 <stop offset="25%" stop-color="rgb(255, 238, 168)" />
183 <stop offset="100%" stop-color="rgb(255, 155, 0)" />
187 <rect x="0" y="0" rx="' . ($h * $border_radius) . 'px" ry="' . ($h * $border_radius) . 'px" width="' . $w . '" height="' . $h . '" fill="url(#GrGRAY)" stroke="none" />
191 $barw = (($value - $min) / ($max - $min) ) * $w;
192 if ($optimum < $low) {
194 $barcol = 'url(#GrGREEN)';
195 } else if ($value > $high) {
196 $barcol = 'url(#GrRED)';
198 $barcol = 'url(#GrORANGE)';
200 } else if ($optimum > $high) {
202 $barcol = 'url(#GrRED)';
203 } else if ($value > $high) {
204 $barcol = 'url(#GrGREEN)';
206 $barcol = 'url(#GrORANGE)';
210 $barcol = 'url(#GrORANGE)';
211 } else if ($value > $high) {
212 $barcol = 'url(#GrORANGE)';
214 $barcol = 'url(#GrGREEN)';
217 $svg .= '<rect x="0" y="0" rx="' . ($h * $border_radius) . 'px" ry="' . ($h * $border_radius) . 'px" width="' . $barw . '" height="' . $h . '" fill="' . $barcol . '" stroke="none" />';
222 //$svg .= '<rect x="0" y="0" rx="'.($h*$border_radius).'px" ry="'.($h*$border_radius).'px" width="'.$w.'" height="'.$h.'" fill="none" stroke="#888888" stroke-width="0.5px" />';
224 // $svg .= '<rect x="0" y="0" rx="'.($h*$border_radius).'px" ry="'.($h*$border_radius).'px" width="'.$barw.'" height="'.$h.'" fill="none" stroke="#888888" stroke-width="0.5px" />';
228 $svg .= '</g></svg>';
230 } else { // $tag == 'progress'
232 /////////////////////////////////////////////////////////////////////////////////////
233 ///////// CUSTOM <progress type="2">
234 /////////////////////////////////////////////////////////////////////////////////////
236 /////////////////////////////////////////////////////////////////////////////////////
237 ///////// DEFAULT <progress>
238 /////////////////////////////////////////////////////////////////////////////////////
241 $border_radius = 0.143; // Factor of Height
243 if ($value or $value === '0') {
244 $fill = 'url(#GrGRAY)';
249 $svg = '<svg width="' . $w . 'px" height="' . $h . 'px" viewBox="0 0 ' . $w . ' ' . $h . '"><g>
252 <linearGradient id="GrGRAY" x1="0" y1="0" x2="0" y2="1" gradientUnits="boundingBox">
253 <stop offset="0%" stop-color="rgb(222, 222, 222)" />
254 <stop offset="20%" stop-color="rgb(232, 232, 232)" />
255 <stop offset="25%" stop-color="rgb(232, 232, 232)" />
256 <stop offset="100%" stop-color="rgb(182, 182, 182)" />
259 <linearGradient id="GrGREEN" x1="0" y1="0" x2="0" y2="1" gradientUnits="boundingBox">
260 <stop offset="0%" stop-color="rgb(102, 230, 102)" />
261 <stop offset="20%" stop-color="rgb(218, 255, 218)" />
262 <stop offset="25%" stop-color="rgb(218, 255, 218)" />
263 <stop offset="100%" stop-color="rgb(0, 148, 0)" />
268 <rect x="0" y="0" rx="' . ($h * $border_radius) . 'px" ry="' . ($h * $border_radius) . 'px" width="' . $w . '" height="' . $h . '" fill="' . $fill . '" stroke="none" />
272 $barw = (($value - $min) / ($max - $min) ) * $w;
273 $barcol = 'url(#GrGREEN)';
274 $svg .= '<rect x="0" y="0" rx="' . ($h * $border_radius) . 'px" ry="' . ($h * $border_radius) . 'px" width="' . $barw . '" height="' . $h . '" fill="' . $barcol . '" stroke="none" />';
279 $svg .= '<rect x="0" y="0" rx="' . ($h * $border_radius) . 'px" ry="' . ($h * $border_radius) . 'px" width="' . $w . '" height="' . $h . '" fill="none" stroke="#888888" stroke-width="0.5px" />';
281 // $svg .= '<rect x="0" y="0" rx="'.($h*$border_radius).'px" ry="'.($h*$border_radius).'px" width="'.$barw.'" height="'.$h.'" fill="none" stroke="#888888" stroke-width="0.5px" />';
285 $svg .= '</g></svg>';