Repository navigation
Commit 6c6b52b
authored
fix(chart-wordcloud): use the datum index for data-indexes (#251)
* fix(chart-wordcloud): use the datum index for data-indexes
The word-cloud structure tagged each word label with `data-indexes={index}`
where `index` was the position in `placedWords` — a list sorted by font size
descending. The original datum index was captured for the word's color but
never carried onto the WordCandidate, so labels were tagged with their sorted
render position instead of the data item they represent.
Every other structure/item uses the true datum index (e.g. chart-pie:
`data-indexes={[originalIndex]}`). The editor reads `data-indexes` to route
edits (`getIndexesFromElement` -> `updateItemDatum`), so double-click-renaming
a word wrote to the wrong item whenever values weren't already in descending
order — silent data corruption.
Carry the datum index onto the word and emit `data-indexes={[word.index]}`.
The sort-by-size layout is unchanged.
* test: cover word cloud data-indexes mapping
Add a regression test asserting each word label carries its datum index
rather than the font-size sort position. Data is intentionally out of
order (Apple:10, Banana:50, Cherry:30) so the size-sorted render order
(Banana, Cherry, Apple) differs from the datum indices (1, 2, 0), which
is exactly the case the fix corrects.1 parent 6cfe0bf commit 6c6b52b
2 files changed
Lines changed: 59 additions & 2 deletions
File tree
- __tests__/unit/designs/structures
- src/designs/structures
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
208 | 209 | | |
209 | 210 | | |
210 | 211 | | |
| 212 | + | |
211 | 213 | | |
212 | 214 | | |
213 | 215 | | |
| |||
235 | 237 | | |
236 | 238 | | |
237 | 239 | | |
238 | | - | |
| 240 | + | |
239 | 241 | | |
240 | 242 | | |
241 | 243 | | |
| |||
252 | 254 | | |
253 | 255 | | |
254 | 256 | | |
255 | | - | |
| 257 | + | |
256 | 258 | | |
257 | 259 | | |
258 | 260 | | |
| |||
0 commit comments