Commit ca1b312
[Lens] Always show number sign when comparing to Primary metric (elastic#222824)
## Summary
Fixes elastic#221882
This is a possible take of the enhancement request in elastic#221882.
In this scenario the chart automatically enters the `alwaysShowSign`
mode when rendering the delta difference with the Primary Metric in the
Secondary badge.
Some notes:
* The user has no control over it.
* The behaviour is disabled automatically when moving into `Static
value` mode, while it can be replicated using the `custom format` in the
`Value format` control
* The affected formats are `number`, `bytes`, `bits`, `percentage` in
any possible configuration (i.e. also compact mode)
* I've noticed that some formats change a bit when the sign is displayed
(ie Currency goes from `$ xx.xxx` to `+ xx.xx $`)
**Compare to Primary Metric**
| Default | Number | Number (compact) | Custom Format (i.e. Currency) |
Percentage | Bytes | Bits |
| ---- | ---- | ---- | ---- | ---- | ---- | ---- |
| <img width="819" alt="Screenshot 2025-06-05 at 14 41 09"
src="https://github.com/user-attachments/assets/3e836e07-a5eb-479a-96af-463069cabc35"
/> | <img width="473" alt="Screenshot 2025-06-05 at 15 40 37"
src="https://github.com/user-attachments/assets/097548c5-4c68-4041-89a7-a46af228fd7a"
/> | <img width="472" alt="Screenshot 2025-06-05 at 15 41 29"
src="https://github.com/user-attachments/assets/52943f01-c302-4631-8c2c-55fc60d91d99"
/> | <img width="480" alt="Screenshot 2025-06-05 at 15 42 33"
src="https://github.com/user-attachments/assets/b2dbbaec-4c11-4e3f-80ac-20f810511bf7"
/> | <img width="472" alt="Screenshot 2025-06-05 at 14 48 18"
src="https://github.com/user-attachments/assets/13a1b102-30dd-46b4-b8f4-52ade1e9eadb"
/> | <img width="478" alt="Screenshot 2025-06-05 at 15 44 11"
src="https://github.com/user-attachments/assets/e9acbb69-6535-4ee2-962a-f1e5446b93dd"
/> | <img width="477" alt="Screenshot 2025-06-05 at 14 47 54"
src="https://github.com/user-attachments/assets/c6bb99af-5f08-4d0d-b302-e8fbe42a764b"
/> |
When using Static value:
| Default | Number | Number (compact) | Custom format (i.e. Currency) |
Percentage | Bytes | Bits |
| ---- | --- | ---- | ---- | ---- | ---- | ---- |
| <img width="471" alt="Screenshot 2025-06-05 at 14 56 17"
src="https://github.com/user-attachments/assets/6135823f-b644-48aa-b236-076bcc0692ff"
/> | <img width="473" alt="Screenshot 2025-06-05 at 15 49 51"
src="https://github.com/user-attachments/assets/afe492ad-c908-45ee-b831-2108553c15ce"
/> | <img width="477" alt="Screenshot 2025-06-05 at 15 46 24"
src="https://github.com/user-attachments/assets/29eaccf5-0be8-46a6-9e87-3b6f99912e26"
/> | <img width="472" alt="Screenshot 2025-06-05 at 15 52 27"
src="https://github.com/user-attachments/assets/3867b435-a1e2-4cb3-9b4d-687a33f4ff78"
/> | <img width="482" alt="Screenshot 2025-06-05 at 15 46 40"
src="https://github.com/user-attachments/assets/0e1521b3-6ed3-45e4-a913-44e4f99f027a"
/> | <img width="480" alt="Screenshot 2025-06-05 at 15 45 50"
src="https://github.com/user-attachments/assets/0343fd8c-6d22-46bb-9676-f27cad4ca9ee"
/> | <img width="473" alt="Screenshot 2025-06-05 at 15 46 05"
src="https://github.com/user-attachments/assets/072e948d-71ce-48f0-862a-6932c5c510fa"
/> |
Extra bits:
* I did notice that when rendering in Icon mode only and the secondary
raw value is `null` an empty badge was rendered. Now it should not.
* When running Jest tests a warning about a missing `act` wrapping was
shown, which was due to the `jest.advanceTimers` call. Now it is
properly wrapped
* When testing with a time shift it is very likely to encounter into
elastic#221886 and have all badges set
to `NA`. In such case close the inline editor and hit `Refresh` again to
see fresh values.
### Checklist
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios1 parent 1c98aff commit ca1b312
File tree
7 files changed
+93
-23
lines changed7 files changed
+93
-23
lines changedLines changed: 23 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
20 | 29 | | |
21 | 30 | | |
22 | 31 | | |
| |||
31 | 40 | | |
32 | 41 | | |
33 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
34 | 53 | | |
35 | 54 | | |
36 | 55 | | |
37 | 56 | | |
38 | 57 | | |
39 | | - | |
| 58 | + | |
| 59 | + | |
40 | 60 | | |
41 | 61 | | |
42 | 62 | | |
43 | 63 | | |
44 | | - | |
| 64 | + | |
45 | 65 | | |
46 | 66 | | |
47 | 67 | | |
| |||
Lines changed: 7 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
238 | 238 | | |
239 | 239 | | |
240 | 240 | | |
241 | | - | |
242 | | - | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
243 | 247 | | |
244 | 248 | | |
245 | 249 | | |
| |||
Lines changed: 2 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
184 | 184 | | |
185 | 185 | | |
186 | 186 | | |
187 | | - | |
| 187 | + | |
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
193 | 193 | | |
194 | | - | |
195 | 194 | | |
196 | 195 | | |
197 | 196 | | |
| |||
212 | 211 | | |
213 | 212 | | |
214 | 213 | | |
215 | | - | |
| 214 | + | |
216 | 215 | | |
217 | 216 | | |
218 | 217 | | |
219 | 218 | | |
220 | 219 | | |
221 | 220 | | |
222 | | - | |
223 | 221 | | |
224 | 222 | | |
225 | 223 | | |
| |||
Lines changed: 9 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
47 | 46 | | |
48 | 47 | | |
49 | 48 | | |
| |||
257 | 256 | | |
258 | 257 | | |
259 | 258 | | |
| 259 | + | |
260 | 260 | | |
261 | 261 | | |
262 | | - | |
| 262 | + | |
263 | 263 | | |
264 | 264 | | |
265 | 265 | | |
| |||
280 | 280 | | |
281 | 281 | | |
282 | 282 | | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
283 | 290 | | |
284 | 291 | | |
285 | 292 | | |
| |||
Lines changed: 42 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
119 | 120 | | |
120 | 121 | | |
121 | 122 | | |
122 | | - | |
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
129 | | - | |
130 | 129 | | |
131 | 130 | | |
132 | 131 | | |
| |||
152 | 151 | | |
153 | 152 | | |
154 | 153 | | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
155 | 163 | | |
156 | 164 | | |
157 | 165 | | |
| |||
189 | 197 | | |
190 | 198 | | |
191 | 199 | | |
192 | | - | |
193 | | - | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
194 | 205 | | |
195 | 206 | | |
196 | 207 | | |
197 | 208 | | |
198 | 209 | | |
199 | | - | |
| 210 | + | |
| 211 | + | |
200 | 212 | | |
201 | 213 | | |
202 | 214 | | |
203 | 215 | | |
204 | 216 | | |
205 | 217 | | |
206 | | - | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
207 | 237 | | |
208 | 238 | | |
209 | 239 | | |
| |||
214 | 244 | | |
215 | 245 | | |
216 | 246 | | |
217 | | - | |
218 | 247 | | |
219 | 248 | | |
220 | | - | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
221 | 255 | | |
222 | 256 | | |
223 | 257 | | |
| |||
230 | 264 | | |
231 | 265 | | |
232 | 266 | | |
233 | | - | |
234 | 267 | | |
235 | 268 | | |
236 | 269 | | |
| |||
Lines changed: 9 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
| |||
50 | 52 | | |
51 | 53 | | |
52 | 54 | | |
53 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
54 | 61 | | |
55 | 62 | | |
56 | 63 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
0 commit comments