*
* @author danvk@google.com (Dan Vanderkam)
*/
+import Dygraph from '../../src/dygraph';
+import * as utils from '../../src/dygraph-utils';
-describe("to-dom-coords", function() {
+import Proxy from './Proxy';
+import CanvasAssertions from './CanvasAssertions';
+import {assertDeepCloseTo} from './custom_asserts';
-var origFunc = Dygraph.getContext;
-beforeEach(function() {
- document.body.innerHTML = "<div id='graph'></div>";
- Dygraph.getContext = function(canvas) {
- return new Proxy(origFunc(canvas));
- }
-});
+describe("to-dom-coords", function() {
-afterEach(function() {
- Dygraph.getContext = origFunc;
-});
+cleanupAfterEach();
+useProxyCanvas(utils, Proxy);
// Checks that toDomCoords and toDataCoords are inverses of one another.
var checkForInverses = function(g) {
it('testPlainChart', function() {
var opts = {
- axes : {
- x : {
+ axes: {
+ x: {
drawAxis : false,
- drawGrid : false,
+ drawGrid : false
},
- y : {
+ y: {
drawAxis : false,
- drawGrid : false,
+ drawGrid : false
}
},
rightGap: 0,
dateWindow: [0, 100],
width: 400,
height: 400,
- colors: ['#ff0000']
+ colors: ['#ff0000'],
+ labels: ['X', 'Y']
}
var graph = document.getElementById("graph");
it('testChartWithAxes', function() {
var opts = {
- axes : {
- x : {
+ axes: {
+ x: {
drawGrid: false,
drawAxis: true,
},
- y : {
+ y: {
drawGrid: false,
drawAxis: true,
axisLabelWidth: 100
dateWindow: [0, 100],
width: 500,
height: 450,
- colors: ['#ff0000']
+ colors: ['#ff0000'],
+ labels: ['X', 'Y']
}
var graph = document.getElementById("graph");
it('testChartWithAxesAndLabels', function() {
var opts = {
- axes : {
- x : {
+ axes: {
+ x: {
drawGrid: false,
drawAxis: true,
},
- y : {
+ y: {
drawGrid: false,
drawAxis: true,
axisLabelWidth: 100
- }
+ },
},
xAxisHeight: 50,
axisTickSize: 0,
xlabel: 'This is the x-axis',
xLabelHeight: 25,
title: 'This is the title of the chart',
- titleHeight: 25
+ titleHeight: 25,
+ labels: ['X', 'Y']
}
var graph = document.getElementById("graph");
valueRange: [0, 100],
dateWindow: [0, 100],
width: 500,
- height: 500
+ height: 500,
+ labels: ['X', 'Y']
}
var graph = document.getElementById("graph");
valueRange: [0, 100],
dateWindow: [0, 100],
width: 500,
- height: 500
+ height: 500,
+ labels: ['X', 'Y']
}
var graph = document.getElementById("graph");
drawAxis: false,
logscale: true
}
- }
+ },
+ labels: ['X', 'Y']
}
var graph = document.getElementById("graph");
drawGrid: false,
drawAxis: false
}
- }
+ },
+ labels: ['X', 'Y']
}
var graph = document.getElementById("graph");