* @author danvdk@gmail.com (Dan Vanderkam)
*/
import Dygraph from '../../src/dygraph';
+import * as utils from '../../src/dygraph-utils';
describe("data-api", function() {
cleanupAfterEach();
assert.equal(5, g.getRowForX(9));
});
+// indexFromSeriesName should return a value even if the series is invisible
+// In 1.1.1, if you request the last set and it's invisible, the method returns undefined.
+it('testIndexFromSetNameOnInvisibleSet', function() {
+
+ var localOpts = utils.clone(opts);
+ localOpts.visibility = [true, false];
+
+ var g = new Dygraph(graphDiv, [
+ "x,y1,y2",
+ "1,1,1",
+ "2,2,2",
+ "3,3,3"
+ ].join('\n'), localOpts);
+
+ assert.equal(2, g.indexFromSetName("y2"));
+});
+
});
this.setIndexByName_ = {};
var labels = this.attr_("labels");
- if (labels.length > 0) {
- this.setIndexByName_[labels[0]] = 0;
- }
var dataIdx = 0;
for (var i = 1; i < points.length; i++) {
- this.setIndexByName_[labels[i]] = i;
if (!this.visibility()[i - 1]) continue;
this.layout_.addDataset(labels[i], points[i]);
this.datasetIndex_[i] = dataIdx++;
}
+ for (var i = 0; i < labels.length; i++) {
+ this.setIndexByName_[labels[i]] = i;
+ }
this.computeYAxisRanges_(extremes);
this.layout_.setYAxes(this.axes_);