Author: croberts
Date: 2012-05-10 15:14:01 +0000 (Thu, 10 May 2012)
New Revision: 5371
Modified:
trunk/cumin/python/cumin/stat.strings
trunk/cumin/resources/app.js
Log:
Fixing issue where zooming-out causes the axes to be set incorrectly. The root of the
problem was that when we do a duration switch, we wind-up changing the axes on the
display, but the jqplot library remembers what the "original" axes were. The
original axes are recalled when the cursor plugin processes the resetZoom event. The fix
is for us to just force a destroy/new plot when we change durations. No noticible
difference for the end user (except for the fact that zooming/unzooming is now working).
Modified: trunk/cumin/python/cumin/stat.strings
===================================================================
--- trunk/cumin/python/cumin/stat.strings 2012-05-09 20:56:24 UTC (rev 5370)
+++ trunk/cumin/python/cumin/stat.strings 2012-05-10 15:14:01 UTC (rev 5371)
@@ -261,7 +261,7 @@
}
newurl = get_chart_url(id,
$(chart).getParent().getElements('a')[chart_href].get('href'), state);
$(chart).getParent().getElements('a')[chart_href].set('href',
newurl);
- drawSingleChart(chart);
+ drawSingleChart(chart, true);
}
return false;
}
Modified: trunk/cumin/resources/app.js
===================================================================
--- trunk/cumin/resources/app.js 2012-05-09 20:56:24 UTC (rev 5370)
+++ trunk/cumin/resources/app.js 2012-05-10 15:14:01 UTC (rev 5371)
@@ -319,7 +319,7 @@
oIcon.setProperty("title", "Full Page");
setFullpageParam(false, oFullPage);
$(oFullPage).getElement(".jqplotgraph").setProperty("style",
"width:400px;height:150px;");
- drawSingleChart($(oFullPage).getElement(".jqplotgraph"));
+ drawSingleChart($(oFullPage).getElement(".jqplotgraph"), false);
var onrestore = oFullPage.onrestore;
if (onrestore) onrestore();
window.scrollTo(oFullPage.origScroll.x, oFullPage.origScroll.y);
@@ -344,7 +344,7 @@
if (onfullpage)
onfullpage(coords.width, height);
$(oFullPage).getElement(".jqplotgraph").setProperty("style",
"width:100%");
- drawSingleChart($(oFullPage).getElement(".jqplotgraph"));
+ drawSingleChart($(oFullPage).getElement(".jqplotgraph"), false);
var curScroll = window.getScroll();
oFullPage.origScroll = curScroll;
window.scrollTo(0,0);
@@ -456,7 +456,7 @@
*/
drawAllCharts = function() {
$$('.jqplotgraph').each(function(thisdiv) {
- drawSingleChart(thisdiv);
+ drawSingleChart(thisdiv, false);
});
}
@@ -465,9 +465,12 @@
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) {
+drawSingleChart = function(id, doForceRedraw) {
var jsonurl =
$(id).getParent().getElements('a')[chart_href].get('href');
var passback = "";
+ if(allCharts[id.id]) {
+ allCharts[id.id].forceRedraw = doForceRedraw;
+ }
allCharts['chartNowTime'] = new Date();
wooly.setIntervalUpdate(jsonurl, stathandler, 0, passback, true);
}
@@ -484,7 +487,7 @@
chartParams = wooly.session.branch(jsonurl);
// for long-duration charts, updating is not particularly useful
if(chartParams.duration <= MAX_UPDATE_CHART_DURATION) {
- drawSingleChart(id);
+ drawSingleChart(id, false);
}
}
}
@@ -604,7 +607,7 @@
/*
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) {
+drawChart = function(holder, dataContainer, dataopts, forceRedraw) {
$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.
@@ -701,14 +704,19 @@
// if the chart already exists, perform a "replot()" on the chart, otherwise,
draw the chart from scratch
if(allCharts[divName] != undefined) {
- 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,pad:1.2,numberTicks:4,tickOptions:{formatString:'%.0f',formatter:
y_axis_Formatter,}}, 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);
+ if(allCharts[divName]["forceRedraw"] == true) {
+ allCharts[divName].destroy();
+ allCharts[divName] = $j.jqplot(holder,
dataContainer['y_coordinate_values'],chartOptionsObject);
+ } else {
+ 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,pad:1.2,numberTicks:4,tickOptions:{formatString:'%.0f',formatter:
y_axis_Formatter,}}, 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);