MediaWiki:Common.js
From FridaV
my_chart.ncols.push(name); | my_chart.ncols.push(name); | ||
}); // fields | }); // fields | ||
| - | |||
| - | |||
| - | |||
// get rows | // get rows | ||
} | } | ||
}); // rows | }); // rows | ||
| + | |||
| + | console.log(my_chart); | ||
| + | return; | ||
| + | |||
}); // tables | }); // tables | ||
} // init() | } // init() | ||
Revision as of 21:44, 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
// 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
console.log(my_chart);
return;
}); // tables
} // init()
}
$(document).ready(charts.init);
