apache / apache/echarts

[Bug] axisLabel precision causes floating-point error in number formatting (toFixed)

Open
#21,036 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
67.3k
Forks
19.8k
Avg merge
15h 17m
Merged PRs (30d)
5

Description

### Version

5.6.0

### Link to Minimal Reproduction

https://echarts.apache.org/examples/en/editor.html?c=bar-simple&lang=ts&code=PYBwLglsB2AEC8sDeAoWsDmAnCATAXMmurADYCmAZmIQMwAM9ANMQL4voAeAgpxAM6FUJWGACeIcoQDkAYwCGYchmBYx0jiVyL5hANrSAsjA2xpAFQCu5U9IDq5XLfMALS7YBiOaQF02msV4BIWJ0cUkZADd5UmsNUNgIaCUsaNJCegA6egA2AHZ6AFY8gCYATgBGHOqavM10AFt5TkJYLIraABYKis7CgA5aIeGu-tgGpMIAWiyS-h68iv68wsY1-bH-EFIIMAA5SwaAI3IsQkL_Yn5TiHJBWD0E4RFYbTBdB4SRLNyizpz-n0xt9smUSv0mLAviQfowynkcoUcpDoegfiVaP0yiiXjDsrkMf1UbAfMDRBIpGYjvIsNIEqxiH5WABuIA

### Steps to Reproduce

see Link to Minimal Reproduction

### Current Behavior

the axis label formatting via (+x).toFixed(precision) in [src/util/number.ts](https://github.com/apache/echarts/blob/master/src/util/number.ts) (line 146) produces floating-point errors.

![Image](https://github.com/user-attachments/assets/749c7ddb-bd79-4130-b400-23f90e4aded2)

### Expected Behavior

axis label value should be increased by interval

Image

### Environment

```markdown
- OS:
- Browser:
- Framework:
```

### Any additional comments?

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with src/util/number.ts at the referenced line and run the linked minimal reproduction in the ECharts editor. Trace how axisLabel precision reaches toFixed, then verify the reproduction shows labels increasing by the interval without floating-point artifacts.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.