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

Refactor VictoryPie and Slice so that slices can be more granularly controlled #1136

Closed
boygirl opened this issue Oct 5, 2018 · 2 comments · Fixed by #1177
Closed

Refactor VictoryPie and Slice so that slices can be more granularly controlled #1136

boygirl opened this issue Oct 5, 2018 · 2 comments · Fixed by #1177

Comments

@boygirl
Copy link
Contributor

boygirl commented Oct 5, 2018

Currently it is not possible to define radius, innerRadius or labelRadius for individual pie slices because the pathFunction that is provided to each slice already has those values pre-defined. Instead, we should provide a partially applied path function that gets calculated for each slice. We should also let radius, innerRadius and labelRadius be defined as functions of data. New radius, innerRadius props should be added to Slice, and labelRadius should be added to VictoryLabel

@boygirl
Copy link
Contributor Author

boygirl commented Nov 9, 2018

Update:

The Slice primitive used by VictoryPie now takes radius, cornerRadius, innerRadius, padAngle, sliceStartAngle and sliceEndAngle props. Each of these props may be given as number or a function of datum and active. padAngle, radius, cornerRadius and innerRadius will be passed down from props on VictoryBar, but sliceStartAngle and sliceEndAngle must be defined directly on the Slice instance, These values should be given in degrees. To make these values easier to use as functional props, startAngle, endAngle, and padAngle (in degrees) are added to each datum passed into Slice. (If your data already has these properties they will not be overridden)

Breaking Changes
The Slice primitive will still take a pathFunction prop, but this prop will no longer be provided by VictoryPie. This will not be a breaking change for most users. This will only affect users who were wrapping the Slice component and making use of the pathFunction prop provided by VictoryPie Users who were providing their own pathFunction prop to Slice should not be effected.

@boygirl
Copy link
Contributor Author

boygirl commented Nov 9, 2018

Example:

<VictoryPie
  theme={VictoryTheme.material}
  events={[{
    target: "data",
    eventHandlers: {
      onMouseOver: () => ({
        mutation: (props) => ({
          radius: 135,
          sliceStartAngle: props.datum.startAngle + 5,
          sliceEndAngle: props.datum.endAngle - 5
        })
      }),
      onMouseOut: () => ({
        mutation: () => null
      })
    }
  }]}
/>

pie-events

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant