$itemtype = 'Computer';
$table_item = getTableForItemType($itemtype);
+$svg_colors = Array('red'=>'#ffa0a0', 'green'=>'#a0ffa0', 'yellow'=>'#ffdd80', 'blue'=>'#a0a0ff');
+
function svg_circle($color, $size=4) {
+ global $svg_colors;
+ if (array_key_exists($color, $svg_colors)) { $color = $svg_colors[$color]; }
$r = (int)$size; $cx = $r+1; $cy = $r+1;
$svg = '<svg width="'.(2+2*$r).'" height="'.(2+2*$r).'" style="margin: 1px; vertical-align: middle;">';
$svg .= "<circle cx='$cx' cy='$cy' r='$r' stroke='black' stroke-width='0' fill='$color' />";
}
function svg_pie_chart($values, $size=16) {
- $colors = Array("#ffa0a0", "#a0ffa0", "#ffffa0", "#a0a0ff"); $color_idx = 0;
+ global $svg_colors;
+ $color_names = Array('red', 'green', 'yellow', 'blue'); $color_idx = 0;
$total = 0.0; foreach ($values as $v) { $total += $v; }
$r = (int)$size; $cx = $r+1; $cy = $r+1; $rad = 2*pi()/$total; $old_a = 0;
$svg = '<svg width="'.(2+2*$r).'" height="'.(2+2*$r).'" style="margin: 2px; vertical-align: middle;">';
$x2 = $cx + $r * cos(-($old_a + $a) * $rad);
$y2 = $cy + $r * sin(-($old_a + $a) * $rad);
$big = ($a > ($total/2)) ? '1' : '0';
- $color = $colors[$color_idx++];
+ $color = $svg_colors[$color_names[$color_idx++]];
$svg .= "<path d=\"M$cx,$cy L$x1,$y1 A$r,$r 0 $big,0 $x2,$y2 z\" style=\"stroke: 0 black; fill: $color;\" />";
$old_a += $a;
}
echo "\n<span class='big b'>Ordinateurs par implantation</span><br><br>";
echo "<table class='tab_cadrehov'>";
echo "<tr class='tab_bg_1'><th rowspan='2' colspan='2'>Implantation</th>";
-echo "<th colspan='2'>".svg_circle("#ffa0a0")." Serveurs</th>";
-echo "<th colspan='2'>".svg_circle("#a0ffa0")." Clients internes</th>";
-echo "<th colspan='2'>".svg_circle("#ffffa0")." Clients publics</th>";
+echo "<th colspan='2'>".svg_circle('red')." Serveurs</th>";
+echo "<th colspan='2'>".svg_circle('green')." Clients internes</th>";
+echo "<th colspan='2'>".svg_circle('yellow')." Clients publics</th>";
echo "<th rowspan='2'>Total<br /><span style='font-size: 75%'>(+ sans statut)</span></th>";
-echo "<th rowspan='2'>".svg_circle("#a0a0ff")." Virtuels</th></tr>";
+echo "<th rowspan='2'>".svg_circle('blue')." Virtuels</th></tr>";
echo "<tr class='tab_bg_1'><th>Total</th><th>Production</th>";
echo "<th>Total</th><th>Attribué</th><th>Total</th><th>Attribué</th></tr>\n";