Concernant
$marqueur_formes
, l'idée de passage dans une fonction était de pouvoir traiter ultérieurement les cas des drapeaux dont la syntaxe sera plus complexe et aussi l'affichage des valeurs en lieu et place des marqueurs, ce qui ne peut se faire totalement dans un array.
Pour le thème du camembert, on pourrait passer cela en couleur de fond (voir prochain commit) pour uniformiser les choses par rapport au traitement des couleurs.
A +;
Olivier Gautier.
erational@erational.org a écrit :
Author: erational@erational.org
Date: Thu Oct 29 10:32:53 2009
New Revision: 32463Log:
nettoyage de codeModified:
_plugins_/jpgraph/jpgraph_fonctions.php
_plugins_/jpgraph/plugin.xmlModified: _plugins_/jpgraph/jpgraph_fonctions.php
--- _plugins_/jpgraph/jpgraph_fonctions.php (original)
+++ _plugins_/jpgraph/jpgraph_fonctions.php Thu Oct 29 10:32:53 2009
@@ -9,8 +9,8 @@
// (a ameliorer activer le cache de jpgraph ou celui de spip ?)
function jpgraph_name_hash($type="graph",$largeur,$hauteur,$donnee) {
// repertoire IMG/jpgraph dispo ?
- if (!is_dir(_DIR_VAR."jpgraph/")) { - if (!mkdir (_DIR_VAR."jpgraph/", 0777)) // on essaie de le creer + if (!is_dir(_DIR_VAR."cache-jpgraph/")) { + if (!mkdir (_DIR_VAR."cache-jpgraph/", 0777)) // on essaie de le creer spip_log("plugin jgraph: impossible de creer le reperoitre image");
}
@@ -18,26 +18,10 @@
$donnee = $largeur;
$donnee = $hauteur;
$hash = md5(serialize($donnee));
- return _DIR_VAR."jpgraph/$type-$hash.png";
+ return _DIR_VAR."cache-jpgraph/$type-$hash.png";
}-function jpgraph_nom_marqueur($plot,$marqueur) {
-switch($marqueur) {
- case 'carre': $plot->mark->SetType(MARK_SQUARE); break;
- case 'triangle': $plot->mark->SetType(MARK_UTRIANGLE); break;
- case 'triangle_bas': $plot->mark->SetType(MARK_DTRIANGLE); break;
- case 'losange': $plot->mark->SetType(MARK_DIAMOND); break;
- case 'cercle': $plot->mark->SetType(MARK_CIRCLE); break;
- case 'cercle_plein': $plot->mark->SetType(MARK_FILLEDCIRCLE); break;
- case 'croix': $plot->mark->SetType(MARK_CROSS); break;
- case 'croix_x': $plot->mark->SetType(MARK_X); break;
- case 'etoile': $plot->mark->SetType(MARK_STAR); break;
- default: $plot->mark->SetType(MARK_SQUARE); break;
-}
-
//
// filtre pour creer des courbes simples
//
@@ -56,7 +40,19 @@
$marqueur_couleur="",
$marqueur_epaisseur="",
$marqueur_couleur_fond="",
- $style=""){
+ $style="")
+{
+
+ // constantes
+ $marqueur_formes = array("carre"=>MARK_SQUARE,
+ "triangle"=> MARK_UTRIANGLE,
+ "triangle_bas"=> MARK_DTRIANGLE,
+ "losange"=> MARK_DIAMOND,
+ "cercle"=> MARK_CIRCLE,
+ "disque"=> MARK_FILLEDCIRCLE,
+ "croix"=> MARK_CROSS,
+ "croix_x" => MARK_X,
+ "etoile" => MARK_STAR);
// traiter les donnees
$type_graphe = strtolower(trim($type_graphe)); // pour pb avec les modeles si du blanc en fin de ligne
@@ -111,17 +107,17 @@
$graph->SetScale('textlin');
// Create the linear plot
$plot=new LinePlot($donnee);
+ // style & couleur
$plot->SetColor($couleur);
if ($style=='marches') $plot->SetStepStyle();
if ($fond_degrade) $plot->SetFillGradient($fond_degrade[0],$fond_degrade[1]);
if ($couleur_fond) $plot->SetFillColor($couleur_fond);
if ($epaisseur) $plot->SetWeight($epaisseur);
- if ($marqueur_forme) {
- jpgraph_nom_marqueur($plot,$marqueur_forme);
+ if (isset($marqueur_formes[$marqueur_forme])) + $plot->mark->SetType($marqueur_formes[$marqueur_forme]); if ($marqueur_couleur) $plot->mark->SetColor($marqueur_couleur);
if ($marqueur_couleur_fond) $plot->mark->SetFillColor($marqueur_couleur_fond);
if ($marqueur_epaisseur)$plot->mark->SetWidth($marqueur_epaisseur);
- }
// titre & legende $graph->title->Set(utf8_decode($titre));
@@ -143,7 +139,8 @@
case "camembert": $graph = new PieGraph($largeur,$hauteur); // Create the linear plot
$plot = new PiePlot($donnee);
- $plot->SetTheme("earth"); + // style & couleur
+ //$plot->SetTheme($style); // titre & legende $graph->title->Set(utf8_decode($titre));
if (count($legende)>1)Modified: _plugins_/jpgraph/plugin.xml
--- _plugins_/jpgraph/plugin.xml (original)
+++ _plugins_/jpgraph/plugin.xml Thu Oct 29 10:32:53 2009
@@ -1,6 +1,6 @@
<plugin>
<nom>JpGraph</nom>
- <auteur>mise en plugin [erational->http://www.erational.org], complété par Olivier Gautier</auteur>
+ <auteur>mise en plugin [erational->http://www.erational.org], Olivier Gautier</auteur>
<licence>QPL 1.0</licence>
<version>0.2</version>
<description>_______________________________________________
Spip-zone-commit@rezo.net - http://listes.rezo.net/mailman/listinfo/spip-zone-commit