WiseSwift
WiseSwift

Reputation: 35

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?

Upvotes: 0

Views: 3901

Answers (1)

WiseSwift
WiseSwift

Reputation: 35

I used this example and changed the onClick to an onMouseOver event. Works fine.

Upvotes: 2

Related Questions