@opendata-ai/openchart-engine 8.0.0-rc.2 → 8.0.0-rc.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (271) hide show
  1. package/dist/index.d.ts +140 -2
  2. package/dist/index.js +1403 -210
  3. package/dist/index.js.map +1 -1
  4. package/package.json +3 -4
  5. package/src/__test-fixtures__/specs.ts +0 -182
  6. package/src/__tests__/__snapshots__/compile-snapshot.test.ts.snap +0 -2339
  7. package/src/__tests__/annotation-behavior.test.ts +0 -721
  8. package/src/__tests__/axes.test.ts +0 -1579
  9. package/src/__tests__/compile-animation.test.ts +0 -161
  10. package/src/__tests__/compile-chart.test.ts +0 -1303
  11. package/src/__tests__/compile-footnotes.test.ts +0 -277
  12. package/src/__tests__/compile-layer.test.ts +0 -969
  13. package/src/__tests__/compile-snapshot.test.ts +0 -156
  14. package/src/__tests__/compound-labels.test.ts +0 -147
  15. package/src/__tests__/dimensions.test.ts +0 -918
  16. package/src/__tests__/encoding-sugar.test.ts +0 -390
  17. package/src/__tests__/facet.test.ts +0 -215
  18. package/src/__tests__/helpers/invariants.ts +0 -299
  19. package/src/__tests__/known-bugs.test.ts +0 -566
  20. package/src/__tests__/layout-fuzz.test.ts +0 -358
  21. package/src/__tests__/layout-invariants.test.ts +0 -535
  22. package/src/__tests__/legend.test.ts +0 -721
  23. package/src/__tests__/mark-keys.test.ts +0 -294
  24. package/src/__tests__/ranking-recipes.test.ts +0 -260
  25. package/src/__tests__/rotation.test.ts +0 -83
  26. package/src/__tests__/scales.test.ts +0 -323
  27. package/src/__tests__/series-search.test.ts +0 -92
  28. package/src/__tests__/spec-sugar.test.ts +0 -801
  29. package/src/__tests__/you-draw-it.test.ts +0 -160
  30. package/src/annotations/__tests__/compute.test.ts +0 -1672
  31. package/src/annotations/__tests__/geometry.test.ts +0 -66
  32. package/src/annotations/__tests__/placement-fuzz.test.ts +0 -256
  33. package/src/annotations/__tests__/placement-invariants.test.ts +0 -345
  34. package/src/annotations/__tests__/placement.test.ts +0 -316
  35. package/src/annotations/__tests__/resolve-text.test.ts +0 -788
  36. package/src/annotations/__tests__/rich-text.test.ts +0 -91
  37. package/src/annotations/__tests__/thinning.test.ts +0 -285
  38. package/src/annotations/collisions.ts +0 -326
  39. package/src/annotations/compute.ts +0 -333
  40. package/src/annotations/constants.ts +0 -162
  41. package/src/annotations/geometry.ts +0 -370
  42. package/src/annotations/move.ts +0 -135
  43. package/src/annotations/placement.ts +0 -636
  44. package/src/annotations/position.ts +0 -131
  45. package/src/annotations/resolve-range.ts +0 -117
  46. package/src/annotations/resolve-refline.ts +0 -157
  47. package/src/annotations/resolve-text.ts +0 -539
  48. package/src/annotations/rich-text.ts +0 -65
  49. package/src/annotations/thinning.ts +0 -190
  50. package/src/barlist/__tests__/compile-barlist.test.ts +0 -200
  51. package/src/barlist/compile-barlist.ts +0 -391
  52. package/src/barlist/types.ts +0 -28
  53. package/src/charts/__tests__/post-process.test.ts +0 -237
  54. package/src/charts/__tests__/registry.test.ts +0 -116
  55. package/src/charts/__tests__/utils.test.ts +0 -195
  56. package/src/charts/_shared/__tests__/density-filter.test.ts +0 -32
  57. package/src/charts/_shared/density-filter.ts +0 -26
  58. package/src/charts/_shared/format-label-value.ts +0 -16
  59. package/src/charts/bar/__tests__/compute.test.ts +0 -934
  60. package/src/charts/bar/__tests__/gradient-orient.test.ts +0 -127
  61. package/src/charts/bar/__tests__/labels.test.ts +0 -292
  62. package/src/charts/bar/compute.ts +0 -539
  63. package/src/charts/bar/index.ts +0 -60
  64. package/src/charts/bar/labels.ts +0 -311
  65. package/src/charts/beeswarm/__tests__/compute.test.ts +0 -280
  66. package/src/charts/beeswarm/__tests__/dodge.test.ts +0 -148
  67. package/src/charts/beeswarm/compute.ts +0 -203
  68. package/src/charts/beeswarm/dodge.ts +0 -155
  69. package/src/charts/beeswarm/index.ts +0 -32
  70. package/src/charts/builtin.ts +0 -75
  71. package/src/charts/calendar/__tests__/compute.test.ts +0 -417
  72. package/src/charts/calendar/compute.ts +0 -319
  73. package/src/charts/calendar/index.ts +0 -32
  74. package/src/charts/column/__tests__/compute.test.ts +0 -540
  75. package/src/charts/column/__tests__/labels.test.ts +0 -179
  76. package/src/charts/column/compute.ts +0 -493
  77. package/src/charts/column/index.ts +0 -53
  78. package/src/charts/column/labels.ts +0 -229
  79. package/src/charts/dot/__tests__/compute.test.ts +0 -380
  80. package/src/charts/dot/__tests__/labels.test.ts +0 -98
  81. package/src/charts/dot/compute.ts +0 -285
  82. package/src/charts/dot/index.ts +0 -62
  83. package/src/charts/dot/labels.ts +0 -121
  84. package/src/charts/line/__tests__/compute.test.ts +0 -1194
  85. package/src/charts/line/__tests__/curves.test.ts +0 -51
  86. package/src/charts/line/__tests__/labels.test.ts +0 -94
  87. package/src/charts/line/__tests__/mark-options.test.ts +0 -175
  88. package/src/charts/line/area.ts +0 -484
  89. package/src/charts/line/compute.ts +0 -356
  90. package/src/charts/line/curves.ts +0 -85
  91. package/src/charts/line/index.ts +0 -176
  92. package/src/charts/line/labels.ts +0 -177
  93. package/src/charts/parliament/__tests__/compute.test.ts +0 -411
  94. package/src/charts/parliament/compute.ts +0 -313
  95. package/src/charts/parliament/index.ts +0 -32
  96. package/src/charts/pie/__tests__/compute.test.ts +0 -384
  97. package/src/charts/pie/__tests__/labels.test.ts +0 -132
  98. package/src/charts/pie/compute.ts +0 -324
  99. package/src/charts/pie/index.ts +0 -49
  100. package/src/charts/pie/labels.ts +0 -143
  101. package/src/charts/post-process.ts +0 -229
  102. package/src/charts/range/__tests__/compute.test.ts +0 -486
  103. package/src/charts/range/compute.ts +0 -273
  104. package/src/charts/range/index.ts +0 -82
  105. package/src/charts/range/labels.ts +0 -169
  106. package/src/charts/rect/__tests__/compute.test.ts +0 -120
  107. package/src/charts/rect/index.ts +0 -127
  108. package/src/charts/registry.ts +0 -72
  109. package/src/charts/rule/index.ts +0 -139
  110. package/src/charts/scatter/__tests__/compute.test.ts +0 -488
  111. package/src/charts/scatter/__tests__/trendline.test.ts +0 -191
  112. package/src/charts/scatter/compute.ts +0 -192
  113. package/src/charts/scatter/index.ts +0 -46
  114. package/src/charts/scatter/trendline.ts +0 -100
  115. package/src/charts/text/__tests__/compute.test.ts +0 -307
  116. package/src/charts/text/index.ts +0 -141
  117. package/src/charts/tick/__tests__/compute.test.ts +0 -75
  118. package/src/charts/tick/index.ts +0 -99
  119. package/src/charts/utils.ts +0 -170
  120. package/src/charts/waffle/__tests__/compute.test.ts +0 -305
  121. package/src/charts/waffle/compute.ts +0 -197
  122. package/src/charts/waffle/index.ts +0 -31
  123. package/src/compile/__tests__/color-scale-range.test.ts +0 -158
  124. package/src/compile/__tests__/color-scale-reverse.test.ts +0 -89
  125. package/src/compile/__tests__/data-clip.test.ts +0 -127
  126. package/src/compile/__tests__/fill-patterns.test.ts +0 -154
  127. package/src/compile/__tests__/size-scale.test.ts +0 -108
  128. package/src/compile/__tests__/watermark-obstacle.test.ts +0 -93
  129. package/src/compile/color-scale-range.ts +0 -101
  130. package/src/compile/data-clip.ts +0 -48
  131. package/src/compile/fill-patterns.ts +0 -74
  132. package/src/compile/layer.ts +0 -626
  133. package/src/compile/size-scale.ts +0 -139
  134. package/src/compile/spec-sugar.ts +0 -758
  135. package/src/compile/watermark-obstacle.ts +0 -54
  136. package/src/compile/you-draw-it.ts +0 -123
  137. package/src/compile.ts +0 -1450
  138. package/src/compiler/__tests__/a11y-warnings.test.ts +0 -148
  139. package/src/compiler/__tests__/animation.test.ts +0 -177
  140. package/src/compiler/__tests__/compile.test.ts +0 -87
  141. package/src/compiler/__tests__/fixtures/vl-parity/axis-null.json +0 -19
  142. package/src/compiler/__tests__/fixtures/vl-parity/color-value.json +0 -20
  143. package/src/compiler/__tests__/fixtures/vl-parity/count-aggregate.json +0 -22
  144. package/src/compiler/__tests__/fixtures/vl-parity/data-values.json +0 -19
  145. package/src/compiler/__tests__/fixtures/vl-parity/layer-axis-null.json +0 -14
  146. package/src/compiler/__tests__/fixtures/vl-parity/layer-count.json +0 -34
  147. package/src/compiler/__tests__/fixtures/vl-parity/layer-data-values.json +0 -22
  148. package/src/compiler/__tests__/fixtures/vl-parity/layer-legend-null.json +0 -41
  149. package/src/compiler/__tests__/fixtures/vl-parity/layer-scheme.json +0 -38
  150. package/src/compiler/__tests__/fixtures/vl-parity/layer-sort.json +0 -28
  151. package/src/compiler/__tests__/fixtures/vl-parity/layer-theta.json +0 -28
  152. package/src/compiler/__tests__/fixtures/vl-parity/layer-title.json +0 -30
  153. package/src/compiler/__tests__/fixtures/vl-parity/layer-value-def.json +0 -29
  154. package/src/compiler/__tests__/fixtures/vl-parity/legend-null.json +0 -32
  155. package/src/compiler/__tests__/fixtures/vl-parity/scheme.json +0 -25
  156. package/src/compiler/__tests__/fixtures/vl-parity/sort-by-value.json +0 -19
  157. package/src/compiler/__tests__/fixtures/vl-parity/theta-arc.json +0 -19
  158. package/src/compiler/__tests__/fixtures/vl-parity/title-subtitle.json +0 -21
  159. package/src/compiler/__tests__/fixtures/vl-parity/width-height.json +0 -23
  160. package/src/compiler/__tests__/keys.test.ts +0 -83
  161. package/src/compiler/__tests__/normalize-highlight.test.ts +0 -103
  162. package/src/compiler/__tests__/normalize.test.ts +0 -399
  163. package/src/compiler/__tests__/sparkline-defaults.test.ts +0 -153
  164. package/src/compiler/__tests__/validate-did-you-mean.test.ts +0 -86
  165. package/src/compiler/__tests__/validate-highlight.test.ts +0 -112
  166. package/src/compiler/__tests__/validate-near-miss.test.ts +0 -89
  167. package/src/compiler/__tests__/validate.test.ts +0 -629
  168. package/src/compiler/__tests__/vl-parity.test.ts +0 -68
  169. package/src/compiler/a11y-warnings.ts +0 -110
  170. package/src/compiler/animation.ts +0 -142
  171. package/src/compiler/index.ts +0 -47
  172. package/src/compiler/keys.ts +0 -55
  173. package/src/compiler/normalize.ts +0 -733
  174. package/src/compiler/sparkline-defaults.ts +0 -138
  175. package/src/compiler/types.ts +0 -241
  176. package/src/compiler/validate.ts +0 -1810
  177. package/src/endpoint-labels/__tests__/compute.test.ts +0 -587
  178. package/src/endpoint-labels/compute.ts +0 -621
  179. package/src/endpoint-labels/constants.ts +0 -54
  180. package/src/endpoint-labels/format.ts +0 -60
  181. package/src/endpoint-labels/predict.ts +0 -139
  182. package/src/format/__tests__/field-format.test.ts +0 -164
  183. package/src/format/field-format.ts +0 -27
  184. package/src/geo/__tests__/compile-map.test.ts +0 -621
  185. package/src/geo/compile-map.ts +0 -856
  186. package/src/geo/join.ts +0 -115
  187. package/src/geo/projections.ts +0 -45
  188. package/src/geo/types.ts +0 -24
  189. package/src/graphs/__tests__/community.test.ts +0 -228
  190. package/src/graphs/__tests__/compile-graph.test.ts +0 -396
  191. package/src/graphs/__tests__/encoding.test.ts +0 -415
  192. package/src/graphs/community.ts +0 -92
  193. package/src/graphs/compile-graph.ts +0 -329
  194. package/src/graphs/encoding.ts +0 -356
  195. package/src/graphs/types.ts +0 -106
  196. package/src/index.ts +0 -177
  197. package/src/layout/__tests__/metrics.test.ts +0 -97
  198. package/src/layout/__tests__/scales-highlight.test.ts +0 -192
  199. package/src/layout/axes/rotation.ts +0 -152
  200. package/src/layout/axes/thinning.ts +0 -98
  201. package/src/layout/axes/ticks.ts +0 -409
  202. package/src/layout/axes.ts +0 -757
  203. package/src/layout/dimensions.ts +0 -912
  204. package/src/layout/facet.ts +0 -91
  205. package/src/layout/gridlines.ts +0 -84
  206. package/src/layout/metrics.ts +0 -132
  207. package/src/layout/plan.ts +0 -631
  208. package/src/layout/scales.ts +0 -1053
  209. package/src/layout/shared.ts +0 -44
  210. package/src/legend/__tests__/continuous.test.ts +0 -318
  211. package/src/legend/__tests__/redundancy.test.ts +0 -108
  212. package/src/legend/__tests__/size.test.ts +0 -348
  213. package/src/legend/__tests__/suppression.test.ts +0 -382
  214. package/src/legend/compute.ts +0 -747
  215. package/src/legend/continuous.ts +0 -327
  216. package/src/legend/size.ts +0 -407
  217. package/src/legend/suppression.ts +0 -226
  218. package/src/legend/wrap.ts +0 -117
  219. package/src/sankey/__tests__/compile-sankey.test.ts +0 -458
  220. package/src/sankey/__tests__/layout.test.ts +0 -165
  221. package/src/sankey/__tests__/node-label-wrap.test.ts +0 -114
  222. package/src/sankey/__tests__/node-sort.test.ts +0 -45
  223. package/src/sankey/compile-sankey.ts +0 -706
  224. package/src/sankey/layout.ts +0 -184
  225. package/src/sankey/types.ts +0 -41
  226. package/src/tables/__tests__/bar-column.test.ts +0 -147
  227. package/src/tables/__tests__/category-colors.test.ts +0 -230
  228. package/src/tables/__tests__/compile-table.test.ts +0 -236
  229. package/src/tables/__tests__/format-cells.test.ts +0 -143
  230. package/src/tables/__tests__/heatmap.test.ts +0 -148
  231. package/src/tables/__tests__/pagination.test.ts +0 -78
  232. package/src/tables/__tests__/search.test.ts +0 -94
  233. package/src/tables/__tests__/sort.test.ts +0 -107
  234. package/src/tables/__tests__/sparkline.test.ts +0 -122
  235. package/src/tables/bar-column.ts +0 -94
  236. package/src/tables/category-colors.ts +0 -78
  237. package/src/tables/compile-table.ts +0 -427
  238. package/src/tables/format-cells.ts +0 -115
  239. package/src/tables/heatmap.ts +0 -141
  240. package/src/tables/pagination.ts +0 -46
  241. package/src/tables/search.ts +0 -66
  242. package/src/tables/sort.ts +0 -69
  243. package/src/tables/sparkline.ts +0 -113
  244. package/src/tables/utils.ts +0 -16
  245. package/src/tilemap/__tests__/compile-tilemap.test.ts +0 -576
  246. package/src/tilemap/compile-tilemap.ts +0 -755
  247. package/src/tilemap/layout.ts +0 -172
  248. package/src/tilemap/types.ts +0 -33
  249. package/src/tooltips/__tests__/compute.test.ts +0 -582
  250. package/src/tooltips/compute.ts +0 -700
  251. package/src/transforms/__tests__/aggregate.test.ts +0 -159
  252. package/src/transforms/__tests__/bin.test.ts +0 -88
  253. package/src/transforms/__tests__/calculate.test.ts +0 -146
  254. package/src/transforms/__tests__/conditional.test.ts +0 -127
  255. package/src/transforms/__tests__/filter-relative.test.ts +0 -202
  256. package/src/transforms/__tests__/filter.test.ts +0 -59
  257. package/src/transforms/__tests__/fold.test.ts +0 -79
  258. package/src/transforms/__tests__/index.test.ts +0 -93
  259. package/src/transforms/__tests__/predicates.test.ts +0 -193
  260. package/src/transforms/__tests__/timeunit.test.ts +0 -129
  261. package/src/transforms/__tests__/window.test.ts +0 -286
  262. package/src/transforms/aggregate.ts +0 -131
  263. package/src/transforms/bin.ts +0 -87
  264. package/src/transforms/calculate.ts +0 -60
  265. package/src/transforms/conditional.ts +0 -46
  266. package/src/transforms/filter.ts +0 -122
  267. package/src/transforms/fold.ts +0 -49
  268. package/src/transforms/index.ts +0 -60
  269. package/src/transforms/predicates.ts +0 -123
  270. package/src/transforms/timeunit.ts +0 -88
  271. package/src/transforms/window.ts +0 -185
