Skip to content

Commit 62a1585

Browse files
committed
fix: Resolve groupStackData type errors from updated d3-shape types (fall back to d3's default order/offset).
1 parent ab36488 commit 62a1585

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

  • packages/layerchart/src/lib/utils

packages/layerchart/src/lib/utils/stack.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { flatGroup, group, max, rollup, sum } from 'd3-array';
2-
import { stack } from 'd3-shape';
2+
import { stack, stackOffsetNone, stackOrderNone } from 'd3-shape';
33
import { pivotWider } from './pivot.js';
44

55
type OrderType = typeof import('d3-shape').stackOrderNone; // all orders share the same API
@@ -37,12 +37,11 @@ export function groupStackData<TData>(
3737
const stackKeys: Array<any> = [
3838
...new Set(groupData.map((d: any) => d[options.stackBy ?? ''])),
3939
];
40-
// @ts-expect-error
4140
const stackData = stack()
4241
.keys(stackKeys)
4342
.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);
4645

4746
return stackData.flatMap((series) => {
4847
return series.flatMap((s) => {
@@ -74,12 +73,11 @@ export function groupStackData<TData>(
7473

7574
// @ts-expect-error
7675
const stackKeys: Array<any> = [...new Set(data.map((d) => d[options.stackBy ?? '']))];
77-
// @ts-expect-error
7876
const stackData = stack()
7977
.keys(stackKeys)
8078
.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);
8381

8482
const result = stackData.flatMap((series) => {
8583
return series.flatMap((s) => {

0 commit comments

Comments
 (0)