Add tests for new series option.
[dygraphs.git] / auto_tests / tests / per_series.js
index 3b6ee54..8f647cc 100644 (file)
@@ -1,9 +1,9 @@
 /**
- * @fileoverview FILL THIS IN
+ * @fileoverview Tests for per-series options.
  *
  * @author danvk@google.com (Dan Vanderkam)
  */
-var perSeriesTestCase = TestCase("per-series");
+var Tests for per-series options.
 
 perSeriesTestCase.prototype.setUp = function() {
   document.body.innerHTML = "<div id='graph'></div>";
@@ -12,43 +12,6 @@ perSeriesTestCase.prototype.setUp = function() {
 perSeriesTestCase.prototype.tearDown = function() {
 };
 
-/**
- * @constructor
- */
-var PixelSampler = function(dygraph) {
-  this.dygraph_ = dygraph;
-
-  var canvas = dygraph.hidden_;
-  var ctx = canvas.getContext("2d");
-  this.imageData_ = ctx.getImageData(0, 0, canvas.width, canvas.height);
-};
-
-/**
- * @param {number} x The screen x-coordinate at which to sample.
- * @param {number} y The screen y-coordinate at which to sample.
- * @return {Array.<number>} a 4D array: [R, G, B, alpha]. All four values
- * are in [0, 255]. A pixel which has never been touched will be [0,0,0,0].
- */
-PixelSampler.prototype.colorAtPixel = function(x, y) {
-  var i = 4 * (x + this.imageData_.width * y);
-  var d = this.imageData_.data;
-  return [d[i], d[i+1], d[i+2], d[i+3]];
-};
-
-/**
- * The method samples a color using data coordinates (not screen coordinates).
- * This will round your data coordinates to the nearest screen pixel before
- * sampling.
- * @param {number} x The data x-coordinate at which to sample.
- * @param {number} y The data y-coordinate at which to sample.
- * @return {Array.<number>} a 4D array: [R, G, B, alpha]. All four values
- * are in [0, 255]. A pixel which has never been touched will be [0,0,0,0].
- */
-PixelSampler.prototype.colorAtCoordinate = function(x, y) {
-  var dom_xy = this.dygraph_.toDomCoords(x, y);
-  return this.colorAtPixel(Math.round(dom_xy[0]), Math.round(dom_xy[1]));
-};
-
 
 perSeriesTestCase.prototype.testPerSeriesFill = function() {
   var opts = {
@@ -85,3 +48,16 @@ perSeriesTestCase.prototype.testPerSeriesFill = function() {
   assertEquals([255,0,0,38], sampler.colorAtCoordinate(6.5, 0.5));
 };
 
+perSeriesTestCase.prototype.testOldStyleSeries = function() {
+  var opts = {
+    pointSize : 5
+    Y: { pointSize : 4 },
+  };
+  var data = "X,Y,Z\n1,0,0\n";
+  g = new Dygraph("Graph", data, opts);
+
+  assertEquals(5, g.getOption("pointSize"));
+  assertEquals(4, g.getOption("pointSize", "Y"));
+  assertEquals(5, g.getOption("pointSize", "Z"));
+};
+