Repository navigation
Commit 5253b86
authored
fix: stop abbreviating 500-999 as 0.5k/0.8k on chart axes (#3434)
## Summary
With "Large number format" off, the time chart's Y-axis mixed abbreviated and plain labels (`0, 250, 0.5k, 0.8k, 1k`). Some labels were also wrong: 750 rendered as `0.8k`.
The axis always formats ticks in compact form (deliberate since #171 and #3030, to fit the gutter). numbro's `lowPrecision` option, on by default, adds the `k` suffix to any value that *rounds* to 1000, which is everything ≥ 500. This PR changes `formatNumber` so that, whenever `average` is applied, abbreviation starts at 1000.
| value | before (Decimals 1) | after |
|---|---|---|
| 400 | `400` | `400` |
| 500 | `0.5k` | `500` |
| 750 | `0.8k` | `750` |
| 1000 | `1k` | `1k` |
Because the fix is in `formatNumber`, it also covers heatmap axis labels, plus tooltips, number tiles, and tables when "Large number format" is on (750 used to show as `0.8k` or `1k` there). The CLI's mirrored `formatNumber` gets the same change. Byte output is excluded: it forces `average: false`, and numbro rejects `lowPrecision` without `average`.
Turning `lowPrecision` off on its own makes numbro pick the unit before rounding (999,700 → `1000k`). So the unit is now chosen from the value rounded at the configured decimals and passed to numbro as `forceAverage`: 999,700 → `1m`, 999.6 → `1k`.
### Screenshots or video
Screenshots to be added by the author.
| Before | After |
| :----- | :---- |
| <img width="1457" height="766" alt="Screenshot 2026-10-21 at 2 47 49 PM" src="https://github.com/user-attachments/assets/7f95b81c-e15d-4c6b-aadb-cede5a61948f" /> | <img width="1465" height="808" alt="Screenshot 2026-10-21 at 2 47 33 PM" src="https://github.com/user-attachments/assets/018ee738-3d38-456b-aca9-31c88d5023cb" /> |
### How to reproduce
**Starting point:** `yarn app:dev:local` connected to the demo server, or the Vercel preview.
**On `main`:**
1. Open **Chart Explorer**, pick the demo **Logs** source, and choose **Time Series**.
2. Set the aggregation to **Average** and the value to `500 + rand() % 400`.
3. Open display settings and set Output format **Number**, Decimals **1**, with **Large number format** off. Click **Apply**.
4. The Y-axis shows ticks like `0, 250, 0.5k, 0.8k`.
**On this branch:**
1. Repeat the steps above. The Y-axis shows `0, 250, 500, 750`, and `k` appears only from 1000.
### How to test on Vercel preview
**Preview routes:** /chart
**Steps:**
1. Select the "Logs" source and the "Time Series" chart type.
2. Set the aggregation to "Average" and the value expression to `500 + rand() % 400`, then run the query.
3. Open display settings, set Output format to "Number" and Decimals to 1, leave "Large number format" unchecked, and click "Apply".
4. Verify that no Y-axis tick label below 1000 ends in "k" (for example, "500" and "750", not "0.5k" and "0.8k").
### References
- Linear Issue: HDX-5781
- Related PRs: #3030, #3162, #31721 parent bc47e48 commit 5253b86
6 files changed
Lines changed: 137 additions & 8 deletions
File tree
- .changeset
- packages
- app/src
- __tests__
- cli/src
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
89 | 99 | | |
90 | 100 | | |
91 | 101 | | |
| |||
320 | 330 | | |
321 | 331 | | |
322 | 332 | | |
323 | | - | |
| 333 | + | |
324 | 334 | | |
325 | 335 | | |
326 | 336 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
508 | 508 | | |
509 | 509 | | |
510 | 510 | | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
511 | 541 | | |
512 | 542 | | |
513 | 543 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1001 | 1001 | | |
1002 | 1002 | | |
1003 | 1003 | | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
1004 | 1030 | | |
1005 | 1031 | | |
1006 | 1032 | | |
| |||
1057 | 1083 | | |
1058 | 1084 | | |
1059 | 1085 | | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
1060 | 1089 | | |
1061 | 1090 | | |
1062 | 1091 | | |
1063 | 1092 | | |
1064 | 1093 | | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
1065 | 1100 | | |
1066 | 1101 | | |
1067 | 1102 | | |
| |||
1072 | 1107 | | |
1073 | 1108 | | |
1074 | 1109 | | |
1075 | | - | |
1076 | | - | |
1077 | | - | |
1078 | 1110 | | |
1079 | 1111 | | |
1080 | 1112 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
6 | 15 | | |
7 | 16 | | |
8 | 17 | | |
| |||
18 | 27 | | |
19 | 28 | | |
20 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
21 | 40 | | |
22 | 41 | | |
23 | 42 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
168 | 194 | | |
169 | 195 | | |
170 | 196 | | |
| |||
221 | 247 | | |
222 | 248 | | |
223 | 249 | | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
224 | 253 | | |
225 | 254 | | |
226 | 255 | | |
227 | 256 | | |
228 | 257 | | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
229 | 264 | | |
230 | 265 | | |
231 | 266 | | |
| |||
236 | 271 | | |
237 | 272 | | |
238 | 273 | | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | 274 | | |
243 | 275 | | |
244 | 276 | | |
| |||
0 commit comments