-// Copyright (c) 2011 Google, Inc.
+// Copyright (c) 2011 Google, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
*
* @author konigsberg@google.com (Robert Konigsberg)
*/
-var DEAD_SIMPLE_DATA = [[ 20061010, 2100 ]];
-var ZERO_TO_FIFTY = [[ 20061010, 0 ] , [ 20061011, 50 ]];
+var DEAD_SIMPLE_DATA = [[ 10, 2100 ]];
+var ZERO_TO_FIFTY = [[ 10, 0 ] , [ 20, 50 ]];
var SanityTestCase = TestCase("dygraphs-sanity");
assertNotNull(graph);
};
+// TODO(konigsberg): Move the following tests to a new package that
+// tests all kinds of toDomCoords, toDataCoords, toPercent, et cetera.
+
/**
* A sanity test of sorts, by ensuring the dygraph is created, and
* isn't just some piece of junk object.
var graph = document.getElementById("graph");
var g = new Dygraph(graph, ZERO_TO_FIFTY, { valueRange: [0,50] });
assertEquals([0, 50], g.yAxisRange(0));
+ g.updateOptions({valueRange: null, axes: {y: {valueRange: [10, 40]}}});
+ assertEquals([10, 40], g.yAxisRange(0));
};
-function assertEqualsDelta(msg, expected, actual, delta) {
- var args = this.argsWithOptionalMsg_(arguments, 4);
-
- var message = args[0];
- var exp = args[1];
- var act = args[2];
- var d = args[3];
- if (Math.abs(exp - act) > d) {
- fail(message +
- " Expected to be within " + d + " of " + exp + ", got " + act);
- }
-}
-
/**
* Test that valueRange matches the y-axis range specifically.
*
assertEquals(50, g.toDomYCoord(0));
assertEquals(0, g.toDomYCoord(50));
-
+
+ for (var x = 0; x <= 50; x++) {
+ assertEqualsDelta(50 - x, g.toDomYCoord(x), 0.00001);
+ }
+ g.updateOptions({valueRange: null, axes: {y: {valueRange: [0, 50]}}});
+
+ assertEquals(50, g.toDomYCoord(0));
+ assertEquals(0, g.toDomYCoord(50));
+
for (var x = 0; x <= 50; x++) {
assertEqualsDelta(50 - x, g.toDomYCoord(x), 0.00001);
}
};
+
+/**
+ * Test that the two-argument form of the constructor (no options) works.
+ */
+SanityTestCase.prototype.testTwoArgumentConstructor = function() {
+ var graph = document.getElementById("graph");
+ new Dygraph(graph, ZERO_TO_FIFTY);
+};
+
+// Here is the first of a series of tests that just ensure the graph is drawn
+// without exception.
+//TODO(konigsberg): Move to its own test case.
+SanityTestCase.prototype.testFillStack1 = function() {
+ var graph = document.getElementById("graph");
+ new Dygraph(graph, ZERO_TO_FIFTY, { stackedGraph: true });
+}
+
+SanityTestCase.prototype.testFillStack2 = function() {
+ var graph = document.getElementById("graph");
+ new Dygraph(graph, ZERO_TO_FIFTY, { stackedGraph: true, fillGraph: true });
+}
+
+SanityTestCase.prototype.testFillStack3 = function() {
+ var graph = document.getElementById("graph");
+ new Dygraph(graph, ZERO_TO_FIFTY, { fillGraph: true });
+}