(n)
| 58 | * than inventing a step that would misstate the order. |
| 59 | */ |
| 60 | export function ordinal(n) { |
| 61 | if (n <= 0) return []; |
| 62 | if (n === 1) return [ORDINAL[2]]; |
| 63 | const out = []; |
| 64 | for (let i = 0; i < n; i++) { |
| 65 | out.push(i < ORDINAL.length ? ORDINAL[Math.round((i * (ORDINAL.length - 1)) / (n - 1))] : NEUTRAL); |
| 66 | } |
| 67 | return out; |
| 68 | } |
| 69 | |
| 70 | /** "Other" keeps the neutral wherever the API folded a tail into it. */ |
| 71 | export function paletteFor(labels, scale) { |