Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/chart/line/LineView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,8 @@ class LineView extends ChartView {
polyline.setShape({
smooth,
smoothMonotone,
connectNulls
connectNulls,
step: !!step
});

if (polygon) {
Expand All @@ -894,7 +895,8 @@ class LineView extends ChartView {
smooth,
stackedOnSmooth,
smoothMonotone,
connectNulls
connectNulls,
step: !!step
});

setStatesStylesFromModel(polygon, seriesModel, 'areaStyle');
Expand Down
23 changes: 18 additions & 5 deletions src/chart/line/poly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ function drawSegment(
dir: number,
smooth: number,
smoothMonotone: 'x' | 'y' | 'none',
connectNulls: boolean
connectNulls: boolean,
step?: boolean
) {
let prevX: number;
let prevY: number;
Expand Down Expand Up @@ -81,7 +82,14 @@ function drawSegment(
let dy = y - prevY;

// Ignore tiny segment.
if ((dx * dx + dy * dy) < 0.5) {
// In step mode, keep every corner; only drop strict duplicates. See #21614.
if (step) {
if (dx === 0 && dy === 0) {
idx += dir;
continue;
}
}
else if ((dx * dx + dy * dy) < 0.5) {
idx += dir;
continue;
}
Expand Down Expand Up @@ -218,6 +226,8 @@ class ECPolylineShape {
smoothConstraint = true;
smoothMonotone: 'x' | 'y' | 'none';
connectNulls: boolean;
// True when `points` are step-expanded; keep every corner. See #21614.
step: boolean;
}

interface ECPolylineProps extends PathProps {
Expand Down Expand Up @@ -271,7 +281,8 @@ export class ECPolyline extends Path<ECPolylineProps> {
ctx, points, i, len, len,
1,
shape.smooth,
shape.smoothMonotone, shape.connectNulls
shape.smoothMonotone, shape.connectNulls,
shape.step
) + 1;
}
}
Expand Down Expand Up @@ -395,13 +406,15 @@ export class ECPolygon extends Path {
ctx, points, i, len, len,
1,
shape.smooth,
smoothMonotone, shape.connectNulls
smoothMonotone, shape.connectNulls,
shape.step
);
drawSegment(
ctx, stackedOnPoints, i + k - 1, k, len,
-1,
shape.stackedOnSmooth,
smoothMonotone, shape.connectNulls
smoothMonotone, shape.connectNulls,
shape.step
);
i += k + 1;

Expand Down
103 changes: 103 additions & 0 deletions test/ut/spec/series/line-step-poly.test.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.