Skip to content

fix: skip y-axis band when selected overlay has no point values - #845

Merged
liihuu merged 1 commit into
klinecharts:mainfrom
NemeZZiZZ:fix/overlay-yaxis-sentinel-band
Sep 30, 2026
Merged

liihuu merged 1 commit into
klinecharts:mainfrom
NemeZZiZZ:fix/overlay-yaxis-sentinel-band

Conversation

@NemeZZiZZ

Copy link
Copy Markdown
Contributor

Problem

OverlayYAxisView paints the selected overlay's band rect from topY/bottomY, which start as Number.MAX_SAFE_INTEGER / Number.MIN_SAFE_INTEGER and are updated only for points that carry a numeric value:

let topY = Number.MAX_SAFE_INTEGER
let bottomY = Number.MIN_SAFE_INTEGER
coordinates.forEach((coordinate, index) => {
  const point = overlay.points[index]
  if (isNumber(point.value)) { topY = …; bottomY = …; … }
})
if (coordinates.length > 1) {
  figures.unshift({ type: 'rect', attrs: { x: 0, y: topY, height: bottomY - topY, … } })
}

For an overlay whose points carry only timestamp (e.g. verticalSegment, verticalRayLine) created programmatically — createOverlay({ name: 'verticalSegment', points: [{ timestamp: a }, { timestamp: b }] }) — and then selected by click, no point has a value, so the rect is emitted with y ≈ 9e15 and height ≈ -1.8e16: a fill covering the entire y-axis widget.

(UI drawing is not affected — _coordinateToPoint always sets value there; the trigger is programmatic points without value, plus selection, since the band renders only for the clicked overlay.)

Fix

Emit the band only when at least one point actually contributed: topY <= bottomY is true iff the loop updated the sentinels. One condition added.

@liihuu
liihuu merged commit b8fc7c7 into klinecharts:main Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants