Changeset 9956 in spip-zone
- Timestamp:
- Feb 27, 2007, 11:19:51 PM (14 years ago)
- Location:
- _dev_/top10
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
_dev_/top10/stats.html
r9951 r9956 12 12 dataFunction = getDataVersions; 13 13 jQuery(this).treemap(640,480,{target:jQuery(this).next(),getData:dataFunction}); 14 enhanceTreemap(jQuery("div.treemap")); 14 15 }) 15 16 … … 28 29 var maj = parseInt(version.replace(/[.-]/g,'')) 29 30 if(maj<100) maj *=10; 30 var maj2 = parseInt(maj/10) //maj.substr(0,2);31 var maj3 = parseInt(maj%10) //maj.substr(0,2);31 var maj2 = parseInt(maj/10); 32 var maj3 = parseInt(maj%10); 32 33 if(!maj_versions[maj2]) maj_versions[maj2] = {}; 33 34 if(!maj_versions[maj2][maj3]) maj_versions[maj2][maj3] = []; … … 50 51 } 51 52 53 function enhanceTreemap(t,data) { 54 jQuery("div.treemapCell",t).hover(function(){jQuery(this).addClass("selected")},function(){jQuery(this).removeClass("selected")}); 55 } 56 57 52 58 </script> 59 <style type="text/css"> 60 .treemapCell {background-color:#FF6600} 61 .treemapHead {/*cursor:pointer;*/background-color:#B34700} 62 .treemapCell.selected, .treemapCell.selected .treemapCell.selected {background-color:#FFCC80 !important} 63 .treemapCell.selected .treemapCell {background-color:#FF9900} 64 .treemapCell.selected .treemapHead {background-color:#B36B00} 65 .transfer {border:1px solid black} 66 </style> 67 53 68 </head> 54 69 <body> -
_dev_/top10/stats.php
r9948 r9956 7 7 jQuery(function(){ 8 8 jQuery("<div class='treemap'>").hide().insertAfter("table"); 9 jQuery("table").each(function(){ 10 jQuery(this).treemap(640,480,{target:jQuery(this).next()}); 9 jQuery("table").each(function(){ 10 var dataFunction; 11 if(jQuery(this).is("#versions")) 12 dataFunction = getDataVersions; 13 jQuery(this).treemap(640,480,{target:jQuery(this).next(),getData:dataFunction}); 14 enhanceTreemap(jQuery("div.treemap")); 11 15 }) 12 16 … … 16 20 }); 17 21 }) 22 23 function getDataVersions(t) { 24 var data = []; 25 var maj_versions = {}; 26 jQuery("tr",t).each(function(){ 27 var cells = jQuery(">td",this); 28 var version = cells.eq(0).html(); 29 var maj = parseInt(version.replace(/[.-]/g,'')) 30 if(maj<100) maj *=10; 31 var maj2 = parseInt(maj/10); 32 var maj3 = parseInt(maj%10); 33 if(!maj_versions[maj2]) maj_versions[maj2] = {}; 34 if(!maj_versions[maj2][maj3]) maj_versions[maj2][maj3] = []; 35 maj_versions[maj2][maj3].push([version,cells.eq(1).html()]); 36 }); 37 38 jQuery.each(maj_versions,function(i,n){ 39 var row = [i[0]+'.'+i[1],n]; 40 if(n.constructor==Object) { 41 var row2 = []; 42 jQuery.each(n,function(i,n2){ 43 row2.push([row[0]+'.'+i,n2]); 44 }); 45 row[1] = row2; 46 } 47 48 data.push(row); 49 }); 50 return data; 51 } 52 53 function enhanceTreemap(t,data) { 54 jQuery("div.treemapCell",t).hover(function(){jQuery(this).addClass("selected")},function(){jQuery(this).removeClass("selected")}); 55 } 18 56 </script> 57 <style type="text/css"> 58 .treemapCell {background-color:#FF6600} 59 .treemapHead {background-color:#B34700} 60 .treemapCell.selected, .treemapCell.selected .treemapCell.selected {background-color:#FFCC80 !important} 61 .treemapCell.selected .treemapCell {background-color:#FF9900} 62 .treemapCell.selected .treemapHead {background-color:#B36B00} 63 .transfer {border:1px solid black} 64 </style> 19 65 </head> 20 66 <body> … … 68 114 69 115 70 function affiche_table($array ) {71 echo "<table >\n";116 function affiche_table($array,$id="") { 117 echo "<table".($id?" id='$id'":"").">\n"; 72 118 foreach ($array as $k => $n) { 73 119 echo "<tr><td>$k</td><td>$n</td></tr>\n"; … … 79 125 echo "<h2>Versions:</h2>\n"; 80 126 arsort($versions); 81 affiche_table($versions );127 affiche_table($versions,"versions"); 82 128 83 129 $total = count($sites) - $erreurs['injoignable'] - $erreurs['erreur 404']; -
_dev_/top10/treemap.js
r9936 r9956 7 7 (function() { 8 8 jQuery.fn.treemap = function(w,h,options) { 9 options = jQuery.extend({labelCell:0,dataCell:1,headHeight:20,borderWidth:1 },options);9 options = jQuery.extend({labelCell:0,dataCell:1,headHeight:20,borderWidth:1,sort:true},options); 10 10 var or_target = options.target; 11 11 return this.pushStack(jQuery.map(this,function(el){ … … 23 23 treemap.normalizeValues(data); 24 24 25 data.sort(function(a,b){ 26 var val1 = b[1], val2 = a[1]; 27 val1 = val1.constructor==Array?treemap.getValue(val1):val1; 28 val2 = val2.constructor==Array?treemap.getValue(val2):val2; 29 return val1-val2; 30 }); 25 if (options.sort) 26 data.sort(function(a,b){ 27 var val1 = b[1], val2 = a[1]; 28 val1 = val1.constructor==Array?treemap.getValue(val1):val1; 29 val2 = val2.constructor==Array?treemap.getValue(val2):val2; 30 return val1-val2; 31 }); 31 32 32 33 options.target = or_target || el; … … 130 131 var rl = row.length-1,sum = 0, bw = options.borderWidth, bw2 = bw*2, cells = []; 131 132 for(var i=0;i<=rl;i++) { 132 var n = row[i],hier = n[1].constructor == Array, head = [] ;133 var cell = treemap.emptyCell.clone().html(n[0]) ;133 var n = row[i],hier = n[1].constructor == Array, head = [], val = hier?treemap.getValue(n[1]):n[1]; 134 var cell = treemap.emptyCell.clone().html(n[0]).attr('title',n[0]+' ('+val+')'); 134 135 var lastCell = i==rl; 135 var fixedDim = rowDim, varDim = lastCell ? w-sum : Math.round( (hier?treemap.getValue(n[1]):n[1])/h);136 var fixedDim = rowDim, varDim = lastCell ? w-sum : Math.round(val/h); 136 137 if(varDim<=0) return 0; 137 138 sum += varDim;
Note: See TracChangeset
for help on using the changeset viewer.