From: Dan Vanderkam Date: Sun, 10 Apr 2011 22:27:09 +0000 (-0400) Subject: fix embarrassing CSV error on dygraphs home page X-Git-Tag: v1.0.0~524^2 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;ds=sidebyside;h=327a92793133f1029aa530c9dfe9e6e197af10d2;p=dygraphs.git fix embarrassing CSV error on dygraphs home page --- 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