MediaWiki:Common.js
From FridaV
$('tr',this).each(function(j) { | $('tr',this).each(function(j) { | ||
if(j>=1) { | if(j>=1) { | ||
| - | + | var epoch=$('th.day',this).attr('epoch')*1000; | |
| - | + | $('td',this).each(function(ii) { // columns | |
| - | + | var a=my_chart.ncols[ii]; | |
| - | + | var v=this.innerHTML; | |
| - | + | if(v=='None') v=0; | |
| - | + | if(!my_chart.series[a]) my_chart.series[a]={ label: a , data: [] }; | |
| - | + | my_chart.series[a].data.unshift([epoch,parseFloat(v)]); | |
| - | + | }); // columns | |
| + | } | ||
}); // rows | }); // rows | ||
}); // tables | }); // tables | ||
Revision as of 21:43, 4 April 2009
/* Any JavaScript here will be loaded for all users on every page load. */
var charts = {
chart: {},
init: function() {
$('table.flot').each(function(i) {
var my_id=$(this).attr('id');
console.log('table '+my_id);
var my_chart={cols:{}, ncols:[], series:{}};
charts.chart[my_id]=my_chart;
// get fields
$('tr:first th',this).each(function(j) {
var name=this.innerHTML;
console.log('column '+name);
my_chart.cols[name]=j;
my_chart.ncols.push(name);
}); // fields
console.log(my_chart);
return;
// get rows
$('tr',this).each(function(j) {
if(j>=1) {
var epoch=$('th.day',this).attr('epoch')*1000;
$('td',this).each(function(ii) { // columns
var a=my_chart.ncols[ii];
var v=this.innerHTML;
if(v=='None') v=0;
if(!my_chart.series[a]) my_chart.series[a]={ label: a , data: [] };
my_chart.series[a].data.unshift([epoch,parseFloat(v)]);
}); // columns
}
}); // rows
}); // tables
} // init()
}
$(document).ready(charts.init);
