Reactjs 如何使用功能组件在vx反应库中创建工具提示?

Reactjs 如何使用功能组件在vx反应库中创建工具提示?,reactjs,d3.js,Reactjs,D3.js,我正在vx反应库中绘制图表。他们有一个工具提示的演示,但他们使用类组件,我使用的是功能组件。我不确定如何在代码中实现此工具提示。这是我的图表组件 const x = d => d.name; const y = d => d.stat; const xMax = width-80; const yMax = height-80; let dataMax = max(data, d => d.stat); let xScale = scaleBand({ rangeR

我正在vx反应库中绘制图表。他们有一个工具提示的演示,但他们使用类组件,我使用的是功能组件。我不确定如何在代码中实现此工具提示。这是我的图表组件

const x = d => d.name;
const y = d => d.stat;
const xMax = width-80;
const yMax = height-80;


let dataMax = max(data, d => d.stat);
let xScale = scaleBand({
    rangeRound: [0,xMax],
    padding: 0.1,
    domain: data.map(d=>d.name)
});
let yScale = scaleLinear({
    rangeRound: [yMax, 0],
    domain: [0, (Math.round(dataMax*2) /2)]
});

const BarChart = props => {

    let content = (
        <svg width={width} height={height}>
            <Group top={25} left={55}>
                <AxisLeft scale={yScale} numTicks={10} label={statType} tickFormat={alFormat} />
                <GridRows
                    scale={yScale}
                    width={xMax}
                    stroke={"black"}
                />
                {data.map((d,i) => {
                    const label = x(d);
                    const barWidth = xScale.bandwidth();
                    const barHeight = yMax-yScale(y(d));
                    const barX = xScale(label);
                    const barY = yMax-barHeight;
                    const barColor = (i===data.length-1) ? leagueColor : barColors[i];

                    return (
                        <Bar
                            key={`bar-${label}`}
                            x={barX}
                            y={barY}
                            width={barWidth}
                            height={barHeight}
                            fill={barColor}
                            bottom={0}
                            onMouseOver={event => console.log(event)}
                        />
                    );
                })}
                <AxisBottom
                    scale={xScale}
                    label="Players"
                    labelOffset={15}
                    top={yMax}
                />
            </Group>
        </svg>
    );
    return content;
}

export default BarChart
const x=d=>d.name;
常数y=d=>d.stat;
常数xMax=宽度-80;
const yMax=高度-80;
设dataMax=max(data,d=>d.stat);
设xScale=scaleBand({
rangeRound:[0,xMax],
填充:0.1,
域:data.map(d=>d.name)
});
让yScale=scaleLinear({
rangeRound:[yMax,0],
域:[0,(数学圆整(dataMax*2)/2)]
});
常量条形图=道具=>{
让内容=(
{data.map((d,i)=>{
常数标签=x(d);
const barWidth=xScale.bandwidth();
常数杆高=yMax yScale(y(d));
常数barX=xScale(标签);
常数barY=yMax barHeight;
const barColor=(i==data.length-1)?leagueColor:barColors[i];
返回(
console.log(事件)}
/>
);
})}
);
返回内容;
}
导出默认条形图