Bonjour à tous,
J'ai découvert jpgraph il y a environ trois semaines et je le trouve très puissant.
Néanmoins, il reste quelque "bugs" qui rendent son utilisation contre-intuitive.
J'ai un AccBarPlot qui contient n BarPlot.
Chaque BarPlot affiche sa valeur centrée verticalement et horizontalement.
Quand deux valeurs petites (par rapport aux total des valeurs) sont l'une au dessus de l'autre, les chiffres se chevauchent.
Ce que j'aimerais faire, c'est qu'un BarPlot sur deux, la valeur soit alignée à gauche horizontalement, à droite pour les autres.
Seulement, j'ai beau setter l'alignement des values des BarPlot, aucun effet.
Voilà mon code :
La partie commentée n'a aucun effet. Avez-vous une idée ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 $data = end($datas); $name = key($datas); while($data) { $bplot = new BarPlot($data); $bplot->SetLegend(formated_legend($name, $typeaggregate)); $bplot->SetCSIMTargets($targs[$name],$alts[$name]); $bplots[] = $bplot; $data = prev($datas); $name = key($datas); } $gbarplot = new AccBarPlot($bplots); $gbarplot->SetWidth(0.6); $gbarplot->SetValuePos('top'); $gbarplot->value->SetFont(FF_ARIAL,FS_BOLD); $gbarplot->value->SetColor("red","darkred"); $gbarplot->value->SetFormat('%d'); $gbarplot->value->SetAngle(34); $gbarplot->value->Show(); $graph->Add($gbarplot); krsort($datas); $names = array_keys($datas); $oColor = new Color(); $odd = true; foreach($bplots as $i => $bplot) { $oColor->hashColor($names[$i], 2); $color = "#".$oColor->toHexa(); $textcolor = ($oColor->isDark())?"white":"black"; $bplots[$i]->SetColor($color); $bplots[$i]->SetFillColor($color); $bplots[$i]->SetValuePos('center'); $bplots[$i]->value->SetFont(FF_ARIAL,FS_BOLD); $bplots[$i]->value->SetColor($textcolor); /* NE FONCTIONNE PAS ! $halign = ($odd)?'left':'right'; $bplots[$i]->value->SetAlign($halign);*/ $bplots[$i]->value->SetFormat("%d"); $bplots[$i]->value->Show(); $odd = !$odd; }
Partager