0

我目前这样渲染图表:

<BarChart width={868} height={40} data={data}
                    margin={{top:0, bottom: 10, left:0, right:0}} barSize={5}>
            <Tooltip
              labelStyle={{ textAlign: 'left' }}
               cursor={{fill: "blue"}}
      position={{ x: this.state.mouseX - 20, y:-5 }}
            />
            <Bar dataKey="blocks"
                 onMouseOver={e => this.getMouseX(e)} >
              {
                data.map((entry, index) => {

                  const result = entry.result >  4  ?  TRASH : NO_TRASH;
                  return <Cell fill={result} key={index}/>;
                })
              }
            </Bar>
          </BarChart>

有没有办法在悬停栏时更改单元格/栏的颜色,而不是光标?

4

1 回答 1

1

我使用了这个示例并将 onClick 更改为 onMouseOver 事件。工作正常。

于 2019-10-09T15:24:51.187 回答