*/
var UpdateOptionsTestCase = TestCase("update-options");
-UpdateOptionsTestCase.prototype.opts = {
+var opts = {
width: 480,
height: 320,
};
-UpdateOptionsTestCase.prototype.data = "X,Y1,Y2\n" +
+var data = "X,Y1,Y2\n" +
"2011-01-01,2,3\n" +
"2011-02-02,5,3\n" +
"2011-03-03,6,1\n" +
* Tweaks the dygraph so it sets g._testDrawCalled to true when internal method
* drawGraph_ is called. Call unWrapDrawGraph when done with this.
*/
-UpdateOptionsTestCase.prototype.wrapDrawGraph = function(g) {
+var wrapDrawGraph = function(g) {
g._testDrawCalled = false;
g._oldDrawGraph = g.drawGraph_;
g.drawGraph_ = function() {
g._testDrawCalled = true;
g._oldDrawGraph.call(g);
}
-}
+};
/*
* See wrapDrawGraph
*/
-UpdateOptionsTestCase.prototype.unwrapDrawGraph = function(g) {
+var unwrapDrawGraph = function(g) {
g.drawGraph_ = g._oldDrawGraph;
}
UpdateOptionsTestCase.prototype.testStrokeAll = function() {
var graphDiv = document.getElementById("graph");
- var graph = new Dygraph(graphDiv, this.data, this.opts);
+ var graph = new Dygraph(graphDiv, data, opts);
var updatedOptions = { };
updatedOptions['strokeWidth'] = 3;
// These options will allow us to jump to renderGraph_()
// drawGraph_() will be skipped.
- this.wrapDrawGraph(graph);
+ wrapDrawGraph(graph);
graph.updateOptions(updatedOptions);
- this.unwrapDrawGraph(graph);
+ unwrapDrawGraph(graph);
assertFalse(graph._testDrawCalled);
};
UpdateOptionsTestCase.prototype.testStrokeSingleSeries = function() {
var graphDiv = document.getElementById("graph");
- var graph = new Dygraph(graphDiv, this.data, this.opts);
+ var graph = new Dygraph(graphDiv, data, opts);
var updatedOptions = { };
var optionsForY1 = { };
// These options will allow us to jump to renderGraph_()
// drawGraph_() will be skipped.
- this.wrapDrawGraph(graph);
+ wrapDrawGraph(graph);
graph.updateOptions(updatedOptions);
- this.unwrapDrawGraph(graph);
+ unwrapDrawGraph(graph);
assertFalse(graph._testDrawCalled);
};
UpdateOptionsTestCase.prototype.testSingleSeriesRequiresNewPoints = function() {
var graphDiv = document.getElementById("graph");
- var graph = new Dygraph(graphDiv, this.data, this.opts);
+ var graph = new Dygraph(graphDiv, data, opts);
var updatedOptions = {
series: {
Y1: {
// These options will not allow us to jump to renderGraph_()
// drawGraph_() must be called
- this.wrapDrawGraph(graph);
+ wrapDrawGraph(graph);
graph.updateOptions(updatedOptions);
- this.unwrapDrawGraph(graph);
+ unwrapDrawGraph(graph);
assertTrue(graph._testDrawCalled);
};
UpdateOptionsTestCase.prototype.testWidthChangeNeedsNewPoints = function() {
var graphDiv = document.getElementById("graph");
- var graph = new Dygraph(graphDiv, this.data, this.opts);
+ var graph = new Dygraph(graphDiv, data, opts);
var updatedOptions = { };
// This will require new points.
// These options will not allow us to jump to renderGraph_()
// drawGraph_() must be called
- this.wrapDrawGraph(graph);
+ wrapDrawGraph(graph);
graph.updateOptions(updatedOptions);
- this.unwrapDrawGraph(graph);
+ unwrapDrawGraph(graph);
assertTrue(graph._testDrawCalled);
};
UpdateOptionsTestCase.prototype.testUpdateLabelsDivDoesntInfiniteLoop = function() {
var graphDiv = document.getElementById("graph");
var labelsDiv = document.getElementById("labels");
- var graph = new Dygraph(graphDiv, this.data, this.opts);
+ var graph = new Dygraph(graphDiv, data, opts);
graph.updateOptions({labelsDiv : labelsDiv});
}
// Test https://github.com/danvk/dygraphs/issues/247
UpdateOptionsTestCase.prototype.testUpdateColors = function() {
var graphDiv = document.getElementById("graph");
- var graph = new Dygraph(graphDiv, this.data, this.opts);
+ var graph = new Dygraph(graphDiv, data, opts);
var defaultColors = ["rgb(0,128,0)", "rgb(0,0,128)"];
assertEquals(["rgb(0,128,0)", "rgb(0,0,128)"], graph.getColors());
});
assertEquals(colors2, graph.getColors());
- graph.updateOptions({ colors: null, file: this.data });
+ graph.updateOptions({ colors: null, file: data });
assertEquals(defaultColors, graph.getColors());
}
// legend.
UpdateOptionsTestCase.prototype.testUpdateLegendAlways = function() {
var graphDiv = document.getElementById("graph");
- var graph = new Dygraph(graphDiv, this.data, this.opts);
+ var graph = new Dygraph(graphDiv, data, opts);
var legend = document.getElementsByClassName("dygraph-legend");
assertEquals(1, legend.length);