Skip to content

Commit 797be82

Browse files
committed
docs: 示例增加点击事件
1 parent 1c68d5b commit 797be82

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

docs/demos/config/demo/Sankey/basic.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,15 @@ function Example() {
150150
nodeHeight(node) {
151151
return node.depth === 0 ? 160 : 40;
152152
},
153+
node: {
154+
style: {
155+
// 扩大 node 点击热区
156+
boundsPadding: [0, 20, 0, 20],
157+
},
158+
},
153159
label: {
154160
visible: true,
155-
offset: 8,
161+
offset: -12,
156162
formatMethod(_, datum) {
157163
return `${datum?.name} ${datum?.total?.toLocaleString()}`;
158164
},
@@ -311,15 +317,24 @@ function Example() {
311317
closeAutoHover();
312318
};
313319
},
320+
// eslint-disable-next-line react-hooks/exhaustive-deps
314321
[],
315322
);
316323

324+
const handleClick: SankeyProps['onClick'] = (e) => {
325+
if (e.node?.type === 'rect') {
326+
// eslint-disable-next-line no-console
327+
console.log(e);
328+
}
329+
};
330+
317331
return (
318332
<>
319333
<Sankey
320334
{...spec}
321335
skipFunctionDiff
322336
ref={chartRef}
337+
onClick={handleClick}
323338
/>
324339
<Tooltip style={tooltipStyles} />
325340
</>

0 commit comments

Comments
 (0)