Skip to content

Commit

Permalink
fix: stepped dosn't respect align at the end
Browse files Browse the repository at this point in the history
  • Loading branch information
Leubeling, David committed Jun 8, 2022
1 parent 17ce73d commit ca16a95
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/paths/stepped.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@ export function stepped(opts) {

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

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

let prevYPos = pixelForY(dataY[dir == 1 ? idx0 : idx1]);
let firstXPos = pixelForX(dataX[dir == 1 ? idx0 : idx1]);
let prevYPos = pixelForY(dataY[dir == 1 ? lftIdx : rgtIdx]);
let firstXPos = pixelForX(dataX[dir == 1 ? lftIdx : rgtIdx]);
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) {
for (let i = dir == 1 ? lftIdx : rgtIdx; i >= lftIdx && i <= rgtIdx; i += dir) {
let yVal1 = dataY[i];

if (yVal1 == null)
if (yVal1 == null && i < rgtIdx)
continue;

let x1 = pixelForX(dataX[i]);
Expand Down

0 comments on commit ca16a95

Please sign in to comment.