Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'active' variable in style for VictoryBar no longer works as expected #2861

Open
2 tasks done
nateguy opened this issue Apr 22, 2024 · 2 comments
Open
2 tasks done

'active' variable in style for VictoryBar no longer works as expected #2861

nateguy opened this issue Apr 22, 2024 · 2 comments
Labels
Type: Bug 🐛 Oh no! A bug or unintentional behavior

Comments

@nateguy
Copy link

nateguy commented Apr 22, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Code of Conduct

  • I agree to follow this project's Code of Conduct

Victory version

37.0.2

Code Sandbox link

No response

Bug report

<VictoryBar
   key={1}
   barRatio={1}
   style={{
      data: {
         fill: ({active}) =>
            active ? '#3A7DC0' : '#CCD2D9',
         },
      }}
   data={chartData.transactionCountData}
   y={(datum) => datum.y}
/>

Steps to reproduce

1. Open screen with VictoryBar chart
2. Click on one of the bars

Expected behavior

The selected bar color should change to #3A7DC0

Actual behavior

The selected bar no longer changes color

Environment

- Device:
- OS:
- Node:
- npm:
@nateguy nateguy added the Type: Bug 🐛 Oh no! A bug or unintentional behavior label Apr 22, 2024
@vinitsood
Copy link

I noticed it too. This worked in 36.9.2

@carbonrobot
Copy link
Contributor

The active property is only available when a component is wrapped in a selection container like VictorySelectionContainer, VictoryBrushContainer, etc. Components by default do not have events attached to them, so for a simple Bar chart you would do something like this.

Here is an example codesandbox of using events to target data elements. Relevant code pasted below.

<VictoryBar
  style={{
    data: {
      fill: (props) => (props.active ? "#3A7DC0" : "#CCD2D9"),
    },
  }}
  events={[
    {
      target: "data",
      eventHandlers: {
        onMouseOver: () => {
          return [{ target: "data", mutation: () => ({ active: true }) }];
        },
        onMouseOut: () => {
          return [{ target: "data", mutation: () => ({ active: false }) }];
        },
      },
    },
  ]}
/>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug 🐛 Oh no! A bug or unintentional behavior
Projects
None yet
Development

No branches or pull requests

3 participants