From 34825ef57158a0cfb37b0ceb59c687ecfc4a26fb Mon Sep 17 00:00:00 2001 From: Robert Konigsberg Date: Sat, 17 Nov 2012 18:51:24 -0600 Subject: [PATCH 1/1] Looking better -- handle the CSV/no label case. --- dygraph-options.js | 12 +++++++++++- dygraph.js | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) 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; -- 2.7.4