Skip to content

Commit

Permalink
improve(stepped): draw step by null-value at begin/end of dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
Leubeling committed May 12, 2022
1 parent 1b8d313 commit 88f3d7a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/paths/stepped.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,24 @@ export function stepped(opts) {

const _dir = 1 * scaleX.dir * (scaleX.ori == 0 ? 1 : -1);

idx0 = nonNullIdx(dataY, idx0, idx1, 1);
idx1 = nonNullIdx(dataY, idx0, idx1, -1);
idx0 = align === -1 ? idx0 : nonNullIdx(dataY, idx0, idx1, 1);
idx1 = align === 1 ? idx1 : nonNullIdx(dataY, idx0, idx1, -1);

let gaps = [];
let inGap = false;
let prevYPos = pxRound(valToPosY(dataY[_dir == 1 ? idx0 : idx1], scaleY, yDim, yOff));
let firstXPos = pxRound(valToPosX(dataX[_dir == 1 ? idx0 : idx1], scaleX, xDim, xOff));
let prevXPos = firstXPos;

lineTo(stroke, firstXPos, yDim + yOff)
lineTo(stroke, firstXPos, prevYPos);

for (let i = _dir == 1 ? idx0 : idx1; i >= idx0 && i <= idx1; i += _dir) {
let yVal1 = dataY[i];

let x1 = pxRound(valToPosX(dataX[i], scaleX, xDim, xOff));

if (yVal1 == null) {
if (yVal1 == null && i < idx1) {
if (yVal1 === null) {
addGap(gaps, prevXPos, x1);
inGap = true;
Expand All @@ -60,6 +61,8 @@ export function stepped(opts) {
prevXPos = x1;
}

lineTo(stroke, prevXPos, yDim + yOff)

let [ bandFillDir, bandClipDir ] = bandFillClipDirs(u, seriesIdx);

if (series.fill != null || bandFillDir != 0) {
Expand Down

0 comments on commit 88f3d7a

Please sign in to comment.