Rechart 工具提示问题:显示背景元素
Rechart tooltip issue: shows background elements
我有 3 个条形图,一张一张。
我必须显示自定义工具提示,但当它的高度高于条形图时它会显示背景内容。
这是自定义工具提示组件
const CustomTooltip = ({ active, payload, label }: any) => {
return (
<div className="custom-tooltip">
<p className="label">{`${label} : ${payload[0].value}`}</p>
<p className="intro">{getIntroOfPage(label)}</p>
<p className="desc">Anything you want can be displayed here.</p>
<p className="desc">Anything you want can be displayed here.</p>
<p className="desc">Anything you want can be displayed here.</p>
<p className="desc">Anything you want can be displayed here.</p>
<p className="desc">Anything you want can be displayed here.</p>
<p className="desc">Anything you want can be displayed here.</p>
<p className="desc">Anything you want can be displayed here.</p>
<p className="desc">Anything you want can be displayed here.</p>
<p className="desc">Anything you want can be displayed here.</p>
<p className="desc">Anything you want can be displayed here.</p>
<p className="desc">Anything you want can be displayed here.</p>
<p className="desc">Anything you want can be displayed here.</p>
</div>
);
};
请参阅下面的 sandbox 进行演示。
请指导如何解决这个问题。
根据这个 github 问题,您可以在工具提示中添加 zIndex
,如下所示:-
<Tooltip content={<CustomTooltip />} wrapperStyle={{ zIndex: 1000 }}/>
我有 3 个条形图,一张一张。 我必须显示自定义工具提示,但当它的高度高于条形图时它会显示背景内容。 这是自定义工具提示组件
const CustomTooltip = ({ active, payload, label }: any) => {
return (
<div className="custom-tooltip">
<p className="label">{`${label} : ${payload[0].value}`}</p>
<p className="intro">{getIntroOfPage(label)}</p>
<p className="desc">Anything you want can be displayed here.</p>
<p className="desc">Anything you want can be displayed here.</p>
<p className="desc">Anything you want can be displayed here.</p>
<p className="desc">Anything you want can be displayed here.</p>
<p className="desc">Anything you want can be displayed here.</p>
<p className="desc">Anything you want can be displayed here.</p>
<p className="desc">Anything you want can be displayed here.</p>
<p className="desc">Anything you want can be displayed here.</p>
<p className="desc">Anything you want can be displayed here.</p>
<p className="desc">Anything you want can be displayed here.</p>
<p className="desc">Anything you want can be displayed here.</p>
<p className="desc">Anything you want can be displayed here.</p>
</div>
);
};
请参阅下面的 sandbox 进行演示。 请指导如何解决这个问题。
根据这个 github 问题,您可以在工具提示中添加 zIndex
,如下所示:-
<Tooltip content={<CustomTooltip />} wrapperStyle={{ zIndex: 1000 }}/>