question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Assigned fill to selected bar using 'cell' disappears when you move the brush

See original GitHub issue

Hi,

I’m using the bar chart with brush. The selected bar is assigned a different fill using the <Cell/> method but whenever I move zoom in with the brush, the highlighted attribute is no longer in effect. It is literally only effective when I don’t use the brush… If anyone could give me an insight or any kind of explanation on what is going on, I would greatly appreciate it.

This is the line of my <Cell />: {data.map((entry, index) => ( <Cell cursor="pointer" key={cell-${index}} fill={entry.ID === selectedAgglos ? '#c95d47' : 'lightgrey' }/> ))}

Thank you

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8

github_iconTop GitHub Comments

2reactions
shahinlotficommented, Apr 10, 2021

I was having the same issue. Here’s how I solved it, using a custom shape.

  const CustomBar = (props) => {
    const { vibration } = props

    // Don't forget to import Rectangle

    return (
      <Rectangle
        {...props}
        fill={
          vibration <= 25  ? '#FF0000' : '#00FF00'
        }
      />
    )
  }

Usage:

<Bar shape={CustomBar} dataKey="vibration" name="Vibration" />
0reactions
Andyyyyyycommented, Sep 1, 2021

I stumbled across this problem myself, in my case I wanted to have one particular bar in a different color.

I managed to solve this by keeping track of the startIndex and then calculating the correct index when the brush changes. index === activeIndex - startIndex

This might be trivial but could save some time for anyone who also comes across this issue.

https://codesandbox.io/s/recharts-brush-with-custom-cell-fix-4ck18?file=/src/App.tsx

Read more comments on GitHub >

github_iconTop Results From Across the Web

Display or hide the fill handle - Microsoft Support
Learn how to enable or disable the fill handle and cell drag-and-drop in Excel.
Read more >
How to Format Cells to Appear or Disappear with a Checkbox ...
Free Workbooks: https://www.excelvbaisfun.com/links?utm_source=youtube&utm_medium=desc&utm_content=Y0I68OE5Suk Join Excel Ninja Pro: ...
Read more >
ImageJ User Guide
The ImageJ User Guide provides a detailed overview of ImageJ (and inherently Fiji), the standard in scientific image analysis (see XXVI Focus on...
Read more >
Adjustment and fill layers in Photoshop - Adobe Support
Link With Layer moves the pattern along with the layer as the layer moves. When selected, you can drag in the image to...
Read more >
Excel hints and tips - STL Training
Use Control + D to fill a cell with the data from an adjacent cell. ... Go to the sheet where you want...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found