r5156 - branches/noflash/cumin/resources
by croberts@fedoraproject.org
Author: croberts
Date: 2011-11-30 20:53:45 +0000 (Wed, 30 Nov 2011)
New Revision: 5156
Modified:
branches/noflash/cumin/resources/app.js
Log:
Taking a moment to introduce some badly needed documentation into the jqplot charts.
Modified: branches/noflash/cumin/resources/app.js
===================================================================
--- branches/noflash/cumin/resources/app.js 2011-11-30 16:17:44 UTC (rev 5155)
+++ branches/noflash/cumin/resources/app.js 2011-11-30 20:53:45 UTC (rev 5156)
@@ -427,28 +427,52 @@
return false;
}
+/*
+ This block of code sets up the allCharts object which is where all of the
+ charts will be stored. If a given chart already exists in the allCharts
+ object, it will be redrawn rather than fully rebuilt to preserve client side
+ cycles/memory
+*/
var allCharts = new Object();
chart_href = 0; //used if we rearrange the divs that show the charts
window.addEvent("domready", function() {
drawAllCharts();
});
+
+/*
+ This function grabs all of the charts [with the .joplotgraph class] on the page and
+ triggers a draw [or redraw] for each of them
+*/
drawAllCharts = function() {
$$('.jqplotgraph').each(function(thisdiv) {
drawSingleChart(thisdiv);
});
}
+/*
+ This function grabs the data url (chart.json) from the div that will house the chart.
+ It then uses the wooly.setIntervalUpdate to fetch the data via AJAX and will call the stathandler
+ function after that data is fetched
+*/
drawSingleChart = function(id) {
var jsonurl = $(id).getParent().getElements('a')[chart_href].get('href');
var passback = "";
wooly.setIntervalUpdate(jsonurl, stathandler, 0, passback, true);
}
+/*
+ This function sets up the timer that will trigger the updating of each chart
+*/
startChartMonitor = function(id) {
setInterval(function() {drawSingleChart(id)}, 10000);
}
+/*
+ This function is meant to take the JSON response from cumin and do some basic work on it (determine max/min).
+ A lot of the dirtier work is done in the parseJson function.
+ After getting the data into the dataContainer object, the drawChart function is called
+*/
stathandler = function(response) {
try {
response = JSON.decode(response);
@@ -463,6 +487,13 @@
return true;
}
+
+/*
+ The parseJson function takes the output from cumin and massages it into
+ something that is useful for the charting library in use (currently jqplot).
+ It is most definitely easier to tweak this function as needed than it is to
+ make significant (and possibly temporary) adjustments to the cumin output
+*/
parseJson = function(json) {
var dataContainer = new Object();
dataContainer['end_secs'] = json.end_secs;
@@ -517,17 +548,20 @@
dataContainer['x_axis_values'] = dataContainer['x_axis_values']
.append([ json.x_axis.labels.labels[i].text ]);
}
-
-
-// console.log("end_secs: " + dataContainer['end_secs'] + " tnow: "
-// + dataContainer['tnow']);
+// console.log("end_secs: " + dataContainer['end_secs'] + " tnow: " + dataContainer['tnow']);
// console.log("x-axis vals: " + dataContainer['x_axis_values']);
// console.log("x_coord_vals: " + dataContainer['x_coordinate_values']);
// console.log("y_coord_vals: " + dataContainer['y_coordinate_values']);
return dataContainer;
}
-
+
+
+/*
+ This function takes the dataContainer and formats the data (and labels)
+ for jqplot library. The resultant series array is used in the options
+ passed to draw the chart.
+*/
getSeries = function(dataContainer) {
var series = new Array(dataContainer['labels'].length);
for(var i=0; i < dataContainer['labels'].length; i++) {
@@ -535,10 +569,15 @@
}
return series;
}
-
+
+/*
+ This function will render a jqplot chart for the given div (holder), dataContainer (lists of data) and options on that data (dataopts)
+*/
drawChart = function(holder, dataContainer, dataopts) {
- $j.jqplot.config.enablePlugins = true;
+ $j.jqplot.config.enablePlugins = true; // needed when using pie and non-pie charts since pie charts explicitly turn off enablePlugins
+ // The chartOptionsObject is where the action is. Pretty much every characteristic of the chart is defined here.
+ // Details on usage are found here: http://www.jqplot.com/docs/files/usage-txt.html
var chartOptionsObject = {
title: {
text: '',
@@ -572,7 +611,6 @@
pad:0,
min:dataopts['xmin'] / dataContainer['x_axis_normalizer'],
max:dataopts['xmax'] / dataContainer['x_axis_normalizer'],
- //ticks:[[-3600, "60 min"], [-2700, "45 min"], [-1800, "30 min"], [-900, "15 min"], [0, "0"]]
tickOptions:{formatString:'%.0f ' + dataContainer['x_axis_unit_label'], formatter: x_axis_Formatter,},
}
},
@@ -587,44 +625,47 @@
highlightMouseOver: false,
highlightMouseDown: false,
highlightColor: null,
- markerRenderer: $j.jqplot.MarkerRenderer,
+ markerRenderer: $j.jqplot.MarkerRenderer,
},
markerOptions: {show:true,
lineWidth:2,
style:'filledCircle',
size:4,
- },
+ },
},
highlighter: {
- tooltipaxes:'xy',
- show: true,
- formatString:'<table class="jqplot-highlighter"><tr><td>Time:</td><td>%s</td></tr><tr><td>Value:</td><td>%s</td></tr></table>'
+ tooltipaxes:'xy',
+ show: true,
+ formatString:'<table class="jqplot-highlighter"><tr><td>Time:</td><td>%s</td></tr><tr><td>Value:</td><td>%s</td></tr></table>'
},
cursor:{show:true,
- zoom:true,
- looseZoom:true,
- showCursorLegend:false,
- constrainZoomTo: 'x'
- },
-
- }
+ zoom:true,
+ looseZoom:true,
+ showCursorLegend:false,
+ constrainZoomTo: 'x'
+ },
+ }; // end of chartOptionsObject
+
var divName = $(holder).get('id');
+
+ // if the chart already exists, perform a "replot()" on the chart, otherwise, draw the chart from scratch
if(allCharts[divName]) {
for(i=0; i < allCharts[divName].series.length; i++) {
allCharts[divName].series[i].data = dataContainer['y_coordinate_values'][i];
}
- try{
- allCharts[divName].replot({resetAxes:(!allCharts[divName].plugins.cursor._zoom.isZoomed), axes:{y2axis:{autoscale:true,min:0,numberTicks:4,}, xaxis:{min:dataopts['xmin'] / dataContainer['x_axis_normalizer'], max:dataopts['xmax'] / dataContainer['x_axis_normalizer'],tickOptions:{formatString:'%.0f ' + dataContainer['x_axis_unit_label'], formatter: x_axis_Formatter,}}}})
- } catch (err) {
- // this is needed in the event of the first draw for a fullpage chart
- allCharts[divName] = $j.jqplot(holder, dataContainer['y_coordinate_values'],chartOptionsObject);
- }
+ try {
+ allCharts[divName].replot({resetAxes:(!allCharts[divName].plugins.cursor._zoom.isZoomed), axes:{y2axis:{autoscale:true,min:0,numberTicks:4,}, xaxis:{min:dataopts['xmin'] / dataContainer['x_axis_normalizer'], max:dataopts['xmax'] / dataContainer['x_axis_normalizer'],tickOptions:{formatString:'%.0f ' + dataContainer['x_axis_unit_label'], formatter: x_axis_Formatter,}}}})
+ } catch (err) {
+ // this is needed in the event of the first draw for a fullpage chart
+ allCharts[divName] = $j.jqplot(holder, dataContainer['y_coordinate_values'],chartOptionsObject);
+ }
} else {
allCharts[divName] = $j.jqplot(holder, dataContainer['y_coordinate_values'],chartOptionsObject);
startChartMonitor(divName);
}
-}
-
+} // end functio drawChart
+
+// used in axis:tickOptions:formatter to override the default axis label formatting
x_axis_Formatter = function (format, val) {
if (typeof val == 'number') {
if (!format) {
@@ -637,6 +678,7 @@
}
}
+// used in axis:tickOptions:formatter to override the default axis label formatting
y_axis_Formatter = function (format, val) {
tickval = "";
if (typeof val == 'number') {
@@ -659,6 +701,10 @@
return tickval;
}
+/*
+ This function draws or updates the pie located in "piediv"
+ with the given data (vals) and specified colors
+*/
updatePieChart = function (piediv, vals, colors) {
$j.jqplot.config.enablePlugins = false;
var data = vals;
@@ -696,6 +742,8 @@
);
}
+// utility for Pie chart drawing since cumin gives us separate lists for data values and labels.
+// This returns a single list of the format [[label1,data1], [labelN, dataN]]
combineValsAndLegend = function (vals, legend) {
var index, length;
var result = [];
12 years, 5 months
r5155 - branches/noflash/cumin/resources
by croberts@fedoraproject.org
Author: croberts
Date: 2011-11-30 16:17:44 +0000 (Wed, 30 Nov 2011)
New Revision: 5155
Modified:
branches/noflash/cumin/resources/app.js
Log:
Correcting y-axis ticks (from default of 3 to 4) for the update replot.
Modified: branches/noflash/cumin/resources/app.js
===================================================================
--- branches/noflash/cumin/resources/app.js 2011-11-29 16:20:03 UTC (rev 5154)
+++ branches/noflash/cumin/resources/app.js 2011-11-30 16:17:44 UTC (rev 5155)
@@ -614,7 +614,7 @@
allCharts[divName].series[i].data = dataContainer['y_coordinate_values'][i];
}
try{
- allCharts[divName].replot({resetAxes:(!allCharts[divName].plugins.cursor._zoom.isZoomed), axes:{y2axis:{autoscale:true,min:0}, xaxis:{min:dataopts['xmin'] / dataContainer['x_axis_normalizer'], max:dataopts['xmax'] / dataContainer['x_axis_normalizer'],tickOptions:{formatString:'%.0f ' + dataContainer['x_axis_unit_label'], formatter: x_axis_Formatter,}}}})
+ allCharts[divName].replot({resetAxes:(!allCharts[divName].plugins.cursor._zoom.isZoomed), axes:{y2axis:{autoscale:true,min:0,numberTicks:4,}, xaxis:{min:dataopts['xmin'] / dataContainer['x_axis_normalizer'], max:dataopts['xmax'] / dataContainer['x_axis_normalizer'],tickOptions:{formatString:'%.0f ' + dataContainer['x_axis_unit_label'], formatter: x_axis_Formatter,}}}})
} catch (err) {
// this is needed in the event of the first draw for a fullpage chart
allCharts[divName] = $j.jqplot(holder, dataContainer['y_coordinate_values'],chartOptionsObject);
12 years, 5 months
r5152 - branches/noflash/cumin/resources
by croberts@fedoraproject.org
Author: croberts
Date: 2011-11-28 20:21:11 +0000 (Mon, 28 Nov 2011)
New Revision: 5152
Modified:
branches/noflash/cumin/resources/app.js
Log:
Fixes for axis re-rendering when replot is called, including the fix for calling "replot" on a fresh full page chart, which was failing.
Modified: branches/noflash/cumin/resources/app.js
===================================================================
--- branches/noflash/cumin/resources/app.js 2011-11-28 20:18:54 UTC (rev 5151)
+++ branches/noflash/cumin/resources/app.js 2011-11-28 20:21:11 UTC (rev 5152)
@@ -573,8 +573,7 @@
min:dataopts['xmin'] / dataContainer['x_axis_normalizer'],
max:dataopts['xmax'] / dataContainer['x_axis_normalizer'],
//ticks:[[-3600, "60 min"], [-2700, "45 min"], [-1800, "30 min"], [-900, "15 min"], [0, "0"]]
- tickOptions:{formatString:'%.0f ' + dataContainer['x_axis_unit_label'],
- formatter: x_axis_Formatter,},
+ tickOptions:{formatString:'%.0f ' + dataContainer['x_axis_unit_label'], formatter: x_axis_Formatter,},
}
},
series: getSeries(dataContainer),
@@ -613,8 +612,13 @@
if(allCharts[divName]) {
for(i=0; i < allCharts[divName].series.length; i++) {
allCharts[divName].series[i].data = dataContainer['y_coordinate_values'][i];
- }
- allCharts[divName].replot({axes:{y2axis:{min:0}}})
+ }
+ try{
+ allCharts[divName].replot({resetAxes:(!allCharts[divName].plugins.cursor._zoom.isZoomed), axes:{y2axis:{autoscale:true,min:0}, xaxis:{min:dataopts['xmin'] / dataContainer['x_axis_normalizer'], max:dataopts['xmax'] / dataContainer['x_axis_normalizer'],tickOptions:{formatString:'%.0f ' + dataContainer['x_axis_unit_label'], formatter: x_axis_Formatter,}}}})
+ } catch (err) {
+ // this is needed in the event of the first draw for a fullpage chart
+ allCharts[divName] = $j.jqplot(holder, dataContainer['y_coordinate_values'],chartOptionsObject);
+ }
} else {
allCharts[divName] = $j.jqplot(holder, dataContainer['y_coordinate_values'],chartOptionsObject);
startChartMonitor(divName);
@@ -641,7 +645,7 @@
}
if (val > 1000000) {
val = val / 1000000
- format = "%.2fM";
+ format = "%.1fM";
}
if (val > 100000) {
val = val / 1000
12 years, 5 months
r5151 - branches/noflash/cumin/python/cumin
by croberts@fedoraproject.org
Author: croberts
Date: 2011-11-28 20:18:54 +0000 (Mon, 28 Nov 2011)
New Revision: 5151
Modified:
branches/noflash/cumin/python/cumin/stat.strings
Log:
Giving the charts a little more breathing room by making their divs 33em rather than 31em wide
Modified: branches/noflash/cumin/python/cumin/stat.strings
===================================================================
--- branches/noflash/cumin/python/cumin/stat.strings 2011-11-28 16:26:21 UTC (rev 5150)
+++ branches/noflash/cumin/python/cumin/stat.strings 2011-11-28 20:18:54 UTC (rev 5151)
@@ -111,7 +111,7 @@
font-size: 0.9em;
margin: 0 0 1.5em 0;
position: relative;
- width: 31em;
+ width: 33em;
}
div.StatValueChart div.duration {
12 years, 5 months
r5150 - branches/noflash/cumin/resources
by croberts@fedoraproject.org
Author: croberts
Date: 2011-11-28 16:26:21 +0000 (Mon, 28 Nov 2011)
New Revision: 5150
Modified:
branches/noflash/cumin/resources/app.js
Log:
Correcting y-axis label when we are displaying values > 100k.
Modified: branches/noflash/cumin/resources/app.js
===================================================================
--- branches/noflash/cumin/resources/app.js 2011-11-28 16:13:22 UTC (rev 5149)
+++ branches/noflash/cumin/resources/app.js 2011-11-28 16:26:21 UTC (rev 5150)
@@ -644,8 +644,8 @@
format = "%.2fM";
}
if (val > 100000) {
- val = val / 10000
- format = "%.2fk";
+ val = val / 1000
+ format = "%.1fk";
}
tickval = $j.jqplot.sprintf(format, val);
}
12 years, 5 months
r5149 - branches/noflash/cumin/resources
by croberts@fedoraproject.org
Author: croberts
Date: 2011-11-28 16:13:22 +0000 (Mon, 28 Nov 2011)
New Revision: 5149
Modified:
branches/noflash/cumin/resources/app.js
Log:
Updating data on a zoomed chart is now working. Also, changing from a complete regeneration of the chart on a data update to just swap-in the data and do a replot(). This should save memory and cpu cycles on the client machines.
Modified: branches/noflash/cumin/resources/app.js
===================================================================
--- branches/noflash/cumin/resources/app.js 2011-11-23 18:59:23 UTC (rev 5148)
+++ branches/noflash/cumin/resources/app.js 2011-11-28 16:13:22 UTC (rev 5149)
@@ -446,7 +446,7 @@
}
startChartMonitor = function(id) {
- setInterval(function() {drawSingleChart(id)}, 30000);
+ setInterval(function() {drawSingleChart(id)}, 10000);
}
stathandler = function(response) {
@@ -604,29 +604,17 @@
cursor:{show:true,
zoom:true,
looseZoom:true,
- showCursorLegend:false
+ showCursorLegend:false,
+ constrainZoomTo: 'x'
},
}
var divName = $(holder).get('id');
if(allCharts[divName]) {
- if(!allCharts[divName].plugins.cursor._zoom.isZoomed) {
- var parent = $(divName).getParent();
- var newDiv = $(divName);
- allCharts[divName].canvasManager.freeAllCanvases();
- if (allCharts[divName].eventCanvas) {
- allCharts[divName].eventCanvas._elem.unbind();
- }
- // Couple of posts on Stack Overflow indicate that empty() doesn't
- // always cear up the dom and release memory. Sometimes setting
- // innerHTML property to null is needed. Particularly on IE, may
- // have to directly set it to null, bypassing jQuery.
- allCharts[divName].target.empty();
- allCharts[divName].target[0].innerHTML = '';
- allCharts[divName].destroy();
- newDiv.inject(parent);
- allCharts[divName] = $j.jqplot(holder, dataContainer['y_coordinate_values'],chartOptionsObject);
- }
+ for(i=0; i < allCharts[divName].series.length; i++) {
+ allCharts[divName].series[i].data = dataContainer['y_coordinate_values'][i];
+ }
+ allCharts[divName].replot({axes:{y2axis:{min:0}}})
} else {
allCharts[divName] = $j.jqplot(holder, dataContainer['y_coordinate_values'],chartOptionsObject);
startChartMonitor(divName);
12 years, 5 months
r5148 - branches/noflash/cumin/resources
by croberts@fedoraproject.org
Author: croberts
Date: 2011-11-23 18:59:23 +0000 (Wed, 23 Nov 2011)
New Revision: 5148
Modified:
branches/noflash/cumin/resources/app.js
Log:
Fixing issue where a chart would update and lose its zoom. For now, when zoomed-in on a chart, it will not update. Updates will resume when the zoom level is reset.
Modified: branches/noflash/cumin/resources/app.js
===================================================================
--- branches/noflash/cumin/resources/app.js 2011-11-22 20:48:46 UTC (rev 5147)
+++ branches/noflash/cumin/resources/app.js 2011-11-23 18:59:23 UTC (rev 5148)
@@ -610,21 +610,23 @@
}
var divName = $(holder).get('id');
if(allCharts[divName]) {
- var parent = $(divName).getParent();
- var newDiv = $(divName);
- allCharts[divName].canvasManager.freeAllCanvases();
- if (allCharts[divName].eventCanvas) {
- allCharts[divName].eventCanvas._elem.unbind();
+ if(!allCharts[divName].plugins.cursor._zoom.isZoomed) {
+ var parent = $(divName).getParent();
+ var newDiv = $(divName);
+ allCharts[divName].canvasManager.freeAllCanvases();
+ if (allCharts[divName].eventCanvas) {
+ allCharts[divName].eventCanvas._elem.unbind();
+ }
+ // Couple of posts on Stack Overflow indicate that empty() doesn't
+ // always cear up the dom and release memory. Sometimes setting
+ // innerHTML property to null is needed. Particularly on IE, may
+ // have to directly set it to null, bypassing jQuery.
+ allCharts[divName].target.empty();
+ allCharts[divName].target[0].innerHTML = '';
+ allCharts[divName].destroy();
+ newDiv.inject(parent);
+ allCharts[divName] = $j.jqplot(holder, dataContainer['y_coordinate_values'],chartOptionsObject);
}
- // Couple of posts on Stack Overflow indicate that empty() doesn't
- // always cear up the dom and release memory. Sometimes setting
- // innerHTML property to null is needed. Particularly on IE, may
- // have to directly set it to null, bypassing jQuery.
- allCharts[divName].target.empty();
- allCharts[divName].target[0].innerHTML = '';
- allCharts[divName].destroy();
- newDiv.inject(parent);
- allCharts[divName] = $j.jqplot(holder, dataContainer['y_coordinate_values'],chartOptionsObject);
} else {
allCharts[divName] = $j.jqplot(holder, dataContainer['y_coordinate_values'],chartOptionsObject);
startChartMonitor(divName);
12 years, 5 months
r5147 - branches/noflash/cumin/resources
by croberts@fedoraproject.org
Author: croberts
Date: 2011-11-22 20:48:46 +0000 (Tue, 22 Nov 2011)
New Revision: 5147
Modified:
branches/noflash/cumin/resources/app.js
Log:
Changing to use white chart background for the time being.
Modified: branches/noflash/cumin/resources/app.js
===================================================================
--- branches/noflash/cumin/resources/app.js 2011-11-22 20:05:49 UTC (rev 5146)
+++ branches/noflash/cumin/resources/app.js 2011-11-22 20:48:46 UTC (rev 5147)
@@ -545,7 +545,7 @@
show: false,
},
gridPadding: {top:35, right:20, bottom:20, left:20},
- grid: { background: '#444444' },
+ grid: { background: '#FFFFFF' },
legend: {
show:true,
location: 'n',
12 years, 5 months
r5146 - branches/noflash/cumin
by croberts@fedoraproject.org
Author: croberts
Date: 2011-11-22 20:05:49 +0000 (Tue, 22 Nov 2011)
New Revision: 5146
Modified:
branches/noflash/cumin/Makefile
Log:
explicitly installing the contents of /wooly/resources by having separate install commands for *.js and *.css. This prevents the stderr entry for skipping the plugins directory which was causing the build to fail.
Modified: branches/noflash/cumin/Makefile
===================================================================
--- branches/noflash/cumin/Makefile 2011-11-22 19:35:15 UTC (rev 5145)
+++ branches/noflash/cumin/Makefile 2011-11-22 20:05:49 UTC (rev 5146)
@@ -28,7 +28,8 @@
install -d ${CUMIN_HOME}/model
install -pm 0644 model/*.xml ${CUMIN_HOME}/model
install -d ${CUMIN_HOME}/resources
- install -pm 0644 ../wooly/resources/* ${CUMIN_HOME}/resources
+ install -pm 0644 ../wooly/resources/*.css ${CUMIN_HOME}/resources
+ install -pm 0644 ../wooly/resources/*.js ${CUMIN_HOME}/resources
install -pm 0644 ../wooly/resources/plugins/* ${CUMIN_HOME}/resources
install -pm 0644 resources/* ${CUMIN_HOME}/resources
install -d ${CUMIN_HOME}/etc
12 years, 5 months
r5145 - branches/noflash/cumin
by croberts@fedoraproject.org
Author: croberts
Date: 2011-11-22 19:35:15 +0000 (Tue, 22 Nov 2011)
New Revision: 5145
Modified:
branches/noflash/cumin/Makefile
Log:
grabbing the wooly/resources/plugins directory for the build.
Modified: branches/noflash/cumin/Makefile
===================================================================
--- branches/noflash/cumin/Makefile 2011-11-21 21:18:18 UTC (rev 5144)
+++ branches/noflash/cumin/Makefile 2011-11-22 19:35:15 UTC (rev 5145)
@@ -29,6 +29,7 @@
install -pm 0644 model/*.xml ${CUMIN_HOME}/model
install -d ${CUMIN_HOME}/resources
install -pm 0644 ../wooly/resources/* ${CUMIN_HOME}/resources
+ install -pm 0644 ../wooly/resources/plugins/* ${CUMIN_HOME}/resources
install -pm 0644 resources/* ${CUMIN_HOME}/resources
install -d ${CUMIN_HOME}/etc
install -pm 0644 etc/cumin.* ${CUMIN_HOME}/etc
12 years, 5 months