Skip to content

Commit 005c4f2

Browse files
committed
refactor(TimeScale): single-resolution stride; drop mix-and-match label promotion
fix(xaxis): skip drawing labels fully outside the grid fix(formatter): magnitude-aware default precision for numeric x-axis chore(DateTime): add date helpers for tick generation
1 parent 8f03815 commit 005c4f2

7 files changed

Lines changed: 1542 additions & 2717 deletions

File tree

src/modules/Formatters.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,15 @@ class Formatters {
114114
if (Utils.isNumber(w.config.xaxis.decimalsInFloat)) {
115115
return val.toFixed(w.config.xaxis.decimalsInFloat)
116116
} else {
117+
// Decimals derived from the tick step's order of magnitude
118+
// (≈ diff/10). Replaces the old "diff < 100 → 1 decimal"
119+
// heuristic which lost precision for small ranges (e.g.
120+
// diff = 0.004 used to print every label as "0.0").
117121
const diff = w.globals.maxX - w.globals.minX
118-
if (diff > 0 && diff < 100) {
119-
return val.toFixed(1)
122+
if (diff > 0) {
123+
const step = diff / 10
124+
const decimals = Math.max(0, -Math.floor(Math.log10(step)))
125+
return val.toFixed(decimals)
120126
}
121127
return val.toFixed(0)
122128
}

0 commit comments

Comments
 (0)