Des bulles d’aides sur le graph des stats de SPIP

Ceci est une ARCHIVE, peut-être périmée. Vérifiez bien les compatibilités !

Les stats de spip avaient un manque pour moi : pas de bulle d’aide sur les jours pour avoir une valeur précise.
Cette contrib résoud la question.
Elle a été intégrée dans la version 1.8 de SPIP.

Il s’agit d’une modification du cœœur de SPIP.

Visuellement, elle donne ceci (noter la bulle d’aide sur fond jaune) :

Bulle d’aide sur les stats

Sur chaque colonne des stats, en passant la souris, on a dans une bulle d’aide :

  • la date concernée
  • le nombre de visites
  • la moyenne de ce jour là

La copie d’écran ne montre que le graphe des jours, mais la contrib rajoute aussi des bulles d’aide informative sur le graphe des mois.

Voici le diff entre la version originale 1.7.2 et celle-ci.

--- --- D:\!2004\!200407\spip\SPIP-v1-7-2\SPIP-v1-7-2\ecrire\statistiques_visites.php3	Thu May 13 17:08:46 2004 UTC
+++ D:\wwwrootDev\jpyrat\ecrire\statistiques_visites.php3	Wed Sep 8 23:23:21 2004 UTC
@@ -266,6 +266,9 @@
 		while (list($key, $value) = each($log)) {
 			$n++;
 		
+			//$ce_jour=date("Y-m-d", $key);
+			//$jour = nom_jour($ce_jour).' '.jour($ce_jour).' '.nom_mois($ce_jour).' '.annee($ce_jour);
+
 			if ($decal == 30) $decal = 0;
 			$decal ++;
 			$tab_moyenne[$decal] = $value;
@@ -279,6 +282,9 @@
 					$decal ++;
 					$tab_moyenne[$decal] = $value;
 
+                    $ce_jour=date("Y-m-d", $jour_prec+(3600*24*($i+1)));
+			        $jour = nom_jour($ce_jour).' '.jour($ce_jour).' '.nom_mois($ce_jour).' '.annee($ce_jour);
+
 					reset($tab_moyenne);
 					$moyenne = 0;
 					while (list(,$val_tab) = each($tab_moyenne))
@@ -288,15 +294,21 @@
 					$hauteur_moyenne = round(($moyenne) * $rapport) - 1;
 					echo "<td valign='bottom' width=$largeur>";
 					$difference = ($hauteur_moyenne) -1;
+					$moyenne = round($moyenne,2); // Pour affichage harmonieux
+                    $tagtitle='"'.attribut_html(supprimer_tags("$jour | "._T('info_visites')." 0 | "._T('info_moyenne')." $moyenne")).'"';
 					if ($difference > 0) {	
-						echo "<img src='img_pack/rien.gif' width=$largeur height=1 style='background-color:#333333;'>";
-						echo "<img src='img_pack/rien.gif' width=$largeur height=$hauteur_moyenne>";
+						echo "<img src='img_pack/rien.gif' width=$largeur height=1 style='background-color:#333333;' title=$tagtitle>";
+						echo "<img src='img_pack/rien.gif' width=$largeur height=$hauteur_moyenne title=$tagtitle>";
 					}
-					echo "<img src='img_pack/rien.gif' width=$largeur height=1 style='background-color:black;'>";
+					echo "<img src='img_pack/rien.gif' width=$largeur height=1 style='background-color:black;' title=$tagtitle>";
 					echo "</td>";
 					$n++;
 				}
 			}
+            
+   	        $ce_jour=date("Y-m-d", $key);
+			$jour = nom_jour($ce_jour).' '.jour($ce_jour).' '.nom_mois($ce_jour).' '.annee($ce_jour);
+
 			$total_loc = $total_loc + $value;
 			reset($tab_moyenne);
 
@@ -307,37 +319,40 @@
 		
 			$hauteur_moyenne = round($moyenne * $rapport) - 1;
 			$hauteur = round($value * $rapport)	- 1;
+			$moyenne = round($moyenne,2); // Pour affichage harmonieux
 			echo "<td valign='bottom' width=$largeur>";
 		
