Skip to content

Commit

Permalink
style: add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Ovilia committed Feb 12, 2018
1 parent 0ce20ab commit 5573031
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/chart/line/poly.js
Expand Up @@ -44,6 +44,17 @@ function drawSegment(
}
}

/**
* Check if points is in monotone.
*
* @param {number[][]} points Array of points which is in [x, y] form
* @param {string} smoothMonotone 'x', 'y', or 'none', stating for which
* dimension that is checking.
* If is 'none', `drawNonMono` should be
* called.
* If is undefined, either being monotone
* in 'x' or 'y' will call `drawMono`.
*/
function isMono(points, smoothMonotone) {
if (points.length <= 1) {
return true;
Expand All @@ -68,6 +79,11 @@ function isMono(points, smoothMonotone) {
return true;
}

/**
* Draw smoothed line in monotone, in which only vertical or horizontal bezier
* control points will be used. This should be used when points are monotone
* either in x or y dimension.
*/
function drawMono(
ctx, points, start, segLen, allLen,
dir, smoothMin, smoothMax, smooth, smoothMonotone, connectNulls
Expand Down Expand Up @@ -122,6 +138,11 @@ function drawMono(
return k;
}

/**
* Draw smoothed line in non-monotone, in may cause undesired curve in extreme
* situations. This should be used when points are non-monotone neither in x or
* y dimension.
*/
function drawNonMono(
ctx, points, start, segLen, allLen,
dir, smoothMin, smoothMax, smooth, smoothMonotone, connectNulls
Expand Down

0 comments on commit 5573031

Please sign in to comment.