简体   繁体   English

有没有办法在 Hover 的条形图中更改单元格的填充? - 图表

[英]Is there a way to change the fill of a Cell in a Bar Chart on Hover? - Recharts

I currently render the chart like this:我目前这样渲染图表:

<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>

Is there a way to change the cell/bar color, not cursor when you hover the bar?当你 hover 酒吧时,有没有办法改变单元格/栏颜色,而不是 cursor?

I used this example and changed the onClick to an onMouseOver event.我使用了这个示例并将 onClick 更改为 onMouseOver 事件。 Works fine.工作正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM