146e4269264f32d4abc8c53714aebc6decb5335c
[dygraphs.git] / smooth_plotter.js
1 /**
2 * @fileoverview Tests for the smooth (bezier curve) plotter.
3 *
4 * @author danvdk@gmail.com (Dan Vanderkam)
5 */
6
7 import Dygraph from '../../src/dygraph';
8 import '../../src/extras/smooth-plotter'; // defines Dygraph.smoothPlotter
9
10 describe("smooth-plotter", function() {
11
12 var smoothPlotter = Dygraph.smoothPlotter;
13 var getControlPoints = smoothPlotter._getControlPoints;
14
15 beforeEach(function() {
16 });
17
18 afterEach(function() {
19 });
20
21 it('testNoSmoothing', function() {
22 var lastPt = {x: 10, y: 0},
23 pt = {x: 11, y: 1},
24 nextPt = {x: 12, y: 0},
25 alpha = 0;
26
27 assert.deepEqual([11, 1, 11, 1], getControlPoints(lastPt, pt, nextPt, alpha));
28 });
29
30 it('testHalfSmoothing', function() {
31 var lastPt = {x: 10, y: 0},
32 pt = {x: 11, y: 1},
33 nextPt = {x: 12, y: 0},
34 alpha = 0.5;
35
36 assert.deepEqual([10.5, 1, 11.5, 1], getControlPoints(lastPt, pt, nextPt, alpha));
37 });
38
39 it('testExtrema', function() {
40 var lastPt = {x: 10, y: 0},
41 pt = {x: 11, y: 1},
42 nextPt = {x: 12, y: 1},
43 alpha = 0.5;
44
45 assert.deepEqual([10.5, 0.75, 11.5, 1.25],
46 getControlPoints(lastPt, pt, nextPt, alpha, true));
47
48 assert.deepEqual([10.5, 1, 11.5, 1],
49 getControlPoints(lastPt, pt, nextPt, alpha, false));
50 });
51
52 });