it('testXAxisTimeLabelFormatter', function() {
var opts = {
width: 480,
- height: 320
+ height: 320,
+ labels: ['X', 'Y1']
};
var data = [[5.0,0],[5.1,1],[5.2,2],[5.3,3],[5.4,4],[5.5,5],[5.6,6],[5.7,7],[5.8,8],[5.9,9]];
var graph = document.getElementById("graph");
* Verify that log scale axis range is properly specified.
*/
it('testLogScale', function() {
- var g = new Dygraph("graph", [[0, 5], [1, 1000]], { logscale : true });
+ var g = new Dygraph("graph",
+ [[0, 5], [1, 1000]], {
+ logscale: true,
+ labels: ['X', 'Y']
+ });
var nonEmptyLabels = Util.getYLabels().filter(function(x) { return x.length > 0; });
assert.deepEqual(["5","10","20","50","100","200","500","1000"], nonEmptyLabels);
* Verify that include zero range is properly specified.
*/
it('testIncludeZero', function() {
- var g = new Dygraph("graph", [[0, 500], [1, 1000]], { includeZero : true });
+ var g = new Dygraph("graph",
+ [[0, 500], [1, 1000]], {
+ includeZero: true,
+ labels: ['X', 'Y1']
+ });
assert.deepEqual(['0','200','400','600','800','1000'], Util.getYLabels());
g.updateOptions({ includeZero : false });
var assertFontSize = function(selector, expected) {
Util.assertStyleOfChildren(selector, "font-size", expected);
}
-
+
assertFontSize(document.querySelectorAll(".dygraph-axis-label-x"), "14px");
- assertFontSize(document.querySelectorAll(".dygraph-axis-label-y") , "14px");
+ assertFontSize(document.querySelectorAll(".dygraph-axis-label-y"), "14px");
- g.updateOptions({ axisLabelFontSize : 8});
+ g.updateOptions({axisLabelFontSize : 8});
assertFontSize(document.querySelectorAll(".dygraph-axis-label-x"), "8px");
assertFontSize(document.querySelectorAll(".dygraph-axis-label-y"), "8px");
g.updateOptions({
axisLabelFontSize : null,
- axes : {
- x : { axisLabelFontSize : 5 },
+ axes: {
+ x: { axisLabelFontSize : 5 },
}
});
assertFontSize(document.querySelectorAll(".dygraph-axis-label-y"), "14px");
g.updateOptions({
- axes : {
- y : { axisLabelFontSize : 20 },
+ axes: {
+ y: { axisLabelFontSize : 20 },
}
});
assertFontSize(document.querySelectorAll(".dygraph-axis-label-y"), "20px");
g.updateOptions({
- series : {
- Y2 : { axis : "y2" } // copy y2 series to y2 axis.
+ series: {
+ Y2: { axis : "y2" } // copy y2 series to y2 axis.
},
- axes : {
- y2 : { axisLabelFontSize : 12 },
+ axes: {
+ y2: { axisLabelFontSize : 12 },
}
});
};
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);
width: 500, height: 350,
customBars: true,
errorBars: true,
- axes : {
- x : {
+ axes: {
+ x: {
drawGrid: false,
drawAxis: false,
},
- y : {
+ y: {
drawGrid: false,
drawAxis: false,
}
},
valueRange: [0, 120],
fillAlpha: 0.15,
- colors: [ '#00FF00' ]
+ colors: ['#00FF00'],
+ labels: ['X', 'Y']
});
var sampler = new PixelSampler(g);
},
fillAlpha: 1.0,
logscale: true,
- colors: [ '#00FF00' ]
+ colors: ['#00FF00'],
+ labels: ['X', 'Y']
});
// The following assertions describe the sides of the custom bars, which are
],
{
drawPoints: true,
- drawPointCallback : drawPointCallback,
- customBars: true
+ drawPointCallback: drawPointCallback,
+ customBars: true,
+ labels: ['X', 'Y']
});
// Normally all three points would be drawn.
}
},
customBars: true,
- errorBars: true
+ errorBars: true,
+ labels: ['X', 'Y']
};
var data = [
[1, [10, 10, 100]],
[1,0],
[2,1],
[3,0]];
+var BASE_OPTS = {labels: ['X', 'Y']};
it('testCsv', function() {
var data = dataString;
it('testArray', function() {
var data = dataArray;
var graph = document.getElementById("graph");
- var g = new Dygraph(graph, data, {});
+ var g = new Dygraph(graph, data, BASE_OPTS);
assertData(g);
});
var data = function() { return array; }
var graph = document.getElementById("graph");
- var g = new Dygraph(graph, data, {});
+ var g = new Dygraph(graph, data, BASE_OPTS);
assertData(g);
});
"23,0\n";
var data2 =
- [[1, 10],
- [2, 20],
- [3, 30],
- [4, 40],
- [5, 120],
- [6, 50],
- [7, 70],
- [8, 90],
- [9, 50]];
+ "X,Y\n" +
+ "1,10\n" +
+ "2,20\n" +
+ "3,30\n" +
+ "4,40\n" +
+ "5,120\n" +
+ "6,50\n" +
+ "7,70\n" +
+ "8,90\n" +
+ "9,50\n";
function getXLabels() {
var x_labels = document.getElementsByClassName("dygraph-axis-label-x");
* A sanity test to ensure pointClickCallback is called.
*/
it('testPointClickCallback', function() {
- var clicked;
- var g = new Dygraph(document.getElementById("graph"), data2, {
- pointClickCallback : function(event, point) {
+ var clicked = null;
+ var g = new Dygraph('graph', data2, {
+ pointClickCallback: function(event, point) {
clicked = point;
}
});
clickAt(g, 4, 40);
+ assert.isNotNull(clicked);
assert.equal(4, clicked.xval);
assert.equal(40, clicked.yval);
});
[2, null],
[3, 13],
[4, 14]],
- { colors: ['blue']});
+ { colors: ['blue'], labels: ['X', 'Y']});
var htx = g.hidden_ctx_;
assert.equal(2, CanvasAssertions.numLinesDrawn(htx, '#0000ff'));
[2, null],
[3, 13],
[4, 14]],
- { colors: ['blue'], connectSeparatedPoints: true});
+ {
+ colors: ['blue'],
+ connectSeparatedPoints: true,
+ labels: ['X', 'Y']
+ });
var htx = g.hidden_ctx_;
var num_lines = 0;
{
connectSeparatedPoints: true,
drawPoints: true,
- colors: ['red', 'blue']
+ colors: ['red', 'blue'],
+ labels: ['X', 'Y1', 'Y2']
}
);
data,
{
errorBars: true,
- colors: ['red']
+ colors: ['red'],
+ labels: ['X', 'Y']
}
);
connectSeparatedPoints: true,
drawPoints: true,
errorBars: true,
- colors: ['red']
+ colors: ['red'],
+ labels: ['X', 'Y']
}
);
data,
{
customBars: true,
- colors: ['red']
+ colors: ['red'],
+ labels: ['X', 'Y']
}
);
connectSeparatedPoints: true,
drawPoints: true,
customBars: true,
- colors: ['red']
+ colors: ['red'],
+ labels: ['X', 'Y']
}
);
{
connectSeparatedPoints: true,
drawPoints: true,
- colors: ['red','blue']
+ colors: ['red','blue'],
+ labels: ['X', 'Y1', 'Y2']
}
);
g.updateOptions({ dateWindow : [ 2.5, 4.5 ] });
if (data === undefined) data = ZERO_TO_FIFTY_STEPS;
if (expectRangeX === undefined) expectRangeX = [10, 20];
if (expectRangeY === undefined) expectRangeY = [0, 55];
- var graph = document.getElementById("graph");
- var g = new Dygraph(graph, data, opts);
+ if (!opts) opts = {};
+ opts['labels'] = ['X', 'Y'];
+ var g = new Dygraph('graph', data, opts);
assertDeepCloseTo(expectRangeX, g.xAxisRange(), 0.01);
assertDeepCloseTo(expectRangeY, g.yAxisRange(0), 0.01);
* Verify that log scale axis range is properly specified.
*/
it('testLogScaleExcludesZero', function() {
- var g = new Dygraph("graph", FIVE_TO_ONE_THOUSAND, { logscale : true });
+ var g = new Dygraph("graph", FIVE_TO_ONE_THOUSAND, {
+ logscale: true,
+ labels: ['X', 'Y']
+ });
assert.deepEqual([10, 1099], g.yAxisRange(0));
g.updateOptions({ logscale : false });
* Verify that includeZero range is properly specified.
*/
it('testIncludeZeroIncludesZero', function() {
- var g = new Dygraph("graph", [[0, 500], [500, 1000]], { includeZero : true });
+ var g = new Dygraph("graph", [[0, 500], [500, 1000]], {
+ includeZero: true,
+ labels: ['X', 'Y']
+ });
assert.deepEqual([0, 1100], g.yAxisRange(0));
g.updateOptions({ includeZero : false });
* Verify that very large Y ranges don't break things.
*/
it('testHugeRange', function() {
- var g = new Dygraph("graph", [[0, -1e120], [1, 1e230]], { includeZero : true });
+ var g = new Dygraph("graph", [[0, -1e120], [1, 1e230]], {
+ includeZero: true,
+ labels: ['X', 'Y']
+ });
assert.closeTo(1, -1e229 / g.yAxisRange(0)[0], 0.001);
assert.closeTo(1, 1.1e230 / g.yAxisRange(0)[1], 0.001);
});
*
* @author konigsberg@google.com (Robert Konigsberg)
*/
-var DEAD_SIMPLE_DATA = [[ 10, 2100 ]];
-var ZERO_TO_FIFTY = [[ 10, 0 ] , [ 20, 50 ]];
+var DEAD_SIMPLE_DATA = 'X,Y\n10,2100';
+var ZERO_TO_FIFTY = 'X,Y\n10,0\n20,50';
describe("dygraphs-sanity", function() {