expect(chart.data.datasets[0].metaData.length).toBe(3);
});
- it ('should draw all elements', function() {
+ it('should draw all elements', function() {
var chart = {
data: {
datasets: [{
expect(chart.data.datasets[0].metaData[3].draw.calls.count()).toBe(1);
});
- it ('should update elements', function() {
+ it('should update elements', function() {
var data = {
datasets: [{
data: [10, 15, 0, -4],
borderJoinStyle: 'bevel',
borderWidth: 1.2,
fill: true,
- skipNull: true,
tension: 0.1,
},
point: {
borderJoinStyle: 'bevel',
borderWidth: 1.2,
fill: true,
- drawNull: undefined,
- skipNull: true,
tension: 0.1,
scaleTop: 0,
radius: 3,
skip: false,
tension: 0.1,
-
+
// Point
x: 71,
y: 62,
radius: 3,
skip: false,
tension: 0.1,
-
+
// Point
x: 121,
y: 15,
radius: 3,
skip: false,
tension: 0.1,
-
+
// Point
x: 172,
y: 156,
radius: 3,
skip: false,
tension: 0.1,
-
+
// Point
x: 222,
y: 194,
chart.data.datasets[0].borderDashOffset = 7;
chart.data.datasets[0].borderJoinStyle = 'miter';
chart.data.datasets[0].fill = false;
- chart.data.datasets[0].skipNull = false;
- chart.data.datasets[0].drawNull = true;
// point styles
chart.data.datasets[0].radius = 22;
borderJoinStyle: 'miter',
borderWidth: 0.55,
fill: false,
- drawNull: true,
- skipNull: false,
tension: 0.2,
scaleTop: 0,
radius: 22,
skip: false,
tension: 0.2,
-
+
// Point
x: 71,
y: 62,
radius: 22,
skip: false,
tension: 0.2,
-
+
// Point
x: 121,
y: 15,
radius: 22,
skip: false,
tension: 0.2,
-
+
// Point
x: 172,
y: 156,
radius: 22,
skip: false,
tension: 0.2,
-
+
// Point
x: 222,
y: 194,
borderDashOffset: 4.4,
borderJoinStyle: 'round',
fill: true,
- skipNull: true,
- drawNull: false,
};
// point styles
borderJoinStyle: 'round',
borderWidth: 0.3,
fill: true,
- drawNull: true,
- skipNull: false,
tension: 0.25,
scaleTop: 0,
radius: 2.2,
skip: true,
tension: 0.15,
-
+
// Point
x: 71,
y: 62,
});
});
- it ('should handle number of data point changes in update', function() {
+ it('should handle number of data point changes in update', function() {
var data = {
datasets: [{
data: [10, 15, 0, -4],
borderJoinStyle: 'bevel',
borderWidth: 1.2,
fill: true,
- skipNull: true,
tension: 0.1,
},
point: {
expect(chart.data.datasets[0].metaData[4] instanceof Chart.elements.Point).toBe(true);
});
- it ('should set point hover styles', function() {
+ it('should set point hover styles', function() {
var data = {
datasets: [{
data: [10, 15, 0, -4],
expect(point._model.radius).toBe(4.4);
});
- it ('should remove hover styles', function() {
+ it('should remove hover styles', function() {
var data = {
datasets: [{
data: [10, 15, 0, -4],
borderJoinStyle: 'bevel',
borderWidth: 1.2,
fill: true,
- skipNull: true,
tension: 0.1,
},
point: {
expect(point._model.borderWidth).toBe(5.5);
expect(point._model.radius).toBe(4.4);
});
-});
\ No newline at end of file
+});
// Tests for the line element
describe('Line element tests', function() {
- it ('should be constructed', function() {
+ it('should be constructed', function() {
var line = new Chart.elements.Line({
_datasetindex: 2,
_points: [1, 2, 3, 4]
expect(line._points).toEqual([1, 2, 3, 4]);
});
- it ('should draw with default settings', function() {
+ it('should draw with default settings', function() {
var mockContext = window.createMockContext();
// Create our points
_index: 0,
_view: {
x: 0,
- y: 10
+ y: 10,
}
}));
points.push(new Chart.elements.Point({
_index: 1,
_view: {
x: 5,
- y: 0
+ y: 0,
}
}));
points.push(new Chart.elements.Point({
_index: 2,
_view: {
x: 15,
- y: -10
+ y: -10,
}
}));
points.push(new Chart.elements.Point({
_index: 3,
_view: {
x: 19,
- y: -5
+ y: -5,
}
}));
_view: {
fill: false, // don't want to fill
tension: 0.0, // no bezier curve for now
+ scaleZero: 0
}
- })
+ });
line.draw();
args: [],
}, {
name: 'moveTo',
+ args: [0, 0]
+ }, {
+ name: 'lineTo',
args: [0, 10]
}, {
name: 'lineTo',
args: ['butt']
}, {
name: 'setLineDash',
- args: [[]]
+ args: [
+ []
+ ]
}, {
name: 'setLineDashOffset',
args: [0.0]
args: []
}, {
name: 'moveTo',
+ args: [0, 0]
+ }, {
+ name: 'lineTo',
args: [0, 10]
}, {
name: 'lineTo',
}, {
name: 'restore',
args: []
- }])
+ }]);
});
- it ('should draw with custom settings', function() {
+ it('should draw with custom settings', function() {
var mockContext = window.createMockContext();
// Create our points
_children: points,
// Need to provide some settings
_view: {
- fill: true,
+ fill: true,
scaleZero: 2, // for filling lines
tension: 0.0, // no bezier curve for now
borderWidth: 4,
backgroundColor: 'rgb(0, 0, 0)'
}
- })
+ });
line.draw();
args: [],
}, {
name: 'moveTo',
+ args: [0, 2]
+ }, {
+ name: 'lineTo',
args: [0, 10]
}, {
name: 'lineTo',
args: ['round']
}, {
name: 'setLineDash',
- args: [[2, 2]]
+ args: [
+ [2, 2]
+ ]
}, {
name: 'setLineDashOffset',
args: [1.5]
args: []
}, {
name: 'moveTo',
+ args: [0, 2]
+ }, {
+ name: 'lineTo',
args: [0, 10]
}, {
name: 'lineTo',
name: 'restore',
args: []
}];
- expect(mockContext.getCalls()).toEqual(expected)
+ expect(mockContext.getCalls()).toEqual(expected);
});
- it ('should be able to draw with a loop back to the beginning point', function() {
+ it('should be able to draw with a loop back to the beginning point', function() {
var mockContext = window.createMockContext();
// Create our points
_view: {
fill: false, // don't want to fill
tension: 0.0, // no bezier curve for now
+ scaleZero: 0,
}
- })
+ });
line.draw();
args: [],
}, {
name: 'moveTo',
+ args: [0, 0]
+ }, {
+ name: 'lineTo',
args: [0, 10]
}, {
name: 'lineTo',
args: ['butt']
}, {
name: 'setLineDash',
- args: [[]]
+ args: [
+ []
+ ]
}, {
name: 'setLineDashOffset',
args: [0.0]
args: []
}, {
name: 'moveTo',
+ args: [0, 0]
+ }, {
+ name: 'lineTo',
args: [0, 10]
}, {
name: 'lineTo',
}, {
name: 'restore',
args: []
- }])
+ }]);
});
- it ('should draw with bezier curves if tension > 0', function() {
+ it('should draw with bezier curves if tension > 0', function() {
var mockContext = window.createMockContext();
// Create our points
_children: points,
// Need to provide some settings
_view: {
- fill: true,
+ fill: true,
scaleZero: 2, // for filling lines
tension: 0.5, // have bezier curves
borderWidth: 4,
backgroundColor: 'rgb(0, 0, 0)'
}
- })
+ });
line.draw();
args: [],
}, {
name: 'moveTo',
+ args: [0, 2]
+ }, {
+ name: 'lineTo',
args: [0, 10]
}, {
name: 'bezierCurveTo',
args: ['round']
}, {
name: 'setLineDash',
- args: [[2, 2]]
+ args: [
+ [2, 2]
+ ]
}, {
name: 'setLineDashOffset',
args: [1.5]
args: []
}, {
name: 'moveTo',
+ args: [0, 2]
+ }, {
+ name: 'lineTo',
args: [0, 10]
}, {
name: 'bezierCurveTo',
name: 'restore',
args: []
}];
- expect(mockContext.getCalls()).toEqual(expected)
+ expect(mockContext.getCalls()).toEqual(expected);
});
-});
\ No newline at end of file
+});