From 327a92793133f1029aa530c9dfe9e6e197af10d2 Mon Sep 17 00:00:00 2001 From: Dan Vanderkam Date: Sun, 10 Apr 2011 18:27:09 -0400 Subject: [PATCH] fix embarrassing CSV error on dygraphs home page --- dygraph.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/dygraph.js b/dygraph.js index ab5d490..8b1c5ea 100644 --- a/dygraph.js +++ b/dygraph.js @@ -3196,10 +3196,21 @@ Dygraph.prototype.parseCSV_ = function(data) { } else if (this.attr_("customBars")) { // Bars are a low;center;high tuple for (var j = 1; j < inFields.length; j++) { - var vals = inFields[j].split(";"); - fields[j] = [ this.parseFloat_(vals[0], i, line), - this.parseFloat_(vals[1], i, line), - this.parseFloat_(vals[2], i, line) ]; + var val = inFields[j]; + if (/^ *$/.test(val)) { + fields[j] = [null, null, null]; + } else { + var vals = val.split(";"); + if (vals.length == 3) { + fields[j] = [ this.parseFloat_(vals[0], i, line), + this.parseFloat_(vals[1], i, line), + this.parseFloat_(vals[2], i, line) ]; + } else { + this.warning('When using customBars, values must be either blank ' + + 'or "low;center;high" tuples (got "' + val + + '" on line ' + (1+i)); + } + } } } else { // Values are just numbers -- 2.7.4