Skip to content

Commit 057b654

Browse files
committed
fix: funnel with empty data, #2616
1 parent dd23da5 commit 057b654

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

__tests__/bugs/issue-2616-spec.ts

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Funnel } from '../../src';
2+
import { createDiv } from '../utils/dom';
3+
4+
describe('#2616', () => {
5+
it('funel data is empty', () => {
6+
const funnelPlot = new Funnel(createDiv(), {
7+
data: [],
8+
xField: 'stage',
9+
yField: 'number',
10+
legend: false,
11+
});
12+
13+
expect(() => {
14+
funnelPlot.render();
15+
funnelPlot.destroy();
16+
}).not.toThrow();
17+
});
18+
});

src/plots/funnel/geometries/common.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export function transformData(
1616
): FunnelOptions['data'] {
1717
let formatData = [];
1818
const { yField, maxSize, minSize } = options;
19-
const maxYFieldValue = maxBy(originData, yField)[yField];
19+
const maxYFieldValue = get(maxBy(originData, yField), [yField]);
2020
const max = isNumber(maxSize) ? maxSize : 1;
2121
const min = isNumber(minSize) ? minSize : 0;
2222

0 commit comments

Comments
 (0)