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

Fix handles disappearing with invertedAxis #1434

Merged
merged 3 commits into from
Nov 8, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix handles disappearing with invertedAxis
  • Loading branch information
Hypnosphi committed Nov 5, 2019
commit 2d6e14fb066c726c3665fbe4f47b10b60737695c
1 change: 1 addition & 0 deletions demo/components/victory-brush-container-demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ class App extends React.Component {
<VictoryBrushContainer brushDomain={{ x: [2, 4], y: [-2, 2] }} allowDraw={false} />
}
>
<VictoryAxis dependentAxis invertAxis />
<VictoryLegend
x={120}
y={20}
Expand Down
12 changes: 8 additions & 4 deletions packages/victory-brush-container/src/victory-brush-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,16 @@ export const brushContainerMixin = (base) =>
const cursors = this.getCursorPointers(props);
const yProps = { style, width, height: handleWidth, cursor: cursors.yProps };
const xProps = { style, width: handleWidth, height, cursor: cursors.xProps };
const minX = Math.min(x[0], x[1]);
const maxX = Math.max(x[0], x[1]);
const minY = Math.min(y[0], y[1]);
const maxY = Math.max(y[0], y[1]);

const handleProps = {
top: brushDimension !== "x" && assign({ x: x[0], y: y[1] - handleWidth / 2 }, yProps),
bottom: brushDimension !== "x" && assign({ x: x[0], y: y[0] - handleWidth / 2 }, yProps),
left: brushDimension !== "y" && assign({ y: y[1], x: x[0] - handleWidth / 2 }, xProps),
right: brushDimension !== "y" && assign({ y: y[1], x: x[1] - handleWidth / 2 }, xProps)
top: brushDimension !== "x" && assign({ x: minX, y: minY - handleWidth / 2 }, yProps),
bottom: brushDimension !== "x" && assign({ x: minX, y: maxY - handleWidth / 2 }, yProps),
left: brushDimension !== "y" && assign({ y: minY, x: minX - handleWidth / 2 }, xProps),
right: brushDimension !== "y" && assign({ y: minY, x: maxX - handleWidth / 2 }, xProps)
};
const handles = ["top", "bottom", "left", "right"].reduce((memo, curr) => {
memo = handleProps[curr]
Expand Down