+
+		    $tagtitle='"'.attribut_html(supprimer_tags("$jour | "._T('info_visites')." $value | "._T('info_moyenne')." $moyenne")).'"';
 			if ($hauteur > 0){
 				if ($hauteur_moyenne > $hauteur) {
 					$difference = ($hauteur_moyenne - $hauteur) -1;
-					echo "<img src='img_pack/rien.gif' width=$largeur height=1 style='background-color:#333333;'>";
-					echo "<img src='img_pack/rien.gif' width=$largeur height=$difference>";
-					echo "<img src='img_pack/rien.gif' width=$largeur height=1 style='background-color:$couleur_foncee;'>";
+					echo "<img src='img_pack/rien.gif' width=$largeur height=1 style='background-color:#333333;' title=$tagtitle>";
+					echo "<img src='img_pack/rien.gif' width=$largeur height=$difference title=$tagtitle>";
+					echo "<img src='img_pack/rien.gif' width=$largeur height=1 style='background-color:$couleur_foncee;' title=$tagtitle>";
 					if (date("w",$key) == "0") // Dimanche en couleur foncee
-						echo "<img src='img_pack/rien.gif' width=$largeur height=$hauteur style='background-color:$couleur_foncee;'>";
+						echo "<img src='img_pack/rien.gif' width=$largeur height=$hauteur style='background-color:$couleur_foncee;' title=$tagtitle>";
 					else
-						echo "<img src='img_pack/rien.gif' width=$largeur height=$hauteur style='background-color:$couleur_claire;'>";
+						echo "<img src='img_pack/rien.gif' width=$largeur height=$hauteur style='background-color:$couleur_claire;' title=$tagtitle>";
 				} else if ($hauteur_moyenne < $hauteur) {
 					$difference = ($hauteur - $hauteur_moyenne) -1;
-					echo "<img src='img_pack/rien.gif' width=$largeur height=1 style='background-color:$couleur_foncee;'>";
+					echo "<img src='img_pack/rien.gif' width=$largeur height=1 style='background-color:$couleur_foncee;' title=$tagtitle>";
 					if (date("w",$key) == "0") // Dimanche en couleur foncee
 						$couleur =  $couleur_foncee;
 					else
 						$couleur = $couleur_claire;
-					echo "<img src='img_pack/rien.gif' width=$largeur height=$difference style='background-color:$couleur;'>";
-					echo "<img src='img_pack/rien.gif' width=$largeur height=1 style='background-color:#333333;'>";
-					echo "<img src='img_pack/rien.gif' width=$largeur height=$hauteur_moyenne style='background-color:$couleur;'>";
+					echo "<img src='img_pack/rien.gif' width=$largeur height=$difference style='background-color:$couleur;' title=$tagtitle>";
+					echo "<img src='img_pack/rien.gif' width=$largeur height=1 style='background-color:#333333;' title=$tagtitle>";
+					echo "<img src='img_pack/rien.gif' width=$largeur height=$hauteur_moyenne style='background-color:$couleur;' title=$tagtitle>";
 				} else {
-					echo "<img src='img_pack/rien.gif' width=$largeur height=1 style='background-color:$couleur_foncee;'>";
+					echo "<img src='img_pack/rien.gif' width=$largeur height=1 style='background-color:$couleur_foncee;' title=$tagtitle>";
 					if (date("w",$key) == "0") // Dimanche en couleur foncee
-						echo "<img src='img_pack/rien.gif' width=$largeur height=$hauteur style='background-color:$couleur_foncee;'>";
+						echo "<img src='img_pack/rien.gif' width=$largeur height=$hauteur style='background-color:$couleur_foncee;' title=$tagtitle>";
 					else
-						echo "<img src='img_pack/rien.gif' width=$largeur height=$hauteur style='background-color:$couleur_claire;'>";
+						echo "<img src='img_pack/rien.gif' width=$largeur height=$hauteur style='background-color:$couleur_claire;' title=$tagtitle>";
 				}
 			}
-			echo "<img src='img_pack/rien.gif' width=$largeur height=1 style='background-color:black;'>";
+			echo "<img src='img_pack/rien.gif' width=$largeur height=1 style='background-color:black;' title=$tagtitle>";
 			echo "</td>\n";
 		
 			$jour_prec = $key;
