Skip to content

Changing fill or opacity of specific bar in RadialBar chart #3655

Answered by Yilun-Sun
idjuradj asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @idjuradj , thanks for the question, that is an interesting one!

I believe this is exactly what you want -> Codesandbox

The solution is very simple, use a state to keep the selected radial bar name, and use Cell as a child of RadialBar to get control of the selected radial bar opacity.

<RadialBar
  background
  dataKey="uv"
>
  {data.map((entry, index) => (
    <Cell
      key={`cell-${index}`}
      opacity={selectedRadialBar === entry.name ? 1 : 0.1}
    />
  ))}
</RadialBar>
<Legend
  iconSize={10}
  width={120}
  height={140}
  layout="vertical"
  verticalAlign="middle"
  wrapperStyle={style}
  content={({ payload }) => (
    <ul>
      {payload?.map((entry, index) => {
        re…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@ckifer
Comment options

Answer selected by ckifer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants