]>
git.immae.eu Git - github/wallabag/wallabag.git/blob - inc/3rdparty/libraries/mpdf/classes/meter.php
46fa9d5ae15b05c3ede414f610ff19118d67778f
6 function __construct() {
10 function makeSVG($tag, $type, $value, $max, $min, $optimum, $low, $high) {
12 if ($tag == 'meter') {
15 /////////////////////////////////////////////////////////////////////////////////////
16 ///////// CUSTOM <meter type="2">
17 /////////////////////////////////////////////////////////////////////////////////////
20 $border_radius = 0.143; // Factor of Height
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>
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)" />
37 $svg .= '<rect x="0" y="0" width="'.$w.'" height="'.$h.'" fill="#f4f4f4" stroke="none" />';
40 //if ($low && $high && ($low != $min || $high != $max)) {
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" />';
47 // OPTIMUM Marker (? AVERAGE)
49 $barx = (($optimum-$min) / ($max-$min) ) * $w;
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" />';
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;
64 $svg .= '<ellipse fill="'.$col.'" stroke="#000000" stroke-width="0.5px" cx="'.$cx.'" cy="'.$cy.'" rx="'.$rx.'" ry="'.$ry.'"/>';
68 $svg .= '<rect x="0" y="0" width="'.$w.'" height="'.$h.'" fill="none" stroke="#888888" stroke-width="0.5px" />';
73 /////////////////////////////////////////////////////////////////////////////////////
74 ///////// DEFAULT <meter>
75 /////////////////////////////////////////////////////////////////////////////////////
78 $border_radius = 0.143; // Factor of Height
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>
85 <linearGradient id="GrGRAY" x1="0" y1="0" x2="0" y2="1" gradientUnits="boundingBox">
86 <stop offset="0%" stop-color="rgb(222, 222, 222)" />
87 <stop offset="20%" stop-color="rgb(232, 232, 232)" />
88 <stop offset="25%" stop-color="rgb(232, 232, 232)" />
89 <stop offset="100%" stop-color="rgb(182, 182, 182)" />
92 <linearGradient id="GrRED" x1="0" y1="0" x2="0" y2="1" gradientUnits="boundingBox">
93 <stop offset="0%" stop-color="rgb(255, 162, 162)" />
94 <stop offset="20%" stop-color="rgb(255, 218, 218)" />
95 <stop offset="25%" stop-color="rgb(255, 218, 218)" />
96 <stop offset="100%" stop-color="rgb(255, 0, 0)" />
99 <linearGradient id="GrGREEN" x1="0" y1="0" x2="0" y2="1" gradientUnits="boundingBox">
100 <stop offset="0%" stop-color="rgb(102, 230, 102)" />
101 <stop offset="20%" stop-color="rgb(218, 255, 218)" />
102 <stop offset="25%" stop-color="rgb(218, 255, 218)" />
103 <stop offset="100%" stop-color="rgb(0, 148, 0)" />
106 <linearGradient id="GrBLUE" x1="0" y1="0" x2="0" y2="1" gradientUnits="boundingBox">
107 <stop offset="0%" stop-color="rgb(102, 102, 230)" />
108 <stop offset="20%" stop-color="rgb(238, 238, 238)" />
109 <stop offset="25%" stop-color="rgb(238, 238, 238)" />
110 <stop offset="100%" stop-color="rgb(0, 0, 128)" />
113 <linearGradient id="GrORANGE" x1="0" y1="0" x2="0" y2="1" gradientUnits="boundingBox">
114 <stop offset="0%" stop-color="rgb(255, 186, 0)" />
115 <stop offset="20%" stop-color="rgb(255, 238, 168)" />
116 <stop offset="25%" stop-color="rgb(255, 238, 168)" />
117 <stop offset="100%" stop-color="rgb(255, 155, 0)" />
121 <rect x="0" y="0" rx="'.($h*$border_radius).'px" ry="'.($h*$border_radius).'px" width="'.$w.'" height="'.$h.'" fill="url(#GrGRAY)" stroke="none" />
125 $barw = (($value-$min) / ($max-$min) ) * $w;
126 if ($optimum < $low) {
127 if ($value < $low) { $barcol
= 'url(#GrGREEN)'; }
128 else if ($value > $high) { $barcol
= 'url(#GrRED)'; }
129 else { $barcol
= 'url(#GrORANGE)'; }
131 else if ($optimum > $high) {
132 if ($value < $low) { $barcol
= 'url(#GrRED)'; }
133 else if ($value > $high) { $barcol
= 'url(#GrGREEN)'; }
134 else { $barcol
= 'url(#GrORANGE)'; }
137 if ($value < $low) { $barcol
= 'url(#GrORANGE)'; }
138 else if ($value > $high) { $barcol
= 'url(#GrORANGE)'; }
139 else { $barcol
= 'url(#GrGREEN)'; }
141 $svg .= '<rect x="0" y="0" rx="'.($h*$border_radius).'px" ry="'.($h*$border_radius).'px" width="'.$barw.'" height="'.$h.'" fill="'.$barcol.'" stroke="none" />';
146 //$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" />';
148 // $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" />';
152 $svg .= '</g></svg>';
155 else { // $tag == 'progress'
158 /////////////////////////////////////////////////////////////////////////////////////
159 ///////// CUSTOM <progress type="2">
160 /////////////////////////////////////////////////////////////////////////////////////
163 /////////////////////////////////////////////////////////////////////////////////////
164 ///////// DEFAULT <progress>
165 /////////////////////////////////////////////////////////////////////////////////////
168 $border_radius = 0.143; // Factor of Height
170 if ($value or $value==='0') {
171 $fill = 'url(#GrGRAY)';
177 $svg = '<svg width="'.$w.'px" height="'.$h.'px" viewBox="0 0 '.$w.' '.$h.'"><g>
180 <linearGradient id="GrGRAY" x1="0" y1="0" x2="0" y2="1" gradientUnits="boundingBox">
181 <stop offset="0%" stop-color="rgb(222, 222, 222)" />
182 <stop offset="20%" stop-color="rgb(232, 232, 232)" />
183 <stop offset="25%" stop-color="rgb(232, 232, 232)" />
184 <stop offset="100%" stop-color="rgb(182, 182, 182)" />
187 <linearGradient id="GrGREEN" x1="0" y1="0" x2="0" y2="1" gradientUnits="boundingBox">
188 <stop offset="0%" stop-color="rgb(102, 230, 102)" />
189 <stop offset="20%" stop-color="rgb(218, 255, 218)" />
190 <stop offset="25%" stop-color="rgb(218, 255, 218)" />
191 <stop offset="100%" stop-color="rgb(0, 148, 0)" />
196 <rect x="0" y="0" rx="'.($h*$border_radius).'px" ry="'.($h*$border_radius).'px" width="'.$w.'" height="'.$h.'" fill="'.$fill.'" stroke="none" />
200 $barw = (($value-$min) / ($max-$min) ) * $w;
201 $barcol = 'url(#GrGREEN)';
202 $svg .= '<rect x="0" y="0" rx="'.($h*$border_radius).'px" ry="'.($h*$border_radius).'px" width="'.$barw.'" height="'.$h.'" fill="'.$barcol.'" stroke="none" />';
207 $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" />';
209 // $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" />';
213 $svg .= '</g></svg>';