From: Robert Konigsberg Date: Sun, 18 Nov 2012 00:51:24 +0000 (-0600) Subject: Looking better -- handle the CSV/no label case. X-Git-Tag: v1.0.0~168^2~6 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=34825ef57158a0cfb37b0ceb59c687ecfc4a26fb;hp=c1780ad0fcfaa98acb399c976176ebefb25c8794;p=dygraphs.git Looking better -- handle the CSV/no label case. --- diff --git a/dygraph-options.js b/dygraph-options.js index 562fa24..33150fe 100644 --- a/dygraph-options.js +++ b/dygraph-options.js @@ -33,6 +33,16 @@ var DygraphOptions = function(dygraph) { this.global_user = this.dygraph_.user_attrs_ || {}; // Get a list of series names. + + var labels = this.find("labels"); + if (!labels) { + return; // -- can't do more for now, will parse after getting the labels. + }; + + this.reparseForLabels(); +} + +DygraphOptions.prototype.reparseSeries = function() { this.labels = this.find("labels").slice(1); var axisId = 0; // 0-offset; there's always one. @@ -75,7 +85,7 @@ var DygraphOptions = function(dygraph) { this.axes.push(axis_opts["y"] || {}); this.axes.push(axis_opts["y2"] || {}); } else { - this.axes.push(axis_opts["y"] || {}); // There has to be at least one axis. + this.axes.push({}); // There has to be at least one axis. } }; diff --git a/dygraph.js b/dygraph.js index 4189750..ae61842 100644 --- a/dygraph.js +++ b/dygraph.js @@ -2971,6 +2971,7 @@ Dygraph.prototype.parseCSV_ = function(data) { // User hasn't explicitly set labels, so they're (presumably) in the CSV. start = 1; this.attrs_.labels = lines[0].split(delim); // NOTE: _not_ user_attrs_. + this.attributes_.reparseSeries(); } var line_no = 0;