Skip to content

Commit

Permalink
Merge pull request #20557 from apache/fix-pictorial
Browse files Browse the repository at this point in the history
fix(pictorial): fix zero value flipping for different axes
  • Loading branch information
plainheart authored Dec 4, 2024
2 parents 592cab6 + 6e9ef3b commit b18ff75
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 33 deletions.
6 changes: 5 additions & 1 deletion src/chart/bar/PictorialBarView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,11 @@ function prepareBarLength(

// if 'pxSign' means sign of pixel, it can't be zero, or symbolScale will be zero
// and when borderWidth be settled, the actual linewidth will be NaN
outputSymbolMeta.pxSign = boundingLength >= 0 ? 1 : -1;
const isXAxis = valueDim.xy === 'x';
const isInverse = valueAxis.inverse;
outputSymbolMeta.pxSign = (isXAxis && !isInverse) || (!isXAxis && isInverse)
? boundingLength >= 0 ? 1 : -1
: boundingLength > 0 ? 1 : -1;
}

function convertToCoordOnAxis(axis: Axis2D, value: number) {
Expand Down
102 changes: 70 additions & 32 deletions test/pictorial-zero-value.html

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

0 comments on commit b18ff75

Please sign in to comment.