What problem does this feature solve?
I'm currently working on a chart that starts with multiple bars being visible, that allows users to toggle them off so they can focus on a smaller set of datapoints. Recharts allows this toggling to be done very easily with the hide prop, but I've noticed that the domain of the axis will always adapt to fit only the currently displayed data. This negatively affects the user's ability to make comparisons when toggling datapoints.
Minimal codesandbox example here
It would be great to include a way to set the domain of an axis as static, i.e. always including data even if it's hidden. I've made local changes to generateCategoricalChart.tsx and can verify that the behaviour is easy to implement by removing the !item.props.hide check when filtering the graphicalItems.
If this feature is one you would consider implementing, I'd like to agree on the right API that would update those filter predicates, and I'd be happy to open a pull request with the implementation.
What does the proposed API look like?
I have two ideas for this API. My preference would be for this first approach, as I feel it's the simplest:
<YAxis includeHidden /> // maybe `staticDomain` also works as a prop name?
We could also have a boolean flag on the graphical items themselves, so we can still ignore some items if we want:
<Bar onDomain hide={booleanState} /> // by default, `onDomain`'s value would be `!hide`
What problem does this feature solve?
I'm currently working on a chart that starts with multiple bars being visible, that allows users to toggle them off so they can focus on a smaller set of datapoints. Recharts allows this toggling to be done very easily with the
hideprop, but I've noticed that the domain of the axis will always adapt to fit only the currently displayed data. This negatively affects the user's ability to make comparisons when toggling datapoints.Minimal codesandbox example here
It would be great to include a way to set the domain of an axis as static, i.e. always including data even if it's hidden. I've made local changes to
generateCategoricalChart.tsxand can verify that the behaviour is easy to implement by removing the!item.props.hidecheck when filtering thegraphicalItems.If this feature is one you would consider implementing, I'd like to agree on the right API that would update those filter predicates, and I'd be happy to open a pull request with the implementation.
What does the proposed API look like?
I have two ideas for this API. My preference would be for this first approach, as I feel it's the simplest:
We could also have a boolean flag on the graphical items themselves, so we can still ignore some items if we want: