* 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.
(
ctx, points, start, segLen, allLen,
dir, smoothMin, smoothMax, smooth, smoothMonotone, connectNulls
)
| 34418 | * y dimension. |
| 34419 | */ |
| 34420 | function drawNonMono( |
| 34421 | ctx, points, start, segLen, allLen, |
| 34422 | dir, smoothMin, smoothMax, smooth, smoothMonotone, connectNulls |
| 34423 | ) { |
| 34424 | var prevIdx = 0; |
| 34425 | var idx = start; |
| 34426 | for (var k = 0; k < segLen; k++) { |
| 34427 | var p = points[idx]; |
| 34428 | if (idx >= allLen || idx < 0) { |
| 34429 | break; |
| 34430 | } |
| 34431 | if (isPointNull(p)) { |
| 34432 | if (connectNulls) { |
| 34433 | idx += dir; |
| 34434 | continue; |
| 34435 | } |
| 34436 | break; |
| 34437 | } |
| 34438 | |
| 34439 | if (idx === start) { |
| 34440 | ctx[dir > 0 ? 'moveTo' : 'lineTo'](p[0], p[1]); |
| 34441 | v2Copy(cp0, p); |
| 34442 | } |
| 34443 | else { |
| 34444 | if (smooth > 0) { |
| 34445 | var nextIdx = idx + dir; |
| 34446 | var nextP = points[nextIdx]; |
| 34447 | if (connectNulls) { |
| 34448 | // Find next point not null |
| 34449 | while (nextP && isPointNull(points[nextIdx])) { |
| 34450 | nextIdx += dir; |
| 34451 | nextP = points[nextIdx]; |
| 34452 | } |
| 34453 | } |
| 34454 | |
| 34455 | var ratioNextSeg = 0.5; |
| 34456 | var prevP = points[prevIdx]; |
| 34457 | var nextP = points[nextIdx]; |
| 34458 | // Last point |
| 34459 | if (!nextP || isPointNull(nextP)) { |
| 34460 | v2Copy(cp1, p); |
| 34461 | } |
| 34462 | else { |
| 34463 | // If next data is null in not connect case |
| 34464 | if (isPointNull(nextP) && !connectNulls) { |
| 34465 | nextP = p; |
| 34466 | } |
| 34467 | |
| 34468 | sub(v, nextP, prevP); |
| 34469 | |
| 34470 | var lenPrevSeg; |
| 34471 | var lenNextSeg; |
| 34472 | if (smoothMonotone === 'x' || smoothMonotone === 'y') { |
| 34473 | var dim = smoothMonotone === 'x' ? 0 : 1; |
| 34474 | lenPrevSeg = Math.abs(p[dim] - prevP[dim]); |
| 34475 | lenNextSeg = Math.abs(p[dim] - nextP[dim]); |
| 34476 | } |
| 34477 | else { |
nothing calls this directly
no test coverage detected