@@ -355,10 +370,12 @@
 			// basee sur la moyenne (site) ou popularite (article)
 			if (! $id_article) $val_popularite = $moyenne;
 			$prevision = (1 - (date("H")*60 - date("i"))/(24*60)) * $val_popularite;
-			$prevision = ceil($prevision * $rapport);
-			echo "<img src='img_pack/rien.gif' width=$largeur height=$prevision style='background-color:#eeeeee;'>";
+			$hauteurprevision = ceil($prevision * $rapport);
+			$prevision = round($prevision,0)+$visites_today; // Pour affichage harmonieux
+            $tagtitle='"'.attribut_html(supprimer_tags(_T('info_aujourdhui')." $visites_today &rarr; $prevision")).'"';
+			echo "<img src='img_pack/rien.gif' width=$largeur height=$hauteurprevision style='background-color:#eeeeee;' title=$tagtitle>";
 
-			echo "<img src='img_pack/rien.gif' width=$largeur height=$hauteur style='background-color:#cccccc;'>";
+			echo "<img src='img_pack/rien.gif' width=$largeur height=$hauteur style='background-color:#cccccc;' title=$tagtitle>";
 		}
 		echo "<img src='img_pack/rien.gif' width=$largeur height=1 style='background-color:black;'>";
 		echo "</td>";
