|
1 | 1 | import { flatGroup, group, max, rollup, sum } from 'd3-array'; |
2 | | -import { stack } from 'd3-shape'; |
| 2 | +import { stack, stackOffsetNone, stackOrderNone } from 'd3-shape'; |
3 | 3 | import { pivotWider } from './pivot.js'; |
4 | 4 |
|
5 | 5 | type OrderType = typeof import('d3-shape').stackOrderNone; // all orders share the same API |
@@ -37,12 +37,11 @@ export function groupStackData<TData>( |
37 | 37 | const stackKeys: Array<any> = [ |
38 | 38 | ...new Set(groupData.map((d: any) => d[options.stackBy ?? ''])), |
39 | 39 | ]; |
40 | | - // @ts-expect-error |
41 | 40 | const stackData = stack() |
42 | 41 | .keys(stackKeys) |
43 | 42 | .value((d: any, key: any) => d[key] ?? 0) |
44 | | - .order(options.order) |
45 | | - .offset(options.offset)(pivotData); |
| 43 | + .order(options.order ?? stackOrderNone) |
| 44 | + .offset(options.offset ?? stackOffsetNone)(pivotData); |
46 | 45 |
|
47 | 46 | return stackData.flatMap((series) => { |
48 | 47 | return series.flatMap((s) => { |
@@ -74,12 +73,11 @@ export function groupStackData<TData>( |
74 | 73 |
|
75 | 74 | // @ts-expect-error |
76 | 75 | const stackKeys: Array<any> = [...new Set(data.map((d) => d[options.stackBy ?? '']))]; |
77 | | - // @ts-expect-error |
78 | 76 | const stackData = stack() |
79 | 77 | .keys(stackKeys) |
80 | 78 | .value((d: any, key: any) => d[key] ?? 0) |
81 | | - .order(options.order) |
82 | | - .offset(options.offset)(pivotData); |
| 79 | + .order(options.order ?? stackOrderNone) |
| 80 | + .offset(options.offset ?? stackOffsetNone)(pivotData); |
83 | 81 |
|
84 | 82 | const result = stackData.flatMap((series) => { |
85 | 83 | return series.flatMap((s) => { |
|
0 commit comments