<script type="text/javascript" src="../tests/css.js"></script>
<script type="text/javascript" src="../tests/custom_bars.js"></script>
<script type="text/javascript" src="../tests/date_formats.js"></script>
+ <script type="text/javascript" src="../tests/dygraph-options-tests.js"></script>
<script type="text/javascript" src="../tests/error_bars.js"></script>
<script type="text/javascript" src="../tests/formats.js"></script>
<script type="text/javascript" src="../tests/interaction_model.js"></script>
--- /dev/null
+/**
+ * @fileoverview Test cases for DygraphOptions.
+ */
+var DygraphOptionsTestCase = TestCase("dygraph-options-tests");
+
+DygraphOptionsTestCase.prototype.setUp = function() {
+ document.body.innerHTML = "<div id='graph'></div>";
+};
+
+DygraphOptionsTestCase.prototype.tearDown = function() {
+};
+
+/*
+ * Pathalogical test to ensure getSeriesNames works
+ */
+DygraphOptionsTestCase.prototype.testGetSeriesNames = function() {
+ var opts = {
+ width: 480,
+ height: 320
+ };
+ var data = "X,Y,Y2,Y3\n" +
+ "0,-1,0,0";
+
+ // Kind of annoying that you need a DOM to test the object.
+ var graph = document.getElementById("graph");
+ var g = new Dygraph(graph, data, opts);
+
+ // We don't need to get at g's attributes_ object just
+ // to test DygraphOptions.
+ var o = new DygraphOptions(g);
+ assertEquals(["Y", "Y2", "Y3"], o.seriesNames());
+};
return; // -- can't do more for now, will parse after getting the labels.
}
- this.labels = labels.slice(1);
+ this.labels_ = labels.slice(1);
this.yAxes_ = [ { series : [], options : {}} ]; // Always one axis at least.
this.xAxis_ = { options : {} };
if (oldStyleSeries) {
var axisId = 0; // 0-offset; there's always one.
// Go through once, add all the series, and for those with {} axis options, add a new axis.
- for (var idx = 0; idx < this.labels.length; idx++) {
- var seriesName = this.labels[idx];
+ for (var idx = 0; idx < this.labels_.length; idx++) {
+ var seriesName = this.labels_[idx];
var optionsForSeries = this.user_[seriesName] || {};
// Go through one more time and assign series to an axis defined by another
// series, e.g. { 'Y1: { axis: {} }, 'Y2': { axis: 'Y1' } }
- for (var idx = 0; idx < this.labels.length; idx++) {
- var seriesName = this.labels[idx];
+ for (var idx = 0; idx < this.labels_.length; idx++) {
+ var seriesName = this.labels_[idx];
var optionsForSeries = this.series_[seriesName]["options"];
var axis = optionsForSeries["axis"];
}
}
} else {
- for (var idx = 0; idx < this.labels.length; idx++) {
- var seriesName = this.labels[idx];
+ for (var idx = 0; idx < this.labels_.length; idx++) {
+ var seriesName = this.labels_[idx];
var optionsForSeries = this.user_.series[seriesName] || {};
var yAxis = DygraphOptions.axisToIndex_(optionsForSeries["axis"]);