@@ -480,6 +497,8 @@
 		while (list($key, $value) = each($entrees)) {
 			$n++;
 			
+			$mois = nom_mois($key).' '.annee($key);
+
 			if ($decal == 30) $decal = 0;
 			$decal ++;
 			$tab_moyenne[$decal] = $value;
@@ -495,44 +514,46 @@
 			$hauteur_moyenne = round($moyenne * $rapport) - 1;
 			$hauteur = round($value * $rapport)	- 1;
 			echo "<td valign='bottom' width=$largeur>";
+			$moyenne = round($moyenne,2); // Pour affichage harmonieux
+            $tagtitle='"'.attribut_html(supprimer_tags("$mois | "._T('info_visites')." $value | "._T('info_moyenne')." $moyenne")).'"';
 			
 			if ($hauteur > 0){
 				if ($hauteur_moyenne > $hauteur) {
 					$difference = ($hauteur_moyenne - $hauteur) -1;
-					echo "<img src='img_pack/rien.gif' width=$largeur height=1 style='background-color:#333333;'>";
-					echo "<img src='img_pack/rien.gif' width=$largeur height=$difference>";
-					echo "<img src='img_pack/rien.gif' width=$largeur height=1 style='background-color:$couleur_foncee;'>";
+					echo "<img src='img_pack/rien.gif' width=$largeur height=1 style='background-color:#333333;' title=$tagtitle>";
+					echo "<img src='img_pack/rien.gif' width=$largeur height=$difference title=$tagtitle>";
+					echo "<img src='img_pack/rien.gif' width=$largeur height=1 style='background-color:$couleur_foncee;' title=$tagtitle>";
 					if (ereg("-01",$key)){ // janvier en couleur foncee
-						echo "<img src='img_pack/rien.gif' width=$largeur height=$hauteur style='background-color:$couleur_foncee;'>";
+						echo "<img src='img_pack/rien.gif' width=$largeur height=$hauteur style='background-color:$couleur_foncee;' title=$tagtitle>";
 					} 
 					else {
-						echo "<img src='img_pack/rien.gif' width=$largeur height=$hauteur style='background-color:$couleur_claire;'>";
+						echo "<img src='img_pack/rien.gif' width=$largeur height=$hauteur style='background-color:$couleur_claire;' title=$tagtitle>";
 					}
 				}
 				else if ($hauteur_moyenne < $hauteur) {
 					$difference = ($hauteur - $hauteur_moyenne) -1;
-					echo "<img src='img_pack/rien.gif' width=$largeur height=1 style='background-color:$couleur_foncee;'>";
+					echo "<img src='img_pack/rien.gif' width=$largeur height=1 style='background-color:$couleur_foncee;' title=$tagtitle>";
 					if (ereg("-01",$key)){ // janvier en couleur foncee
 						$couleur =  $couleur_foncee;
 					} 
 					else {
 						$couleur = $couleur_claire;
 					}
-					echo "<img src='img_pack/rien.gif' width=$largeur height=$difference style='background-color:$couleur;'>";
-					echo "<img src='img_pack/rien.gif' width=$largeur height=1 style='background-color:#333333;'>";
-					echo "<img src='img_pack/rien.gif' width=$largeur height=$hauteur_moyenne style='background-color:$couleur;'>";
+					echo "<img src='img_pack/rien.gif' width=$largeur height=$difference style='background-color:$couleur;' title=$tagtitle>";
+					echo "<img src='img_pack/rien.gif' width=$largeur height=1 style='background-color:#333333;' title=$tagtitle>";
+					echo "<img src='img_pack/rien.gif' width=$largeur height=$hauteur_moyenne style='background-color:$couleur;' title=$tagtitle>";
 				}
 				else {
-					echo "<img src='img_pack/rien.gif' width=$largeur height=1 style='background-color:$couleur_foncee;'>";
+					echo "<img src='img_pack/rien.gif' width=$largeur height=1 style='background-color:$couleur_foncee;' title=$tagtitle>";
 					if (ereg("-01",$key)){ // janvier en couleur foncee
-						echo "<img src='img_pack/rien.gif' width=$largeur height=$hauteur style='background-color:$couleur_foncee;'>";
+						echo "<img src='img_pack/rien.gif' width=$largeur height=$hauteur style='background-color:$couleur_foncee;' title=$tagtitle>";
 					} 
 					else {
-						echo "<img src='img_pack/rien.gif' width=$largeur height=$hauteur style='background-color:$couleur_claire;'>";
+						echo "<img src='img_pack/rien.gif' width=$largeur height=$hauteur style='background-color:$couleur_claire;' title=$tagtitle>";
 					}
 				}
 			}
-			echo "<img src='img_pack/rien.gif' width=$largeur height=1 style='background-color:black;'>";
+			echo "<img src='img_pack/rien.gif' width=$largeur height=1 style='background-color:black;' title=$tagtitle>";
 			echo "</td>\n";
 			
 			$jour_prec = $key;

Et pour ceux qui préféreraient remplacer directement le fichier, il est joint ci-dessous.

À placer dans le dossier ecrire/ (une fois décompressé, bien sûr !).

Cette contrib utilise les chaine de langue déjà existantes dans spip !

Discussion

Aucune discussion

Ajouter un commentaire

Avant de faire part d’un problème sur un plugin X, merci de lire ce qui suit :

  • Désactiver tous les plugins que vous ne voulez pas tester afin de vous assurer que le bug vient bien du plugin X. Cela vous évitera d’écrire sur le forum d’une contribution qui n’est finalement pas en cause.
  • Cherchez et notez les numéros de version de tout ce qui est en place au moment du test :
    • version de SPIP, en bas de la partie privée
    • version du plugin testé et des éventuels plugins nécessités
    • version de PHP (exec=info en partie privée)
    • version de MySQL / SQLite
  • Si votre problème concerne la partie publique de votre site, donnez une URL où le bug est visible, pour que les gens puissent voir par eux-mêmes.
  • En cas de page blanche, merci d’activer l’affichage des erreurs, et d’indiquer ensuite l’erreur qui apparaît.

Merci d’avance pour les personnes qui vous aideront !

Par ailleurs, n’oubliez pas que les contributeurs et contributrices ont une vie en dehors de SPIP.

Qui êtes-vous ?
[Se connecter]

Pour afficher votre trombine avec votre message, enregistrez-la d’abord sur gravatar.com (gratuit et indolore) et n’oubliez pas d’indiquer votre adresse e-mail ici.

Ajoutez votre commentaire ici

Ce champ accepte les raccourcis SPIP {{gras}} {italique} -*liste [texte->url] <quote> <code> et le code HTML <q> <del> <ins>. Pour créer des paragraphes, laissez simplement des lignes vides.

Ajouter un document

Suivre les commentaires : RSS 2.0 | Atom