From 319abdbf06a052180b61bc8f5be5eb272690b4f2 Mon Sep 17 00:00:00 2001 From: Richard Wall Date: Mon, 4 Oct 2010 00:54:48 +0100 Subject: Add an error placeholder instead of replacing entire template content with error message - preventing subsequent chart rendering. --- jarmon/jarmon.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'jarmon/jarmon.js') diff --git a/jarmon/jarmon.js b/jarmon/jarmon.js index 6ac410c..06ec4c8 100644 --- a/jarmon/jarmon.js +++ b/jarmon/jarmon.js @@ -521,6 +521,9 @@ jarmon.Chart.prototype.draw = function() { return MochiKit.Async.gatherResults(results) .addCallback( function(self, data) { + // Clear any previous error messages. + self.template.find('.error').empty().hide(); + var i, label, disabled = []; unit = ''; for(i=0; i').text(self.siPrefix + unit) .css({width: '100px', @@ -556,7 +559,7 @@ jarmon.Chart.prototype.draw = function() { // table is useful as it generates an optimum label element // width which we can copy to the new divs + a little extra // to accomodate the color box - var legend = self.template.find('.graph-legend'); + var legend = self.template.find('.graph-legend').show(); legend.empty(); self.template.find('.legendLabel') .each(function(i, el) { @@ -585,7 +588,10 @@ jarmon.Chart.prototype.draw = function() { }, this) .addErrback( function(self, failure) { - self.template.text('error: ' + failure.message); + self.template.find('.chart').empty().hide(); + self.template.find('.graph-legend').empty().hide(); + self.template.find('.error').text('error: ' + failure.message); + }, this) .addBoth( function(self, res) { -- cgit v1.2.3