Skip to content

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

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

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.

@liihuu

liihuu commented Sep 15, 2026

Copy link
Copy Markdown
Member

0.00051234 → 0.0{3}51234,this is the default display.

https://klinecharts.com/en-US/api/chart/init#init-decimalFold-format,in this example,0.00051234 → 0.0₃51234 this is a custom display.

@NemeZZiZZ

Copy link
Copy Markdown
Contributor Author

Understood — the custom format option covers this use case, and the brace rendering is an intentional ASCII-safe default. Closing, thanks for clarifying.

@NemeZZiZZ NemeZZiZZ closed this Sep 16, 2026
@NemeZZiZZ
NemeZZiZZ deleted the fix/decimal-fold-subscript branch September 16, 2026 01:11
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