@@ -1,305 +0,0 @@
1
- import type { LayoutStrategy, Rect, RectMark } from '@opendata-ai/openchart-core';
2
- import { describe, expect, it } from 'vitest';
3
-
4
- import { compileChart } from '../../../compile';
5
- import type { NormalizedChartSpec } from '../../../compiler/types';
6
- import { computeScales } from '../../../layout/scales';
7
- import { computeWaffleMarks, largestRemainderCells } from '../compute';
8
-
9
- // ---------------------------------------------------------------------------
10
- // Shared fixtures
11
- // ---------------------------------------------------------------------------
12
-
13
- const chartArea: Rect = { x: 40, y: 20, width: 400, height: 400 };
14
-
15
- const fullStrategy: LayoutStrategy = {
16
- labelMode: 'all',
17
- legendPosition: 'right',
18
- annotationPosition: 'inline',
19
- axisLabelDensity: 'full',
20
- };
21
-
22
- const energyMix = [
23
- { source: 'Fossil', share: 60 },
24
- { source: 'Renewables', share: 30 },
25
- { source: 'Nuclear', share: 10 },
26
- ];
27
-
28
- function makeWaffleSpec(overrides: Partial<NormalizedChartSpec> = {}): NormalizedChartSpec {
29
- return {
30
- markType: 'waffle',
31
- markDef: { type: 'waffle' },
32
- data: [...energyMix],
33
- encoding: {
34
- y: { field: 'share', type: 'quantitative' },
35
- color: { field: 'source', type: 'nominal' },
36
- },
37
- chrome: {},
38
- annotations: [],
39
- responsive: true,
40
- theme: {},
41
- darkMode: 'off',
42
- labels: { density: 'auto', format: '' },
43
- ...overrides,
44
- } as NormalizedChartSpec;
45
- }
46
-
47
- function marksFor(spec: NormalizedChartSpec): RectMark[] {
48
- const scales = computeScales(spec, chartArea, spec.data);
49
- return computeWaffleMarks(spec, scales, chartArea, fullStrategy);
50
- }
51
-
52
- /** Deterministic LCG so the property test carries no runtime randomness. */
53
- function lcg(seed: number): () => number {
54
- let s = seed >>> 0;
55
- return () => {
56
- s = (s * 1664525 + 1013904223) >>> 0;
57
- return s / 2 ** 32;
58
- };
59
- }
60
-
61
- // ---------------------------------------------------------------------------
62
- // largestRemainderCells
63
- // ---------------------------------------------------------------------------
64
-
65
- describe('largestRemainderCells', () => {
66
- it('sums exactly to units', () => {
67
- expect(largestRemainderCells([60, 30, 10], 100).reduce((a, b) => a + b, 0)).toBe(100);
68
- expect(largestRemainderCells([1, 1, 1], 100).reduce((a, b) => a + b, 0)).toBe(100);
69
- expect(largestRemainderCells([7, 13, 3], 40).reduce((a, b) => a + b, 0)).toBe(40);
70
- });
71
-
72
- it('rounds a 0.4-cell category by largest remainder while the total stays exact', () => {
73
- // Quotas 33.2 / 33.2 / 33.2 / 0.4: the 0.4 remainder is the largest, so
74
- // the small category wins the single leftover cell.
75
- expect(largestRemainderCells([33.2, 33.2, 33.2, 0.4], 100)).toEqual([33, 33, 33, 1]);
76
-
77
- // Quotas 49.8 / 49.8 / 0.4: both 0.8 remainders beat 0.4, so the small
78
- // category legitimately rounds to 0 cells (no minimum-1-cell rule).
79
- expect(largestRemainderCells([49.8, 49.8, 0.4], 100)).toEqual([50, 50, 0]);
80
- });
81
-
82
- it('breaks equal remainders by larger raw value, then stable input index', () => {
83
- // Quotas 1.5 / 2.5 / 3.5 / 2.5 (all remainders 0.5), two leftover cells:
84
- // the largest raw value (35) wins first, then the 25s tie and the earlier
85
- // input index (1) wins over index 3.
86
- expect(largestRemainderCells([15, 25, 35, 25], 10)).toEqual([1, 3, 4, 2]);
87
-
88
- // Fully symmetric tie: value tiebreak is moot, index order decides.
89
- expect(largestRemainderCells([25, 25, 25, 25], 10)).toEqual([3, 3, 2, 2]);
90
- });
91
-
92
- it('allocates 0 cells to non-finite and negative values', () => {
93
- expect(largestRemainderCells([Number.NaN, 50, -10, 50], 10)).toEqual([0, 5, 0, 5]);
94
- });
95
-
96
- it('returns all zeros when there is nothing to allocate', () => {
97
- expect(largestRemainderCells([0, 0], 100)).toEqual([0, 0]);
98
- expect(largestRemainderCells([], 100)).toEqual([]);
99
- });
100
- });
101
-
102
- // ---------------------------------------------------------------------------
103
- // computeWaffleMarks geometry
104
- // ---------------------------------------------------------------------------
105
-
106
- describe('computeWaffleMarks', () => {
107
- it('emits square cells with a gap of cell/6', () => {
108
- const marks = marksFor(makeWaffleSpec());
109
- expect(marks).toHaveLength(100);
110
-
111
- const first = marks[0];
112
- expect(first.width).toBeCloseTo(first.height);
113
-
114
- // Neighbor in the same row sits one cell + gap to the right.
115
- const second = marks[1];
116
- expect(second.y).toBe(first.y);
117
- expect(second.x - (first.x + first.width)).toBeCloseTo(first.width / 6);
118
- });
119
-
120
- it('fills bottom-left to top-right by rows', () => {
121
- const marks = marksFor(makeWaffleSpec());
122
-
123
- // First cell is the leftmost column; the first 10 cells share the bottom row.
124
- const xs = marks.map((m) => m.x);
125
- const ys = marks.map((m) => m.y);
126
- expect(marks[0].x).toBe(Math.min(...xs));
127
- expect(marks[0].y).toBe(Math.max(...ys));
128
- for (let i = 1; i < 10; i++) {
129
- expect(marks[i].y).toBe(marks[0].y);
130
- expect(marks[i].x).toBeGreaterThan(marks[i - 1].x);
131
- }
132
- // Cell 10 wraps to the next row up.
133
- expect(marks[10].x).toBe(marks[0].x);
134
- expect(marks[10].y).toBeLessThan(marks[0].y);
135
- // Last cell tops out the grid.
136
- expect(marks[99].y).toBe(Math.min(...ys));
137
- });
138
-
139
- it('centers the grid in the chart area', () => {
140
- const marks = marksFor(makeWaffleSpec());
141
- const minX = Math.min(...marks.map((m) => m.x));
142
- const maxX = Math.max(...marks.map((m) => m.x + m.width));
143
- const minY = Math.min(...marks.map((m) => m.y));
144
- const maxY = Math.max(...marks.map((m) => m.y + m.height));
145
-
146
- expect(minX - chartArea.x).toBeCloseTo(chartArea.x + chartArea.width - maxX);
147
- expect(minY - chartArea.y).toBeCloseTo(chartArea.y + chartArea.height - maxY);
148
- });
149
-
150
- it('assigns category cells contiguously in data order with stable keys', () => {
151
- const marks = marksFor(makeWaffleSpec());
152
-
153
- const bySource = (s: string) =>
154
- marks.filter((m) => (m.data as { source: string }).source === s);
155
- expect(bySource('Fossil')).toHaveLength(60);
156
- expect(bySource('Renewables')).toHaveLength(30);
157
- expect(bySource('Nuclear')).toHaveLength(10);
158
-
159
- expect(marks[0].key).toBe('Fossil|0');
160
- expect(marks[59].key).toBe('Fossil|59');
161
- expect(marks[60].key).toBe('Renewables|0');
162
- expect(marks[99].key).toBe('Nuclear|9');
163
- });
164
-
165
- it('respects units and columns mark options', () => {
166
- const spec = makeWaffleSpec({
167
- markDef: { type: 'waffle', units: 40, columns: 8 },
168
- });
169
- const marks = marksFor(spec);
170
- expect(marks).toHaveLength(40);
171
-
172
- // 8 columns x 5 rows: cells 0-7 share the bottom row, cell 8 wraps.
173
- expect(marks[7].y).toBe(marks[0].y);
174
- expect(marks[8].x).toBe(marks[0].x);
175
- expect(marks[8].y).toBeLessThan(marks[0].y);
176
- });
177
-
178
- it('labels the first cell of each category "x of N units" and marks the rest decorative', () => {
179
- const marks = marksFor(makeWaffleSpec());
180
-
181
- expect(marks[0].aria.label).toBe('Fossil: 60 of 100 units (60%)');
182
- expect(marks[0].aria.decorative).toBeUndefined();
183
- expect(marks[1].aria.label).toBe('Fossil: 60 of 100 units (60%)');
184
- expect(marks[1].aria.decorative).toBe(true);
185
- expect(marks[60].aria.label).toBe('Renewables: 30 of 100 units (30%)');
186
- expect(marks[60].aria.decorative).toBeUndefined();
187
- });
188
-
189
- it('defaults cornerRadius to 1 and honors a mark-level override', () => {
190
- expect(marksFor(makeWaffleSpec())[0].cornerRadius).toBe(1);
191
-
192
- const spec = makeWaffleSpec({ markDef: { type: 'waffle', cornerRadius: 3 } });
193
- expect(marksFor(spec)[0].cornerRadius).toBe(3);
194
- });
195
- });
196
-
197
- // ---------------------------------------------------------------------------
198
- // compileChart integration (spec in, layout out)
199
- // ---------------------------------------------------------------------------
200
-
201
- describe('compileChart with waffle marks', () => {
202
- const baseSpec = {
203
- mark: 'waffle' as const,
204
- data: [...energyMix],
205
- encoding: {
206
- theta: { field: 'share', type: 'quantitative' as const },
207
- color: { field: 'source', type: 'nominal' as const },
208
- },
209
- };
210
-
211
- it('renders exactly units cells for random distributions summing to 100% (property test)', () => {
212
- const rand = lcg(20260711);
213
-
214
- for (let trial = 0; trial < 25; trial++) {
215
- const categoryCount = 2 + Math.floor(rand() * 7);
216
- const raw = Array.from({ length: categoryCount }, () => 0.01 + rand());
217
- const total = raw.reduce((a, b) => a + b, 0);
218
- const data = raw.map((v, i) => ({ category: `C${i}`, share: (v / total) * 100 }));
219
-
220
- const layout = compileChart(
221
- {
222
- mark: 'waffle',
223
- data,
224
- encoding: {
225
- theta: { field: 'share', type: 'quantitative' },
226
- color: { field: 'category', type: 'nominal' },
227
- },
228
- },
229
- { width: 600, height: 400 },
230
- );
231
-
232
- const cells = layout.marks.filter((m) => m.type === 'rect');
233
- expect(cells).toHaveLength(100);
234
- }
235
- });
236
-
237
- it('accepts theta as the value channel and compiles without axes or gridlines', () => {
238
- const layout = compileChart(baseSpec, { width: 600, height: 400 });
239
-
240
- expect(layout.marks.filter((m) => m.type === 'rect')).toHaveLength(100);
241
- expect(layout.axes.x).toBeUndefined();
242
- expect(layout.axes.y).toBeUndefined();
243
- });
244
-
245
- it('shares one tooltip object across every cell of a category', () => {
246
- const layout = compileChart(baseSpec, { width: 600, height: 400 });
247
-
248
- const rects = layout.marks
249
- .map((m, i) => ({ mark: m as RectMark, id: `rect-${i}` }))
250
- .filter(({ mark }) => mark.type === 'rect');
251
-
252
- const fossilIds = rects
253
- .filter(({ mark }) => (mark.data as { source: string }).source === 'Fossil')
254
- .map(({ id }) => id);
255
- const nuclearIds = rects
256
- .filter(({ mark }) => (mark.data as { source: string }).source === 'Nuclear')
257
- .map(({ id }) => id);
258
- expect(fossilIds).toHaveLength(60);
259
-
260
- const fossilTooltip = layout.tooltipDescriptors.get(fossilIds[0]);
261
- expect(fossilTooltip).toBeDefined();
262
- // Literally the same object for all cells: one hover target per category.
263
- for (const id of fossilIds) {
264
- expect(layout.tooltipDescriptors.get(id)).toBe(fossilTooltip);
265
- }
266
- expect(layout.tooltipDescriptors.get(nuclearIds[0])).not.toBe(fossilTooltip);
267
-
268
- expect(fossilTooltip!.title).toBe('Fossil');
269
- const share = fossilTooltip!.fields.find((f) => f.label === 'Share');
270
- expect(share?.value).toBe('60 of 100 units');
271
- });
272
-
273
- it('lists a category in the legend even when it rounds to 0 cells', () => {
274
- const layout = compileChart(
275
- {
276
- mark: 'waffle',
277
- data: [
278
- { source: 'A', share: 49.8 },
279
- { source: 'B', share: 49.8 },
280
- { source: 'C', share: 0.4 },
281
- ],
282
- encoding: {
283
- theta: { field: 'share', type: 'quantitative' },
284
- color: { field: 'source', type: 'nominal' },
285
- },
286
- },
287
- { width: 600, height: 400 },
288
- );
289
-
290
- const cells = layout.marks.filter((m): m is RectMark => m.type === 'rect');
291
- expect(cells).toHaveLength(100);
292
- expect(cells.some((m) => (m.data as { source: string }).source === 'C')).toBe(false);
293
-
294
- expect(layout.legend.type).toBe('categorical');
295
- const labels =
296
- layout.legend.type === 'categorical' ? layout.legend.entries.map((e) => e.label) : [];
297
- expect(labels).toContain('C');
298
- });
299
-
300
- it('generates alt text with the unit framing', () => {
301
- const layout = compileChart(baseSpec, { width: 600, height: 400 });
302
- expect(layout.a11y.altText).toContain('Waffle chart');
303
- expect(layout.a11y.altText).toContain('dividing 100 units');
304
- });
305
- });
@@ -1,197 +0,0 @@
1
- /**
2
- * Waffle chart mark computation.
3
- *
4
- * A unit grid ("3 in 100 people") for part-to-whole counts. Category values
5
- * aggregate by the nominal color field, normalize to `markDef.units` cells
6
- * via largest-remainder rounding (cells always sum exactly to units), and
7
- * fill the grid bottom-left to top-right by rows, matching how readers count.
8
- *
9
- * Geometry: square cells with a gap of cell/6, grid centered in the chart
10
- * area. No positional scales are consumed; the value comes straight from the
11
- * data (the `theta` channel aliases to `y` in the sugar pass, same as arc).
12
- *
13
- * Zero-cell categories are legitimate: a nonzero share can round to 0 cells
14
- * and there is deliberately no minimum-1-cell rule (a floor would distort the
15
- * other categories). The legend still lists the category because legend
16
- * entries derive from data, not marks.
17
- */
18
-
19
- import type {
20
- DataRow,
21
- Encoding,
22
- LayoutStrategy,
23
- MarkAria,
24
- Rect,
25
- RectMark,
26
- } from '@opendata-ai/openchart-core';
27
- import { formatPercent } from '@opendata-ai/openchart-core';
28
-
29
- import { serializeKeyValue } from '../../compiler/keys';
30
- import type { NormalizedChartSpec } from '../../compiler/types';
31
- import type { ResolvedScales } from '../../layout/scales';
32
- import { getColor } from '../utils';
33
-
34
- // ---------------------------------------------------------------------------
35
- // Constants
36
- // ---------------------------------------------------------------------------
37
-
38
- /** Default total cell count (the "out of 100" framing). */
39
- const DEFAULT_UNITS = 100;
40
-
41
- /** Default column count (10x10 grid at the default units). */
42
- const DEFAULT_COLUMNS = 10;
43
-
44
- /** Default cell corner radius (px). Subtle rounding; cells stay data-crisp. */
45
- const DEFAULT_CORNER_RADIUS = 1;
46
-
47
- /** Gap between cells as a fraction of the cell size. */
48
- const GAP_FRACTION = 1 / 6;
49
-
50
- // ---------------------------------------------------------------------------
51
- // Largest-remainder rounding
52
- // ---------------------------------------------------------------------------
53
-
54
- /**
55
- * Allocate `units` integer cells across `values` proportionally using the
56
- * largest-remainder method, so the result always sums exactly to `units`.
57
- *
58
- * Tiebreak is deterministic and never depends on map iteration order:
59
- * equal remainders break by larger raw value, then by stable input index.
60
- * Non-finite and negative values allocate 0 cells.
61
- */
62
- export function largestRemainderCells(values: number[], units: number): number[] {
63
- const clean = values.map((v) => (Number.isFinite(v) && v > 0 ? v : 0));
64
- const total = clean.reduce((sum, v) => sum + v, 0);
65
- const cells = new Array<number>(values.length).fill(0);
66
- if (total <= 0 || units <= 0) return cells;
67
-
68
- const quotas = clean.map((v) => (v / total) * units);
69
- let allocated = 0;
70
- for (let i = 0; i < quotas.length; i++) {
71
- cells[i] = Math.floor(quotas[i]);
72
- allocated += cells[i];
73
- }
74
-
75
- // Distribute the leftover cells to the largest remainders. Ties break by
76
- // larger raw value, then smaller input index (stable and deterministic).
77
- const order = quotas
78
- .map((q, i) => ({ remainder: q - Math.floor(q), value: clean[i], index: i }))
79
- .sort((a, b) => b.remainder - a.remainder || b.value - a.value || a.index - b.index);
80
- for (let k = 0; k < units - allocated; k++) {
81
- cells[order[k].index] += 1;
82
- }
83
-
84
- return cells;
85
- }
86
-
87
- // ---------------------------------------------------------------------------
88
- // Public API
89
- // ---------------------------------------------------------------------------
90
-
91
- /**
92
- * Compute waffle cell marks from a normalized chart spec.
93
- *
94
- * Categories come from the color field (aggregated in data order, matching
95
- * pie), the share value from the quantitative y channel (theta pre-aliased
96
- * to y). Emits one RectMark per cell in fill order (bottom-left to top-right
97
- * by rows), which also drives the entrance-stagger sweep.
98
- */
99
- export function computeWaffleMarks(
100
- spec: NormalizedChartSpec,
101
- scales: ResolvedScales,
102
- chartArea: Rect,
103
- _strategy: LayoutStrategy,
104
- ): RectMark[] {
105
- const encoding = spec.encoding as Encoding;
106
-
107
- const valueChannel = encoding.y ?? encoding.x;
108
- const colorField = encoding.color && 'field' in encoding.color ? encoding.color.field : undefined;
109
- if (!valueChannel || !colorField) return [];
110
-
111
- // Aggregate values by category, preserving data order (drives cell order,
112
- // color assignment, and the legend, which derives the same order from data).
113
- const categoryTotals = new Map<string, number>();
114
- const categoryRows = new Map<string, DataRow>();
115
- for (const row of spec.data) {
116
- const cat = String(row[colorField] ?? '');
117
- const val = Number(row[valueChannel.field] ?? 0);
118
- if (!Number.isFinite(val) || val < 0) continue;
119
-
120
- categoryTotals.set(cat, (categoryTotals.get(cat) ?? 0) + val);
121
- if (!categoryRows.has(cat)) {
122
- categoryRows.set(cat, row);
123
- }
124
- }
125
-
126
- const categories = [...categoryTotals.keys()];
127
- const values = categories.map((cat) => categoryTotals.get(cat)!);
128
- const total = values.reduce((sum, v) => sum + v, 0);
129
- if (categories.length === 0 || total <= 0) return [];
130
-
131
- const units = Math.max(1, Math.round(spec.markDef.units ?? DEFAULT_UNITS));
132
- const columns = Math.max(1, Math.round(spec.markDef.columns ?? DEFAULT_COLUMNS));
133
- const rows = Math.ceil(units / columns);
134
-
135
- const cellCounts = largestRemainderCells(values, units);
136
-
137
- // Square cells with gap = cell/6: grid width = columns*cell + (columns-1)*gap.
138
- // Solve for the cell size on both axes and take the smaller so the grid
139
- // stays square and inside the chart area, then center it.
140
- const cell = Math.min(
141
- chartArea.width / (columns + (columns - 1) * GAP_FRACTION),
142
- chartArea.height / (rows + (rows - 1) * GAP_FRACTION),
143
- );
144
- if (!(cell > 0)) return [];
145
-
146
- const gap = cell * GAP_FRACTION;
147
- const step = cell + gap;
148
- const gridWidth = columns * cell + (columns - 1) * gap;
149
- const gridHeight = rows * cell + (rows - 1) * gap;
150
- const originX = chartArea.x + (chartArea.width - gridWidth) / 2;
151
- // Top edge of the bottom row; rows fill upward from here.
152
- const bottomRowY = chartArea.y + (chartArea.height - gridHeight) / 2 + gridHeight - cell;
153
-
154
- const cornerRadius =
155
- spec.markDef.cornerRadius === 'pill'
156
- ? cell / 2
157
- : (spec.markDef.cornerRadius ?? DEFAULT_CORNER_RADIUS);
158
-
159
- const marks: RectMark[] = [];
160
- let cellIndex = 0;
161
-
162
- for (let c = 0; c < categories.length; c++) {
163
- const category = categories[c];
164
- const count = cellCounts[c];
165
- const value = categoryTotals.get(category)!;
166
- const percentStr = total > 0 ? formatPercent(value / total) : '0%';
167
- const row = categoryRows.get(category)!;
168
- const catKey = serializeKeyValue(category);
169
- const fill = getColor(scales, category);
170
-
171
- // One SR stop per category: the first cell carries the label, the rest
172
- // are decorative duplicates (100 cells would drown screen reader users).
173
- const aria: MarkAria = {
174
- label: `${category}: ${count} of ${units} units (${percentStr})`,
175
- };
176
-
177
- for (let k = 0; k < count; k++, cellIndex++) {
178
- const col = cellIndex % columns;
179
- const gridRow = Math.floor(cellIndex / columns); // 0 = bottom row
180
-
181
- marks.push({
182
- type: 'rect',
183
- key: `${catKey}|${k}`,
184
- x: originX + col * step,
185
- y: bottomRowY - gridRow * step,
186
- width: cell,
187
- height: cell,
188
- fill,
189
- cornerRadius,
190
- data: row as Record<string, unknown>,
191
- aria: k === 0 ? aria : { ...aria, decorative: true },
192
- });
193
- }
194
- }
195
-
196
- return marks;
197
- }
@@ -1,31 +0,0 @@
1
- /**
2
- * Waffle chart module.
3
- *
4
- * Exports the waffle renderer and computation functions. Waffles emit plain
5
- * RectMark[] (rendered by the existing rect mark path) with no per-cell value
6
- * labels: the legend names the categories and the tooltip carries the counts,
7
- * so cell labels would only add noise to the grid.
8
- */
9
-
10
- import type { Mark } from '@opendata-ai/openchart-core';
11
- import type { ChartRenderer } from '../registry';
12
- import { computeWaffleMarks } from './compute';
13
-
14
- // ---------------------------------------------------------------------------
15
- // Waffle chart renderer
16
- // ---------------------------------------------------------------------------
17
-
18
- /**
19
- * Waffle chart renderer.
20
- *
21
- * Produces one square cell per unit, filled bottom-left to top-right by rows.
22
- */
23
- export const waffleRenderer: ChartRenderer = (spec, scales, chartArea, strategy, _theme) => {
24
- return computeWaffleMarks(spec, scales, chartArea, strategy) as Mark[];
25
- };
26
-
27
- // ---------------------------------------------------------------------------
28
- // Public exports
29
- // ---------------------------------------------------------------------------
30
-
31
- export { computeWaffleMarks, largestRemainderCells } from './compute';
@@ -1,158 +0,0 @@
1
- import type { Encoding, ResolvedTheme } from '@opendata-ai/openchart-core';
2
- import { ACHROMATIC_RAMP, adaptTheme, resolveTheme } from '@opendata-ai/openchart-core';
3
- import { scaleLinear, scaleOrdinal } from 'd3-scale';
4
- import { describe, expect, it } from 'vitest';
5
- import type { ResolvedScales } from '../../layout/scales';
6
- import { applyColorScaleRange } from '../color-scale-range';
7
-
8
- const theme: ResolvedTheme = resolveTheme();
9
- const accentNeutralTheme: ResolvedTheme = resolveTheme({ seriesStrategy: 'accent-neutral' });
10
- const darkAccentNeutralTheme: ResolvedTheme = adaptTheme(accentNeutralTheme);
11
-
12
- describe('applyColorScaleRange', () => {
13
- it('is a no-op when no color scale is present', () => {
14
- const scales: ResolvedScales = {};
15
- const encoding: Encoding = {
16
- x: { field: 'x', type: 'quantitative' },
17
- y: { field: 'y', type: 'quantitative' },
18
- };
19
- expect(() => applyColorScaleRange(scales, encoding, theme)).not.toThrow();
20
- expect(scales.color).toBeUndefined();
21
- });
22
-
23
- it('does not overwrite the range when the encoding declares an explicit palette', () => {
24
- // computeScales has already applied the explicit palette to the scale.
25
- // The helper must leave it untouched (not replace it with the theme palette).
26
- const explicit = ['#111111', '#222222', '#333333'];
27
- const ordinal = scaleOrdinal<string, string>().domain(['a', 'b', 'c']).range(explicit);
28
- const scales: ResolvedScales = {
29
- color: { scale: ordinal, type: 'ordinal', channel: 'color' },
30
- };
31
- const encoding: Encoding = {
32
- x: { field: 'x', type: 'nominal' },
33
- y: { field: 'y', type: 'quantitative' },
34
- color: {
35
- field: 'c',
36
- type: 'nominal',
37
- scale: { range: explicit },
38
- },
39
- };
40
- applyColorScaleRange(scales, encoding, theme);
41
- expect(ordinal.range()).toEqual(explicit);
42
- expect(ordinal.range()).not.toEqual(theme.colors.categorical);
43
- });
44
-
45
- it('assigns the theme categorical palette when no range is set', () => {
46
- const ordinal = scaleOrdinal<string, string>().domain(['a', 'b', 'c']);
47
- const scales: ResolvedScales = {
48
- color: { scale: ordinal, type: 'ordinal', channel: 'color' },
49
- };
50
- const encoding: Encoding = {
51
- x: { field: 'x', type: 'nominal' },
52
- y: { field: 'y', type: 'quantitative' },
53
- color: { field: 'c', type: 'nominal' },
54
- };
55
- applyColorScaleRange(scales, encoding, theme);
56
- expect(ordinal.range()).toEqual(theme.colors.categorical);
57
- });
58
-
59
- it('uses the first sequential palette endpoints for sequential color scales', () => {
60
- const linear = scaleLinear<string, string>().domain([0, 100]);
61
- const scales: ResolvedScales = {
62
- color: {
63
- scale: linear as unknown as ResolvedScales['color'] extends infer T
64
- ? T extends { scale: infer S }
65
- ? S
66
- : never
67
- : never,
68
- type: 'sequential',
69
- channel: 'color',
70
- } as NonNullable<ResolvedScales['color']>,
71
- };
72
- const encoding: Encoding = {
73
- x: { field: 'x', type: 'quantitative' },
74
- y: { field: 'y', type: 'quantitative' },
75
- color: { field: 'v', type: 'quantitative' },
76
- };
77
- applyColorScaleRange(scales, encoding, theme);
78
- const firstSeq = Object.values(theme.colors.sequential)[0] ?? theme.colors.categorical;
79
- expect(linear.range()).toEqual([firstSeq[0], firstSeq[firstSeq.length - 1]]);
80
- });
81
- });
82
-
83
- // ---------------------------------------------------------------------------
84
- // seriesStrategy
85
- // ---------------------------------------------------------------------------
86
-
87
- describe('applyColorScaleRange seriesStrategy', () => {
88
- function makeOrdinalScales(domain: string[]): {
89
- scales: ResolvedScales;
90
- ordinal: ReturnType<typeof scaleOrdinal<string, string>>;
91
- } {
92
- const ordinal = scaleOrdinal<string, string>().domain(domain);
93
- const scales: ResolvedScales = {
94
- color: { scale: ordinal, type: 'ordinal', channel: 'color' },
95
- };
96
- return { scales, ordinal };
97
- }
98
-
99
- const encoding: Encoding = {
100
- x: { field: 'x', type: 'nominal' },
101
- y: { field: 'y', type: 'quantitative' },
102
- color: { field: 'c', type: 'nominal' },
103
- };
104
-
105
- it('palette strategy assigns full categorical palette', () => {
106
- const { scales, ordinal } = makeOrdinalScales(['a', 'b', 'c']);
107
- applyColorScaleRange(scales, encoding, theme);
108
- expect(ordinal.range()).toEqual(theme.colors.categorical);
109
- });
110
-
111
- it('accent-neutral: single series gets accent only', () => {
112
- const { scales, ordinal } = makeOrdinalScales(['solo']);
113
- applyColorScaleRange(scales, encoding, accentNeutralTheme);
114
- expect(ordinal.range()).toEqual([accentNeutralTheme.colors.categorical[0]]);
115
- });
116
-
117
- it('accent-neutral: 3 series gets accent + neutral grays (darkest first on light surface)', () => {
118
- const { scales, ordinal } = makeOrdinalScales(['a', 'b', 'c']);
119
- applyColorScaleRange(scales, encoding, accentNeutralTheme);
120
- const range = ordinal.range();
121
- expect(range[0]).toBe(accentNeutralTheme.colors.categorical[0]);
122
- expect(range[1]).toBe(ACHROMATIC_RAMP.fgFaint);
123
- expect(range[2]).toBe(ACHROMATIC_RAMP.fgSubtle);
124
- });
125
-
126
- it('accent-neutral: dark surface reverses neutral prominence (brightest first)', () => {
127
- const { scales, ordinal } = makeOrdinalScales(['a', 'b', 'c']);
128
- applyColorScaleRange(scales, encoding, darkAccentNeutralTheme);
129
- const range = ordinal.range();
130
- expect(range[0]).toBe(darkAccentNeutralTheme.colors.categorical[0]);
131
- expect(range[1]).toBe(ACHROMATIC_RAMP.fgMuted);
132
- expect(range[2]).toBe(ACHROMATIC_RAMP.fgSubtle);
133
- });
134
-
135
- it('accent-neutral: 4 series is the last accent-neutral count', () => {
136
- const { scales, ordinal } = makeOrdinalScales(['a', 'b', 'c', 'd']);
137
- applyColorScaleRange(scales, encoding, accentNeutralTheme);
138
- const range = ordinal.range();
139
- expect(range[0]).toBe(accentNeutralTheme.colors.categorical[0]);
140
- expect(range.slice(1)).toEqual([
141
- ACHROMATIC_RAMP.fgFaint,
142
- ACHROMATIC_RAMP.fgSubtle,
143
- ACHROMATIC_RAMP.fgMuted,
144
- ]);
145
- });
146
-
147
- it('accent-neutral: 5 series falls back to full palette', () => {
148
- const { scales, ordinal } = makeOrdinalScales(['a', 'b', 'c', 'd', 'e']);
149
- applyColorScaleRange(scales, encoding, accentNeutralTheme);
150
- expect(ordinal.range()).toEqual(accentNeutralTheme.colors.categorical);
151
- });
152
-
153
- it('accent-neutral: 6 series falls back to full palette', () => {
154
- const { scales, ordinal } = makeOrdinalScales(['a', 'b', 'c', 'd', 'e', 'f']);
155
- applyColorScaleRange(scales, encoding, accentNeutralTheme);
156
- expect(ordinal.range()).toEqual(accentNeutralTheme.colors.categorical);
157
- });
158
- });