Skip to content

fix: render subscript zero count in default decimalFold format - #844

Open
NemeZZiZZ wants to merge 1 commit into
klinecharts:mainfrom
NemeZZiZZ:fix/decimal-fold-subscript
Open

fix: render subscript zero count in default decimalFold format#844
NemeZZiZZ wants to merge 1 commit into
klinecharts:mainfrom
NemeZZiZZ:fix/decimal-fold-subscript

Conversation

@NemeZZiZZ

Copy link
Copy Markdown
Contributor

Problem

The default formatFoldDecimal emits the literal text 0{3} instead of a subscript count:

result[lastIndex] = v.replace(/0*/, `0{${count}}`)   // → "0.0{3}51234"

Verified by execution: formatFoldDecimal('0.00051234', 3)'0.0{3}51234' — braces printed verbatim on axis labels and tooltips for any high-precision symbol (tokens with pricePrecision 8–10).

The documented sample for this exact feature (docs/@views/api/samples/init-decimalFold-format/index.js) maps the count to Unicode subscript digits — i.e. 0.0₃51234 — so the default implementation contradicts the documented behavior of the option it backs.

Fix

Port the subscript mapping from the docs sample into formatFoldDecimal (module-level subscriptNumbers map, zero-count → subscript).

One deliberate deviation from the sample: the count is subscripted with /\d/g (all digits), not /\d/ (first only) — the sample renders a two-digit count (10+ leading zeros) as 0.0₁2…. With /g it is 0.0₁₂….

Verified outputs: '0.00051234' → '0.0₃51234', '0.000051234' → '0.0₄51234', '1.23456' / '0.0051234' / '0.0000' pass through unchanged.

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.

1 participant