Author: croberts
Date: 2011-10-12 18:33:46 +0000 (Wed, 12 Oct 2011)
New Revision: 5061
Modified:
branches/noflash/cumin/resources/app.js
Log:
The new pure javascript charts will now update themselves on the fly.
Modified: branches/noflash/cumin/resources/app.js
===================================================================
--- branches/noflash/cumin/resources/app.js 2011-10-12 18:33:17 UTC (rev 5060)
+++ branches/noflash/cumin/resources/app.js 2011-10-12 18:33:46 UTC (rev 5061)
@@ -562,27 +562,35 @@
}
window.addEvent("domready", function() {
+ drawAllCharts();
+});
+
+drawAllCharts = function() {
$$('.jqplotgraph').each(function(thisdiv) {
- var div = $(thisdiv);
- var jsonurl = $(div).getElements('a').get('href');
- var jsonRequest = new Request.JSON({
- url : jsonurl,
+ var div = $(thisdiv);
+ var jsonurl = $(div).getElements('a').get('href');
+ var jsonRequest = new Request.JSON({
+ url : jsonurl,
+
+ onComplete : function(response) {
+ console.log("complete: " + response);
+ },
+ onFailure : function(error) {
+ console.log(error.responseText);
+ },
+ onSuccess : function(json) {
+ console.log("Success");
+ var dataopts = new Object();
+ dataopts['xmin'] = -3600;
+ dataopts['xmax'] = 0;
+ dataContainer = parseJson(json);
+ drawChart($(div).get('id'), dataContainer, dataopts);
+ }
+ }).get(); // the .get() here fires-off the json request
+ });
+ t = setTimeout("drawAllCharts()", 10000);
+}
- onComplete : function(response) {
- console.log("complete: " + response);
- },
- onFailure : function(error) {
- console.log(error.responseText);
- },
- onSuccess : function(json) {
- console.log("Success");
- dataContainer = parseJson(json);
- drawChart($(div).get('id'), dataContainer);
- }
- }).get(); // the .get() here fires-off the json request
- });
-});
-
parseJson = function(json) {
var dataContainer = new Object();
dataContainer['end_secs'] = json.end_secs;
@@ -638,7 +646,7 @@
return series;
}
-drawChart = function(holder, dataContainer) {
+drawChart = function(holder, dataContainer, dataopts) {
$j.jqplot.config.enablePlugins = true;
@@ -652,7 +660,7 @@
placement: "outsideGrid"},
axes: {
y2axis: {autoscale: true, min:0},
- xaxis: {autoscale: false, pad:0, min:-3600, max:0,
+ xaxis: {autoscale: false, pad:0, min:dataopts['xmin'],
max:dataopts['xmax'],
// probably need to pass in min/max based on current selection
// renderer:$j.jqplot.DateAxisRenderer,
// tickOptions: {formatString: '%#M'},
@@ -661,6 +669,7 @@
series: getSeries(dataContainer),
seriesColors: ['#cc0000', '#00cc00', '#0000cc'],
seriesDefaults: {
+ lineWidth:1,
fill:true,
fillAndStroke:true,
fillAlpha: 0.4,
Show replies by date