Remove legacy options:
[dygraphs.git] / auto_tests / tests / range_selector.js
index 5d143a7..a145d7a 100644 (file)
@@ -115,7 +115,6 @@ RangeSelectorTestCase.prototype.testRangeSelectorOptions = function() {
     showRangeSelector: true,
     rangeSelectorHeight: 30,
     rangeSelectorPlotFillColor: 'lightyellow',
-    rangeSelectorPlotStyleColor: 'yellow',
     labels: ['X', 'Y']
   };
   var data = [
@@ -333,7 +332,7 @@ RangeSelectorTestCase.prototype.testRangeSelectorPositionIfXAxisNotDrawn = funct
     width: 480,
     height: 100,
     xAxisHeight: 30,
-    drawXAxis: false,
+    axes : { x : { drawAxis: false }},
     showRangeSelector: true,
     rangeSelectorHeight: 30,
     labels: ['X', 'Y']
@@ -359,6 +358,7 @@ RangeSelectorTestCase.prototype.testMiniPlotDrawn = function() {
   var origFunc = Dygraph.getContext;
   var miniHtx;
   Dygraph.getContext = function(canvas) {
+    console.log(canvas.className);
     if (canvas.className != 'dygraph-rangesel-bgcanvas') {
       return origFunc(canvas);
     }
@@ -370,7 +370,7 @@ RangeSelectorTestCase.prototype.testMiniPlotDrawn = function() {
     width: 480,
     height: 100,
     xAxisHeight: 30,
-    drawXAxis: false,
+    axes : { x : { drawAxis: false }},
     showRangeSelector: true,
     rangeSelectorHeight: 30,
     rangeSelectorPlotStrokeColor: '#ff0000',
@@ -385,6 +385,7 @@ RangeSelectorTestCase.prototype.testMiniPlotDrawn = function() {
   var g = new Dygraph(graph, data, opts);
 
   // TODO(danvk): more precise tests.
+  assertNotNull(miniHtx);
   assertTrue(0 < CanvasAssertions.numLinesDrawn(miniHtx, '#ff0000'));
 
   Dygraph.getContext = origFunc;
@@ -449,6 +450,39 @@ RangeSelectorTestCase.prototype.testCombinedSeries = function() {
   }, combinedSeries);
 };
 
+// Tests selection of a specific series to average for the mini plot.
+RangeSelectorTestCase.prototype.testSelectedCombinedSeries = function() {
+  var opts = {
+    showRangeSelector: true,
+    labels: ['X', 'Y1', 'Y2', 'Y3', 'Y4'],
+    series: {
+      'Y1': { showInRangeSelector: true },
+      'Y3': { showInRangeSelector: true }
+    }
+  };
+  var data = [
+      [0, 5, 8, 13, 21],  // average (first and third) = 9
+      [5, 1, 3, 7, 14],   // average (first and third) = 4
+      [10, 0, 19, 10, 6]  // average (first and third) = 5
+    ];
+  var graph = document.getElementById("graph");
+  var g = new Dygraph(graph, data, opts);
+
+  var rangeSelector = g.getPluginInstance_(Dygraph.Plugins.RangeSelector);
+  assertNotNull(rangeSelector);
+
+  var combinedSeries = rangeSelector.computeCombinedSeriesAndLimits_();
+  assertEquals({
+    yMin: 4 - 5 * 0.25,  // 25% padding on combined series range.
+    yMax: 9 + 5 * 0.25,
+    data: [
+      [0, 9],
+      [5, 4],
+      [10, 5]
+    ]
+  }, combinedSeries);
+};
+
 // Tests data computation for the mini plot with a single error bar series.
 RangeSelectorTestCase.prototype.testSingleCombinedSeriesCustomBars = function() {
   var opts = {