| @@ -1,292 +1,282 @@ | ||
| 1 | -<?php | |
| 2 | - | |
| 3 | -class meter | |
| 4 | -{ | |
| 5 | - | |
| 6 | - function __construct() | |
| 7 | - { | |
| 8 | - | |
| 9 | - } | |
| 10 | - | |
| 11 | - function makeSVG($tag, $type, $value, $max, $min, $optimum, $low, $high) | |
| 12 | - { | |
| 13 | - $svg = ''; | |
| 14 | - if ($tag == 'meter') { | |
| 15 | - | |
| 16 | - if ($type == '2') { | |
| 17 | - ///////////////////////////////////////////////////////////////////////////////////// | |
| 18 | - ///////// CUSTOM <meter type="2"> | |
| 19 | - ///////////////////////////////////////////////////////////////////////////////////// | |
| 20 | - $h = 10; | |
| 21 | - $w = 160; | |
| 22 | - $border_radius = 0.143; // Factor of Height | |
| 23 | - | |
| 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> | |
| 27 | - | |
| 28 | - | |
| 29 | - <defs> | |
| 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)" /> | |
| 35 | - </linearGradient> | |
| 36 | - | |
| 37 | - </defs> | |
| 38 | -'; | |
| 39 | - $svg .= '<rect x="0" y="0" width="' . $w . '" height="' . $h . '" fill="#f4f4f4" stroke="none" />'; | |
| 40 | - | |
| 41 | - // LOW to HIGH region | |
| 42 | - //if ($low && $high && ($low != $min || $high != $max)) { | |
| 43 | - if ($low && $high) { | |
| 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" />'; | |
| 47 | - } | |
| 48 | - | |
| 49 | - // OPTIMUM Marker (? AVERAGE) | |
| 50 | - if ($optimum) { | |
| 51 | - $barx = (($optimum - $min) / ($max - $min) ) * $w; | |
| 52 | - $barw = $h / 2; | |
| 53 | - $barcol = '#888888'; | |
| 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" />'; | |
| 55 | - } | |
| 56 | - | |
| 57 | - // VALUE Marker | |
| 58 | - if ($value) { | |
| 59 | - if ($min != $low && $value < $low) { | |
| 60 | - $col = 'orange'; | |
| 61 | - } else if ($max != $high && $value > $high) { | |
| 62 | - $col = 'orange'; | |
| 63 | - } else { | |
| 64 | - $col = '#008800'; | |
| 65 | - } | |
| 66 | - $cx = (($value - $min) / ($max - $min) ) * $w; | |
| 67 | - $cy = $h / 2; | |
| 68 | - $rx = $h / 3.5; | |
| 69 | - $ry = $h / 2.2; | |
| 70 | - $svg .= '<ellipse fill="' . $col . '" stroke="#000000" stroke-width="0.5px" cx="' . $cx . '" cy="' . $cy . '" rx="' . $rx . '" ry="' . $ry . '"/>'; | |
| 71 | - } | |
| 72 | - | |
| 73 | - // BoRDER | |
| 74 | - $svg .= '<rect x="0" y="0" width="' . $w . '" height="' . $h . '" fill="none" stroke="#888888" stroke-width="0.5px" />'; | |
| 75 | - | |
| 76 | - $svg .= '</g></svg>'; | |
| 77 | - } else if ($type == '3') { | |
| 78 | - ///////////////////////////////////////////////////////////////////////////////////// | |
| 79 | - ///////// CUSTOM <meter type="2"> | |
| 80 | - ///////////////////////////////////////////////////////////////////////////////////// | |
| 81 | - $h = 10; | |
| 82 | - $w = 100; | |
| 83 | - $border_radius = 0.143; // Factor of Height | |
| 84 | - | |
| 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> | |
| 88 | - | |
| 89 | - | |
| 90 | - <defs> | |
| 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)" /> | |
| 96 | - </linearGradient> | |
| 97 | - | |
| 98 | - </defs> | |
| 99 | -'; | |
| 100 | - $svg .= '<rect x="0" y="0" width="' . $w . '" height="' . $h . '" fill="#f4f4f4" stroke="none" />'; | |
| 101 | - | |
| 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" />'; | |
| 108 | - } | |
| 109 | - | |
| 110 | - // OPTIMUM Marker (? AVERAGE) | |
| 111 | - if ($optimum) { | |
| 112 | - $barx = (($optimum - $min) / ($max - $min) ) * $w; | |
| 113 | - $barw = $h / 2; | |
| 114 | - $barcol = '#888888'; | |
| 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" />'; | |
| 116 | - } | |
| 117 | - | |
| 118 | - // VALUE Marker | |
| 119 | - if ($value) { | |
| 120 | - if ($min != $low && $value < $low) { | |
| 121 | - $col = 'orange'; | |
| 122 | - } else if ($max != $high && $value > $high) { | |
| 123 | - $col = 'orange'; | |
| 124 | - } else { | |
| 125 | - $col = 'orange'; | |
| 126 | - } | |
| 127 | - $cx = (($value - $min) / ($max - $min) ) * $w; | |
| 128 | - $cy = $h / 2; | |
| 129 | - $rx = $h / 2.2; | |
| 130 | - $ry = $h / 2.2; | |
| 131 | - $svg .= '<ellipse fill="' . $col . '" stroke="#000000" stroke-width="0.5px" cx="' . $cx . '" cy="' . $cy . '" rx="' . $rx . '" ry="' . $ry . '"/>'; | |
| 132 | - } | |
| 133 | - | |
| 134 | - // BoRDER | |
| 135 | - $svg .= '<rect x="0" y="0" width="' . $w . '" height="' . $h . '" fill="none" stroke="#888888" stroke-width="0.5px" />'; | |
| 136 | - | |
| 137 | - $svg .= '</g></svg>'; | |
| 138 | - } else { | |
| 139 | - ///////////////////////////////////////////////////////////////////////////////////// | |
| 140 | - ///////// DEFAULT <meter> | |
| 141 | - ///////////////////////////////////////////////////////////////////////////////////// | |
| 142 | - $h = 10; | |
| 143 | - $w = 50; | |
| 144 | - $border_radius = 0.143; // Factor of Height | |
| 145 | - | |
| 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> | |
| 149 | - | |
| 150 | - <defs> | |
| 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)" /> | |
| 156 | - </linearGradient> | |
| 157 | - | |
| 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)" /> | |
| 163 | - </linearGradient> | |
| 164 | - | |
| 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)" /> | |
| 170 | - </linearGradient> | |
| 171 | - | |
| 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)" /> | |
| 177 | - </linearGradient> | |
| 178 | - | |
| 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)" /> | |
| 184 | - </linearGradient> | |
| 185 | - </defs> | |
| 186 | - | |
| 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" /> | |
| 188 | -'; | |
| 189 | - | |
| 190 | - if ($value) { | |
| 191 | - $barw = (($value - $min) / ($max - $min) ) * $w; | |
| 192 | - if ($optimum < $low) { | |
| 193 | - if ($value < $low) { | |
| 194 | - $barcol = 'url(#GrGREEN)'; | |
| 195 | - } else if ($value > $high) { | |
| 196 | - $barcol = 'url(#GrRED)'; | |
| 197 | - } else { | |
| 198 | - $barcol = 'url(#GrORANGE)'; | |
| 199 | - } | |
| 200 | - } else if ($optimum > $high) { | |
| 201 | - if ($value < $low) { | |
| 202 | - $barcol = 'url(#GrRED)'; | |
| 203 | - } else if ($value > $high) { | |
| 204 | - $barcol = 'url(#GrGREEN)'; | |
| 205 | - } else { | |
| 206 | - $barcol = 'url(#GrORANGE)'; | |
| 207 | - } | |
| 208 | - } else { | |
| 209 | - if ($value < $low) { | |
| 210 | - $barcol = 'url(#GrORANGE)'; | |
| 211 | - } else if ($value > $high) { | |
| 212 | - $barcol = 'url(#GrORANGE)'; | |
| 213 | - } else { | |
| 214 | - $barcol = 'url(#GrGREEN)'; | |
| 215 | - } | |
| 216 | - } | |
| 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" />'; | |
| 218 | - } | |
| 219 | - | |
| 220 | - | |
| 221 | - // Borders | |
| 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" />'; | |
| 223 | - if ($value) { | |
| 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" />'; | |
| 225 | - } | |
| 226 | - | |
| 227 | - | |
| 228 | - $svg .= '</g></svg>'; | |
| 229 | - } | |
| 230 | - } else { // $tag == 'progress' | |
| 231 | - if ($type == '2') { | |
| 232 | - ///////////////////////////////////////////////////////////////////////////////////// | |
| 233 | - ///////// CUSTOM <progress type="2"> | |
| 234 | - ///////////////////////////////////////////////////////////////////////////////////// | |
| 235 | - } else { | |
| 236 | - ///////////////////////////////////////////////////////////////////////////////////// | |
| 237 | - ///////// DEFAULT <progress> | |
| 238 | - ///////////////////////////////////////////////////////////////////////////////////// | |
| 239 | - $h = 10; | |
| 240 | - $w = 100; | |
| 241 | - $border_radius = 0.143; // Factor of Height | |
| 242 | - | |
| 243 | - if ($value or $value === '0') { | |
| 244 | - $fill = 'url(#GrGRAY)'; | |
| 245 | - } else { | |
| 246 | - $fill = '#f8f8f8'; | |
| 247 | - } | |
| 248 | - | |
| 249 | - $svg = '<svg width="' . $w . 'px" height="' . $h . 'px" viewBox="0 0 ' . $w . ' ' . $h . '"><g> | |
| 250 | - | |
| 251 | - <defs> | |
| 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)" /> | |
| 257 | - </linearGradient> | |
| 258 | - | |
| 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)" /> | |
| 264 | - </linearGradient> | |
| 265 | - | |
| 266 | - </defs> | |
| 267 | - | |
| 268 | - <rect x="0" y="0" rx="' . ($h * $border_radius) . 'px" ry="' . ($h * $border_radius) . 'px" width="' . $w . '" height="' . $h . '" fill="' . $fill . '" stroke="none" /> | |
| 269 | -'; | |
| 270 | - | |
| 271 | - if ($value) { | |
| 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" />'; | |
| 275 | - } | |
| 276 | - | |
| 277 | - | |
| 278 | - // Borders | |
| 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" />'; | |
| 280 | - if ($value) { | |
| 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" />'; | |
| 282 | - } | |
| 283 | - | |
| 284 | - | |
| 285 | - $svg .= '</g></svg>'; | |
| 286 | - } | |
| 287 | - } | |
| 288 | - | |
| 289 | - return $svg; | |
| 290 | - } | |
| 291 | - | |
| 292 | -} | |
| 1 | +<?php | |
| 2 | + | |
| 3 | +class meter { | |
| 4 | + | |
| 5 | + | |
| 6 | +function __construct() { | |
| 7 | + | |
| 8 | +} | |
| 9 | + | |
| 10 | +function makeSVG($tag, $type, $value, $max, $min, $optimum, $low, $high) { | |
| 11 | + $svg = ''; | |
| 12 | + if ($tag == 'meter') { | |
| 13 | + | |
| 14 | + if ($type=='2') { | |
| 15 | + ///////////////////////////////////////////////////////////////////////////////////// | |
| 16 | + ///////// CUSTOM <meter type="2"> | |
| 17 | + ///////////////////////////////////////////////////////////////////////////////////// | |
| 18 | + $h = 10; | |
| 19 | + $w = 160; | |
| 20 | + $border_radius = 0.143; // Factor of Height | |
| 21 | + | |
| 22 | + $svg = '<?xml version="1.0" encoding="UTF-8"?> | |
| 23 | + <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> | |
| 24 | + <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> | |
| 25 | + | |
| 26 | + | |
| 27 | + <defs> | |
| 28 | + <linearGradient id="GrGRAY" x1="0" y1="0" x2="0" y2="1" gradientUnits="boundingBox"> | |
| 29 | + <stop offset="0%" stop-color="rgb(222, 222, 222)" /> | |
| 30 | + <stop offset="20%" stop-color="rgb(232, 232, 232)" /> | |
| 31 | + <stop offset="25%" stop-color="rgb(232, 232, 232)" /> | |
| 32 | + <stop offset="100%" stop-color="rgb(182, 182, 182)" /> | |
| 33 | + </linearGradient> | |
| 34 | + | |
| 35 | + </defs> | |
| 36 | +'; | |
| 37 | + $svg .= '<rect x="0" y="0" width="'.$w.'" height="'.$h.'" fill="#f4f4f4" stroke="none" />'; | |
| 38 | + | |
| 39 | + // LOW to HIGH region | |
| 40 | + //if ($low && $high && ($low != $min || $high != $max)) { | |
| 41 | + if ($low && $high) { | |
| 42 | + $barx = (($low-$min) / ($max-$min) ) * $w; | |
| 43 | + $barw = (($high-$low) / ($max-$min) ) * $w; | |
| 44 | + $svg .= '<rect x="'.$barx.'" y="0" width="'.$barw.'" height="'.$h.'" fill="url(#GrGRAY)" stroke="#888888" stroke-width="0.5px" />'; | |
| 45 | + } | |
| 46 | + | |
| 47 | + // OPTIMUM Marker (? AVERAGE) | |
| 48 | + if ($optimum) { | |
| 49 | + $barx = (($optimum-$min) / ($max-$min) ) * $w; | |
| 50 | + $barw = $h/2; | |
| 51 | + $barcol = '#888888'; | |
| 52 | + $svg .= '<rect x="'.$barx.'" y="0" rx="'.($h*$border_radius).'px" ry="'.($h*$border_radius).'px" width="'.$barw.'" height="'.$h.'" fill="'.$barcol.'" stroke="none" />'; | |
| 53 | + } | |
| 54 | + | |
| 55 | + // VALUE Marker | |
| 56 | + if ($value) { | |
| 57 | + if ($min != $low && $value < $low) { $col = 'orange'; } | |
| 58 | + else if ($max != $high && $value > $high) { $col = 'orange'; } | |
| 59 | + else { $col = '#008800'; } | |
| 60 | + $cx = (($value-$min) / ($max-$min) ) * $w; | |
| 61 | + $cy = $h/2; | |
| 62 | + $rx = $h/3.5; | |
| 63 | + $ry = $h/2.2; | |
| 64 | + $svg .= '<ellipse fill="'.$col.'" stroke="#000000" stroke-width="0.5px" cx="'.$cx.'" cy="'.$cy.'" rx="'.$rx.'" ry="'.$ry.'"/>'; | |
| 65 | + } | |
| 66 | + | |
| 67 | + // BoRDER | |
| 68 | + $svg .= '<rect x="0" y="0" width="'.$w.'" height="'.$h.'" fill="none" stroke="#888888" stroke-width="0.5px" />'; | |
| 69 | + | |
| 70 | + $svg .= '</g></svg>'; | |
| 71 | + } | |
| 72 | + else if ($type=='3') { | |
| 73 | + ///////////////////////////////////////////////////////////////////////////////////// | |
| 74 | + ///////// CUSTOM <meter type="2"> | |
| 75 | + ///////////////////////////////////////////////////////////////////////////////////// | |
| 76 | + $h = 10; | |
| 77 | + $w = 100; | |
| 78 | + $border_radius = 0.143; // Factor of Height | |
| 79 | + | |
| 80 | + $svg = '<?xml version="1.0" encoding="UTF-8"?> | |
| 81 | + <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> | |
| 82 | + <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> | |
| 83 | + | |
| 84 | + | |
| 85 | + <defs> | |
| 86 | + <linearGradient id="GrGRAY" x1="0" y1="0" x2="0" y2="1" gradientUnits="boundingBox"> | |
| 87 | + <stop offset="0%" stop-color="rgb(222, 222, 222)" /> | |
| 88 | + <stop offset="20%" stop-color="rgb(232, 232, 232)" /> | |
| 89 | + <stop offset="25%" stop-color="rgb(232, 232, 232)" /> | |
| 90 | + <stop offset="100%" stop-color="rgb(182, 182, 182)" /> | |
| 91 | + </linearGradient> | |
| 92 | + | |
| 93 | + </defs> | |
| 94 | +'; | |
| 95 | + $svg .= '<rect x="0" y="0" width="'.$w.'" height="'.$h.'" fill="#f4f4f4" stroke="none" />'; | |
| 96 | + | |
| 97 | + // LOW to HIGH region | |
| 98 | + if ($low && $high && ($low != $min || $high != $max)) { | |
| 99 | + //if ($low && $high) { | |
| 100 | + $barx = (($low-$min) / ($max-$min) ) * $w; | |
| 101 | + $barw = (($high-$low) / ($max-$min) ) * $w; | |
| 102 | + $svg .= '<rect x="'.$barx.'" y="0" width="'.$barw.'" height="'.$h.'" fill="url(#GrGRAY)" stroke="#888888" stroke-width="0.5px" />'; | |
| 103 | + } | |
| 104 | + | |
| 105 | + // OPTIMUM Marker (? AVERAGE) | |
| 106 | + if ($optimum) { | |
| 107 | + $barx = (($optimum-$min) / ($max-$min) ) * $w; | |
| 108 | + $barw = $h/2; | |
| 109 | + $barcol = '#888888'; | |
| 110 | + $svg .= '<rect x="'.$barx.'" y="0" rx="'.($h*$border_radius).'px" ry="'.($h*$border_radius).'px" width="'.$barw.'" height="'.$h.'" fill="'.$barcol.'" stroke="none" />'; | |
| 111 | + } | |
| 112 | + | |
| 113 | + // VALUE Marker | |
| 114 | + if ($value) { | |
| 115 | + if ($min != $low && $value < $low) { $col = 'orange'; } | |
| 116 | + else if ($max != $high && $value > $high) { $col = 'orange'; } | |
| 117 | + else { $col = 'orange'; } | |
| 118 | + $cx = (($value-$min) / ($max-$min) ) * $w; | |
| 119 | + $cy = $h/2; | |
| 120 | + $rx = $h/2.2; | |
| 121 | + $ry = $h/2.2; | |
| 122 | + $svg .= '<ellipse fill="'.$col.'" stroke="#000000" stroke-width="0.5px" cx="'.$cx.'" cy="'.$cy.'" rx="'.$rx.'" ry="'.$ry.'"/>'; | |
| 123 | + } | |
| 124 | + | |
| 125 | + // BoRDER | |
| 126 | + $svg .= '<rect x="0" y="0" width="'.$w.'" height="'.$h.'" fill="none" stroke="#888888" stroke-width="0.5px" />'; | |
| 127 | + | |
| 128 | + $svg .= '</g></svg>'; | |
| 129 | + } | |
| 130 | + else { | |
| 131 | + ///////////////////////////////////////////////////////////////////////////////////// | |
| 132 | + ///////// DEFAULT <meter> | |
| 133 | + ///////////////////////////////////////////////////////////////////////////////////// | |
| 134 | + $h = 10; | |
| 135 | + $w = 50; | |
| 136 | + $border_radius = 0.143; // Factor of Height | |
| 137 | + | |
| 138 | + $svg = '<?xml version="1.0" encoding="UTF-8"?> | |
| 139 | + <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> | |
| 140 | + <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> | |
| 141 | + | |
| 142 | + <defs> | |
| 143 | + <linearGradient id="GrGRAY" x1="0" y1="0" x2="0" y2="1" gradientUnits="boundingBox"> | |
| 144 | + <stop offset="0%" stop-color="rgb(222, 222, 222)" /> | |
| 145 | + <stop offset="20%" stop-color="rgb(232, 232, 232)" /> | |
| 146 | + <stop offset="25%" stop-color="rgb(232, 232, 232)" /> | |
| 147 | + <stop offset="100%" stop-color="rgb(182, 182, 182)" /> | |
| 148 | + </linearGradient> | |
| 149 | + | |
| 150 | + <linearGradient id="GrRED" x1="0" y1="0" x2="0" y2="1" gradientUnits="boundingBox"> | |
| 151 | + <stop offset="0%" stop-color="rgb(255, 162, 162)" /> | |
| 152 | + <stop offset="20%" stop-color="rgb(255, 218, 218)" /> | |
| 153 | + <stop offset="25%" stop-color="rgb(255, 218, 218)" /> | |
| 154 | + <stop offset="100%" stop-color="rgb(255, 0, 0)" /> | |
| 155 | + </linearGradient> | |
| 156 | + | |
| 157 | + <linearGradient id="GrGREEN" x1="0" y1="0" x2="0" y2="1" gradientUnits="boundingBox"> | |
| 158 | + <stop offset="0%" stop-color="rgb(102, 230, 102)" /> | |
| 159 | + <stop offset="20%" stop-color="rgb(218, 255, 218)" /> | |
| 160 | + <stop offset="25%" stop-color="rgb(218, 255, 218)" /> | |
| 161 | + <stop offset="100%" stop-color="rgb(0, 148, 0)" /> | |
| 162 | + </linearGradient> | |
| 163 | + | |
| 164 | + <linearGradient id="GrBLUE" x1="0" y1="0" x2="0" y2="1" gradientUnits="boundingBox"> | |
| 165 | + <stop offset="0%" stop-color="rgb(102, 102, 230)" /> | |
| 166 | + <stop offset="20%" stop-color="rgb(238, 238, 238)" /> | |
| 167 | + <stop offset="25%" stop-color="rgb(238, 238, 238)" /> | |
| 168 | + <stop offset="100%" stop-color="rgb(0, 0, 128)" /> | |
| 169 | + </linearGradient> | |
| 170 | + | |
| 171 | + <linearGradient id="GrORANGE" x1="0" y1="0" x2="0" y2="1" gradientUnits="boundingBox"> | |
| 172 | + <stop offset="0%" stop-color="rgb(255, 186, 0)" /> | |
| 173 | + <stop offset="20%" stop-color="rgb(255, 238, 168)" /> | |
| 174 | + <stop offset="25%" stop-color="rgb(255, 238, 168)" /> | |
| 175 | + <stop offset="100%" stop-color="rgb(255, 155, 0)" /> | |
| 176 | + </linearGradient> | |
| 177 | + </defs> | |
| 178 | + | |
| 179 | + <rect x="0" y="0" rx="'.($h*$border_radius).'px" ry="'.($h*$border_radius).'px" width="'.$w.'" height="'.$h.'" fill="url(#GrGRAY)" stroke="none" /> | |
| 180 | +'; | |
| 181 | + | |
| 182 | + if ($value) { | |
| 183 | + $barw = (($value-$min) / ($max-$min) ) * $w; | |
| 184 | + if ($optimum < $low) { | |
| 185 | + if ($value < $low) { $barcol = 'url(#GrGREEN)'; } | |
| 186 | + else if ($value > $high) { $barcol = 'url(#GrRED)'; } | |
| 187 | + else { $barcol = 'url(#GrORANGE)'; } | |
| 188 | + } | |
| 189 | + else if ($optimum > $high) { | |
| 190 | + if ($value < $low) { $barcol = 'url(#GrRED)'; } | |
| 191 | + else if ($value > $high) { $barcol = 'url(#GrGREEN)'; } | |
| 192 | + else { $barcol = 'url(#GrORANGE)'; } | |
| 193 | + } | |
| 194 | + else { | |
| 195 | + if ($value < $low) { $barcol = 'url(#GrORANGE)'; } | |
| 196 | + else if ($value > $high) { $barcol = 'url(#GrORANGE)'; } | |
| 197 | + else { $barcol = 'url(#GrGREEN)'; } | |
| 198 | + } | |
| 199 | + $svg .= '<rect x="0" y="0" rx="'.($h*$border_radius).'px" ry="'.($h*$border_radius).'px" width="'.$barw.'" height="'.$h.'" fill="'.$barcol.'" stroke="none" />'; | |
| 200 | + } | |
| 201 | + | |
| 202 | + | |
| 203 | + // Borders | |
| 204 | + //$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" />'; | |
| 205 | + if ($value) { | |
| 206 | + // $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" />'; | |
| 207 | + } | |
| 208 | + | |
| 209 | + | |
| 210 | + $svg .= '</g></svg>'; | |
| 211 | + } | |
| 212 | + } | |
| 213 | + else { // $tag == 'progress' | |
| 214 | + | |
| 215 | + if ($type=='2') { | |
| 216 | + ///////////////////////////////////////////////////////////////////////////////////// | |
| 217 | + ///////// CUSTOM <progress type="2"> | |
| 218 | + ///////////////////////////////////////////////////////////////////////////////////// | |
| 219 | + } | |
| 220 | + else { | |
| 221 | + ///////////////////////////////////////////////////////////////////////////////////// | |
| 222 | + ///////// DEFAULT <progress> | |
| 223 | + ///////////////////////////////////////////////////////////////////////////////////// | |
| 224 | + $h = 10; | |
| 225 | + $w = 100; | |
| 226 | + $border_radius = 0.143; // Factor of Height | |
| 227 | + | |
| 228 | + if ($value or $value==='0') { | |
| 229 | + $fill = 'url(#GrGRAY)'; | |
| 230 | + } | |
| 231 | + else { | |
| 232 | + $fill = '#f8f8f8'; | |
| 233 | + } | |
| 234 | + | |
| 235 | + $svg = '<svg width="'.$w.'px" height="'.$h.'px" viewBox="0 0 '.$w.' '.$h.'"><g> | |
| 236 | + | |
| 237 | + <defs> | |
| 238 | + <linearGradient id="GrGRAY" x1="0" y1="0" x2="0" y2="1" gradientUnits="boundingBox"> | |
| 239 | + <stop offset="0%" stop-color="rgb(222, 222, 222)" /> | |
| 240 | + <stop offset="20%" stop-color="rgb(232, 232, 232)" /> | |
| 241 | + <stop offset="25%" stop-color="rgb(232, 232, 232)" /> | |
| 242 | + <stop offset="100%" stop-color="rgb(182, 182, 182)" /> | |
| 243 | + </linearGradient> | |
| 244 | + | |
| 245 | + <linearGradient id="GrGREEN" x1="0" y1="0" x2="0" y2="1" gradientUnits="boundingBox"> | |
| 246 | + <stop offset="0%" stop-color="rgb(102, 230, 102)" /> | |
| 247 | + <stop offset="20%" stop-color="rgb(218, 255, 218)" /> | |
| 248 | + <stop offset="25%" stop-color="rgb(218, 255, 218)" /> | |
| 249 | + <stop offset="100%" stop-color="rgb(0, 148, 0)" /> | |
| 250 | + </linearGradient> | |
| 251 | + | |
| 252 | + </defs> | |
| 253 | + | |
| 254 | + <rect x="0" y="0" rx="'.($h*$border_radius).'px" ry="'.($h*$border_radius).'px" width="'.$w.'" height="'.$h.'" fill="'.$fill.'" stroke="none" /> | |
| 255 | +'; | |
| 256 | + | |
| 257 | + if ($value) { | |
| 258 | + $barw = (($value-$min) / ($max-$min) ) * $w; | |
| 259 | + $barcol = 'url(#GrGREEN)'; | |
| 260 | + $svg .= '<rect x="0" y="0" rx="'.($h*$border_radius).'px" ry="'.($h*$border_radius).'px" width="'.$barw.'" height="'.$h.'" fill="'.$barcol.'" stroke="none" />'; | |
| 261 | + } | |
| 262 | + | |
| 263 | + | |
| 264 | + // Borders | |
| 265 | + $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" />'; | |
| 266 | + if ($value) { | |
| 267 | + // $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" />'; | |
| 268 | + } | |
| 269 | + | |
| 270 | + | |
| 271 | + $svg .= '</g></svg>'; | |
| 272 | + | |
| 273 | + } | |
| 274 | + } | |
| 275 | + | |
| 276 | + return $svg; | |
| 277 | +} | |
| 278 | + | |
| 279 | + | |
| 280 | +} // end of class | |
| 281 | + | |
| 282 | +?> | |