Skip to content

Commit d32d926

Browse files
committed
docs: 添加隐藏 label 示例
1 parent 9095cf2 commit d32d926

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ function Example() {
131131
const timeoutRef = React.useRef<NodeJS.Timeout>();
132132
const intervalRef = React.useRef<NodeJS.Timeout | null>(null);
133133
const [tooltipStyles, setTooltipStyles] = React.useState<React.CSSProperties>({});
134+
const [hideLabel, setHideLabel] = React.useState(false);
134135

135136
const spec: SankeyProps = {
136137
height: 600,
@@ -174,6 +175,8 @@ function Example() {
174175
visible: true,
175176
offset: -12,
176177
formatMethod(_, datum) {
178+
if (hideLabel)
179+
return ``;
177180
return `${datum?.name} ${datum?.total?.toLocaleString()}`;
178181
},
179182
style: {
@@ -335,6 +338,16 @@ function Example() {
335338
[],
336339
);
337340

341+
React.useEffect(() => {
342+
const timeout = setTimeout(() => {
343+
setHideLabel(true);
344+
}, 5 * 1000);
345+
346+
return () => {
347+
timeout && clearTimeout(timeout);
348+
};
349+
}, []);
350+
338351
const handleClick: SankeyProps['onClick'] = (e) => {
339352
if (e.node?.type === 'rect') {
340353
const { datum } = e;
@@ -375,7 +388,6 @@ function Example() {
375388
<>
376389
<Sankey
377390
{...spec}
378-
skipFunctionDiff
379391
ref={chartRef}
380392
onClick={handleClick}
381393
onDblClick={handleDblClick}

0 commit comments

Comments
 (0)