* @author uemit.seren@gmail.com (Ümit Seren)
*/
+import Dygraph from '../../src/dygraph';
+import * as utils from '../../src/dygraph-utils';
+import Util from './Util';
+import DygraphOps from './DygraphOps';
+
describe("callback", function() {
+cleanupAfterEach();
+
var xhr, styleSheet;
+var graph;
beforeEach(function() {
- document.body.innerHTML = "<div id='graph'></div><div id='selection'></div>";
+ var container = document.getElementById('graph');
+ container.innerHTML = "<div id='inner-graph'></div><div id='selection'></div>";
+ graph = container.querySelector('#inner-graph');
xhr = XMLHttpRequest;
styleSheet = document.createElement("style");
styleSheet.type = "text/css";
h_pts = pts;
};
- var graph = document.getElementById("graph");
var g = new Dygraph(graph, data,
{
width: 100,
called = true;
};
- var graph = document.getElementById("graph");
var g = new Dygraph(graph, data, {
drawPointCallback: callback,
});
called = true;
};
- var graph = document.getElementById("graph");
var g = new Dygraph(graph, data, {
drawPoints: true,
drawPointCallback: callback
count++;
};
- var graph = document.getElementById("graph");
var g = new Dygraph(graph, data, {
drawPoints: true,
drawPointCallback: callback
assert.equal(g, this);
var dx = g.toDataXCoord(cx);
xvalues.push(dx);
- Dygraph.Circles.DEFAULT.apply(this, arguments);
+ utils.Circles.DEFAULT.apply(this, arguments);
};
- var graph = document.getElementById("graph");
var testdata = [[10, 2], [11, 3], [12, NaN], [13, 2], [14, NaN], [15, 3]];
var graphOpts = {
labels: ['X', 'Y'],
called = true;
};
- var graph = document.getElementById("graph");
var g = new Dygraph(graph, data,
{
width: 100,
var h_pts;
var h_series;
- var graph = document.getElementById("graph");
var g = new Dygraph(graph, data,
{
width: 600,
h_pts = pts;
};
- var graph = document.getElementById("graph");
var g = new Dygraph(graph, dataNaN,
{
width: 600,
h_pts = pts;
};
- var graph = document.getElementById("graph");
var g = new Dygraph(graph, dataNaN,
{
width: 600,
h_pts = pts;
};
- var graph = document.getElementById("graph");
var g = new Dygraph(graph, dataGap, {
width: 400,
height: 300,
throw "should not reach here";
};
- var graph = document.getElementById("graph");
graph.style.border = "2px solid black";
var g = new Dygraph(graph, "data.csv", { // fake name
width: 400,
highlightRow = row;
};
- var graph = document.getElementById("graph");
var g = new Dygraph(graph,
"X,Y,Z\n" +
"0,1,2\n" + // 0
yMax = g.yAxisRange(0)[1];
};
- var graph = document.getElementById("graph");
var g = new Dygraph(graph, "\n", {
underlayCallback: callback
});
yMax = g.yAxisRange(0)[1];
};
- var graph = document.getElementById("graph");
var g = new Dygraph(graph, "\n", {
valueRange: [0,10],
underlayCallback: callback
var callback = function(g, seriesName, canvasContext, cx, cy, color, pointSizeParam,idx) {
assert.equal(g, this);
indices.push(idx);
- Dygraph.Circles.DEFAULT.apply(this, arguments);
+ utils.Circles.DEFAULT.apply(this, arguments);
};
- var graph = document.getElementById("graph");
var testdata = [[10, 2], [11, 3], [12, NaN], [13, 2], [14, NaN], [15, 3]];
var graphOpts = {
/**
* Test that the correct idx is returned for the point in the onHiglightCallback.
- */
+ */
it('testDrawHighlightPointCallback_idx', function() {
var idxToCheck = null;
idxToCheck = idx;
};
var testdata = [[1, 2], [2, 3], [3, NaN], [4, 2], [5, NaN], [6, 3]];
- var graph = document.getElementById("graph");
- var g = new Dygraph(graph, testdata,
- {
- drawHighlightPointCallback : drawHighlightPointCallback
+ var g = new Dygraph(graph, testdata, {
+ drawHighlightPointCallback: drawHighlightPointCallback,
+ labels: ['X', 'Y']
});
assert.isNull(idxToCheck);
assert.equal(5,idxToCheck);
});
+/**
+ * Test that drawCallback is called with the correct value for `this`.
+ */
+it('should set this in drawCallback', function() {
+ var g = new Dygraph('graph', data, {
+ drawCallback: function(g, is_initial) {
+ assert.isTrue(is_initial);
+ assert.equal(g, this);
+ }
+ });
+});
+
});