[SPIP Zone] [Spip-zone-commit] r9956 - in /_dev_/top10: stats.html stats.php treemap.js

Y'a moyen de voir ça quelque part sans lancer soi-même le script qui teste tous les sites ?

Le 28 févr. 07 à 00:19, renato@rezo.net a écrit :

Author: renato@rezo.net
Date: Wed Feb 28 00:19:51 2007
New Revision: 9956

Log:
un peu de styles; les datas en title

Modified:
    _dev_/top10/stats.html
    _dev_/top10/stats.php
    _dev_/top10/treemap.js

Modified: _dev_/top10/stats.html

--- _dev_/top10/stats.html (original)
+++ _dev_/top10/stats.html Wed Feb 28 00:19:51 2007
@@ -11,6 +11,7 @@
     if(jQuery(this).is("#versions"))
       dataFunction = getDataVersions;
     jQuery(this).treemap(640,480,{target:jQuery(this).next(),getData:dataFunction});
+ enhanceTreemap(jQuery("div.treemap"));
   })
   
   jQuery("#clic").click(function(){
@@ -27,8 +28,8 @@
     var version = cells.eq(0).html();
     var maj = parseInt(version.replace(/[.-]/g,''))
     if(maj<100) maj *=10;
- var maj2 = parseInt(maj/10)//maj.substr(0,2);
- var maj3 = parseInt(maj%10)//maj.substr(0,2);
+ var maj2 = parseInt(maj/10);
+ var maj3 = parseInt(maj%10);
     if(!maj_versions[maj2]) maj_versions[maj2] = {};
     if(!maj_versions[maj2][maj3]) maj_versions[maj2][maj3] = ;
     maj_versions[maj2][maj3].push([version,cells.eq(1).html()]);
@@ -49,7 +50,21 @@
   return data;
}

+function enhanceTreemap(t,data) {
+ jQuery("div.treemapCell",t).hover(function(){jQuery(this).addClass("selected")},function(){jQuery(this).removeClass("selected")});
+}
+
</script>
+<style type="text/css">
+ .treemapCell {background-color:#FF6600}
+ .treemapHead {/*cursor:pointer;*/background-color:#B34700}
+ .treemapCell.selected, .treemapCell.selected .treemapCell.selected {background-color:#FFCC80 !important}
+ .treemapCell.selected .treemapCell {background-color:#FF9900}
+ .treemapCell.selected .treemapHead {background-color:#B36B00}
+ .transfer {border:1px solid black}
+</style>
+
</head>
<body>

Modified: _dev_/top10/stats.php

--- _dev_/top10/stats.php (original)
+++ _dev_/top10/stats.php Wed Feb 28 00:19:51 2007
@@ -7,7 +7,11 @@
jQuery(function(){
   jQuery("<div class='treemap'>").hide().insertAfter("table");
   jQuery("table").each(function(){
- jQuery(this).treemap(640,480,{target:jQuery(this).next()});
+ var dataFunction;
+ if(jQuery(this).is("#versions"))
+ dataFunction = getDataVersions;
+ jQuery(this).treemap(640,480,{target:jQuery(this).next(),getData:dataFunction});
+ enhanceTreemap(jQuery("div.treemap"));
   })
   
   jQuery("#clic").click(function(){
@@ -15,7 +19,49 @@
     jQuery(this).text( jQuery(this).is(":contains(treemap)")?"tableaux <<":">> treemap" );
   });
})
+
+function getDataVersions(t) {
+ var data = ;
+ var maj_versions = {};
+ jQuery("tr",t).each(function(){
+ var cells = jQuery(">td",this);
+ var version = cells.eq(0).html();
+ var maj = parseInt(version.replace(/[.-]/g,''))
+ if(maj<100) maj *=10;
+ var maj2 = parseInt(maj/10);
+ var maj3 = parseInt(maj%10);
+ if(!maj_versions[maj2]) maj_versions[maj2] = {};
+ if(!maj_versions[maj2][maj3]) maj_versions[maj2][maj3] = ;
+ maj_versions[maj2][maj3].push([version,cells.eq(1).html()]);
+ });
+
+ jQuery.each(maj_versions,function(i,n){
+ var row = [i[0]+'.'+i[1],n];
+ if(n.constructor==Object) {
+ var row2 = ;
+ jQuery.each(n,function(i,n2){
+ row2.push([row[0]+'.'+i,n2]);
+ });
+ row[1] = row2;
+ }
+
+ data.push(row);
+ });
+ return data;
+}
+
+function enhanceTreemap(t,data) {
+ jQuery("div.treemapCell",t).hover(function(){jQuery(this).addClass("selected")},function(){jQuery(this).removeClass("selected")});
+}
</script>
+<style type="text/css">
+ .treemapCell {background-color:#FF6600}
+ .treemapHead {background-color:#B34700}
+ .treemapCell.selected, .treemapCell.selected .treemapCell.selected {background-color:#FFCC80 !important}
+ .treemapCell.selected .treemapCell {background-color:#FF9900}
+ .treemapCell.selected .treemapHead {background-color:#B36B00}
+ .transfer {border:1px solid black}
+</style>
</head>
<body>

@@ -67,8 +113,8 @@

- function affiche_table($array) {
- echo "<table>\n";
+ function affiche_table($array,$id="") {
+ echo "<table".($id?" id='$id'":"").">\n";
     foreach ($array as $k => $n) {
       echo "<tr><td>$k</td><td>$n</td></tr>\n";
     }
@@ -78,7 +124,7 @@

   echo "<h2>Versions:</h2>\n";
   arsort($versions);
- affiche_table($versions);
+ affiche_table($versions,"versions");

   $total = count($sites) - $erreurs['injoignable'] - $erreurs['erreur 404'];
   $inconnue = ($total - array_sum($versions));

Modified: _dev_/top10/treemap.js

--- _dev_/top10/treemap.js (original)
+++ _dev_/top10/treemap.js Wed Feb 28 00:19:51 2007
@@ -6,7 +6,7 @@
*/
(function() {
jQuery.fn.treemap = function(w,h,options) {
- options = jQuery.extend({labelCell:0,dataCell:1,headHeight:20,borderWidth:1},options);
+ options = jQuery.extend({labelCell:0,dataCell:1,headHeight:20,borderWidth:1,sort:true},options);
   var or_target = options.target;
   return this.pushStack(jQuery.map(this,function(el){
     var data;
@@ -22,6 +22,7 @@
     if(jQuery.fn.treemap.caller!=treemap.layoutRow)
       treemap.normalizeValues(data);
     
+ if (options.sort)
     data.sort(function(a,b){
       var val1 = b[1], val2 = a[1];
       val1 = val1.constructor==Array?treemap.getValue(val1):val1;
@@ -129,10 +130,10 @@
     }
     var rl = row.length-1,sum = 0, bw = options.borderWidth, bw2 = bw*2, cells = ;
     for(var i=0;i<=rl;i++) {
- var n = row[i],hier = n[1].constructor == Array, head = ;
- var cell = treemap.emptyCell.clone().html(n[0]);
+ var n = row[i],hier = n[1].constructor == Array, head = , val = hier?treemap.getValue(n[1]):n[1];
+ var cell = treemap.emptyCell.clone().html(n[0]).attr('title',n[0]+' ('+val+')');
       var lastCell = i==rl;
- var fixedDim = rowDim, varDim = lastCell ? w-sum : Math.round((hier?treemap.getValue(n[1]):n[1])/h);
+ var fixedDim = rowDim, varDim = lastCell ? w-sum : Math.round(val/h);
       if(varDim<=0) return 0;
       sum += varDim;
       var cellStyles = {};

_______________________________________________
Spip-zone-commit@rezo.net - http://listes.rezo.net/mailman/listinfo/spip-zone-commit

-Nicolas

--
Nicolas "Brush" HOIZEY
Clever Age : http://www.clever-age.com/
Gastero Prod : http://www.gasteroprod.com/
Photos : http://www.flickr.com/gp/38608514@N00/M1c002
phpHeaven : http://www.phpheaven.net/

Y'a moyen de voir ça quelque part sans lancer soi-même le script qui
teste tous les sites ?

Ce n'est pas encore publié, mais ouvre stats.html dans ton navigateur

-- Fil

Y'a moyen de voir ça quelque part sans lancer soi-même le script qui
teste tous les sites ?

Ce n'est pas encore publié, mais ouvre stats.html dans ton navigateur

Excellent, merci !!!

-Nicolas

--
Nicolas "Brush" HOIZEY
Clever Age : http://www.clever-age.com/
Gastero Prod : http://www.gasteroprod.com/
Photos : http://www.flickr.com/gp/38608514@N00/M1c002
phpHeaven : http://www.phpheaven.net/