Skip to content

Commit 2cba6ad

Browse files
committed
Review update
1 parent 6a2ed8a commit 2cba6ad

File tree

4 files changed

+40
-39
lines changed

4 files changed

+40
-39
lines changed

docs/general/performance.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ new Chart(ctx, {
111111

112112
### Enable spanGaps
113113

114-
If you have a lot of data points, it can be more performant to enable spanGaps. This disables segmentation of line, which can be an unneeded step.
114+
If you have a lot of data points, it can be more performant to enable `spanGaps`. This disables segmentation of the line, which can be an unneeded step.
115115

116-
To enable spanGaps:
116+
To enable `spanGaps`:
117117

118118
```javascript
119119
new Chart(ctx, {

src/elements/element.line.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import defaults from '../core/core.defaults';
44
import Element from '../core/core.element';
5-
import {_bezierInterpolation, _pointInLine, _steppedInterpolation} from '../helpers/helpers.math';
5+
import {_bezierInterpolation, _pointInLine, _steppedInterpolation} from '../helpers/helpers.interpolation';
66
import {_computeSegments, _boundSegments} from '../helpers/helpers.segment';
77
import {_steppedLineTo, _bezierCurveTo} from '../helpers/helpers.canvas';
88
import {_updateBezierControlPoints} from '../helpers/helpers.curve';
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
'use strict';
2+
3+
/**
4+
* @private
5+
*/
6+
export function _pointInLine(p1, p2, t) {
7+
return {
8+
x: p1.x + t * (p2.x - p1.x),
9+
y: p1.y + t * (p2.y - p1.y)
10+
};
11+
}
12+
13+
/**
14+
* @private
15+
*/
16+
export function _steppedInterpolation(p1, p2, t, mode) {
17+
return {
18+
x: p1.x + t * (p2.x - p1.x),
19+
y: mode === 'middle' ? t < 0.5 ? p1.y : p2.y
20+
: mode === 'after' ? t < 1 ? p1.y : p2.y
21+
: t > 0 ? p2.y : p1.y
22+
};
23+
}
24+
25+
/**
26+
* @private
27+
*/
28+
export function _bezierInterpolation(p1, p2, t) {
29+
const cp1 = {x: p1.controlPointNextX, y: p1.controlPointNextY};
30+
const cp2 = {x: p2.controlPointPreviousX, y: p2.controlPointPreviousY};
31+
const a = _pointInLine(p1, cp1, t);
32+
const b = _pointInLine(cp1, cp2, t);
33+
const c = _pointInLine(cp2, p2, t);
34+
const d = _pointInLine(a, b, t);
35+
const e = _pointInLine(b, c, t);
36+
return _pointInLine(d, e, t);
37+
}

src/helpers/helpers.math.js

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -132,42 +132,6 @@ export function distanceBetweenPoints(pt1, pt2) {
132132
return Math.sqrt(Math.pow(pt2.x - pt1.x, 2) + Math.pow(pt2.y - pt1.y, 2));
133133
}
134134

135-
/**
136-
* @private
137-
*/
138-
export function _pointInLine(p1, p2, t) {
139-
return {
140-
x: p1.x + t * (p2.x - p1.x),
141-
y: p1.y + t * (p2.y - p1.y)
142-
};
143-
}
144-
145-
/**
146-
* @private
147-
*/
148-
export function _steppedInterpolation(p1, p2, t, mode) {
149-
return {
150-
x: p1.x + t * (p2.x - p1.x),
151-
y: mode === 'middle' ? t < 0.5 ? p1.y : p2.y
152-
: mode === 'after' ? t < 1 ? p1.y : p2.y
153-
: t > 0 ? p2.y : p1.y
154-
};
155-
}
156-
157-
/**
158-
* @private
159-
*/
160-
export function _bezierInterpolation(p1, p2, t) {
161-
const cp1 = {x: p1.controlPointNextX, y: p1.controlPointNextY};
162-
const cp2 = {x: p2.controlPointPreviousX, y: p2.controlPointPreviousY};
163-
const a = _pointInLine(p1, cp1, t);
164-
const b = _pointInLine(cp1, cp2, t);
165-
const c = _pointInLine(cp2, p2, t);
166-
const d = _pointInLine(a, b, t);
167-
const e = _pointInLine(b, c, t);
168-
return _pointInLine(d, e, t);
169-
}
170-
171135
/**
172136
* Shortest distance between angles, in either direction.
173137
* @private

0 commit comments

Comments
 (0)