Skip to content

fix: y-axis widget loses height after axis type override + indicator removal#803

Merged
liihuu merged 1 commit into
klinecharts:mainfrom
wenshenglai35-lgtm:fix/yaxis-widget-height-after-recreate
Jul 9, 2026
Merged

fix: y-axis widget loses height after axis type override + indicator removal#803
liihuu merged 1 commit into
klinecharts:mainfrom
wenshenglai35-lgtm:fix/yaxis-widget-height-after-recreate

Conversation

@wenshenglai35-lgtm

Copy link
Copy Markdown
Contributor

Problem

Recreating a y-axis (e.g. overrideYAxis({ name: 'percentage' }) to switch axis
type) destroys the old axis widget and creates a fresh one with zero bounding.
The layout triggered by overrideYAxis only measures width, so the new widget
keeps height: 0 until an unrelated measureHeight layout (such as a container
resize) happens to run. While in that state, value-to-pixel conversion collapses:
candles are squashed into a single line at the pane edge and axis ticks disappear.

Reproduction

  1. createIndicator(ind, { isStack: true, pane: { id: 'candle_pane' }, yAxis: { id: 'my_axis', position: 'left' } })
  2. overrideYAxis({ paneId: 'candle_pane', name: 'percentage' })
  3. overrideYAxis({ paneId: 'candle_pane', name: 'normal' })
  4. removeIndicator({ paneId: 'candle_pane', name: ... })

→ candle pane collapses (getSize('candle_pane', 'yAxis').height === 0).

Verified on 10.0.0-beta3 and current main.

Fix

When DrawPane.createYAxis creates a new axis widget, inherit the pane's current
height/top so the widget stays consistent with pane geometry. Width is still
handled by the subsequent measure-width layout, unchanged.

After the fix the same sequence keeps the axis widget at the pane height and the
chart renders correctly (also verified with percentage → logarithm → normal
switches before removal). pnpm type-check passes.

Recreating an axis (e.g. `overrideYAxis({ name })` switching axis type)
destroys the old widget and creates a new one with zero bounding. The
follow-up layout triggered by `overrideYAxis` only measures width, so the
new widget keeps height 0 until an unrelated `measureHeight` layout (such
as a resize) happens. In the meantime value-to-pixel conversion collapses:
bars are squashed into a single line and axis ticks disappear.

Reproduction: create an indicator bound to a custom y-axis on candle_pane,
call `overrideYAxis({ paneId: candle_pane, name: percentage })`, switch
back to normal, then remove the indicator.

Fix: when a new y-axis widget is created, inherit the pane current
height/top so it stays consistent with the pane geometry; width is still
handled by the subsequent measure-width layout.
@liihuu liihuu merged commit 30b43f6 into klinecharts:main Jul 9, 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