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

Bug/horizontal chart zoom #1096

Merged
merged 4 commits into from
Aug 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
14 changes: 13 additions & 1 deletion demo/components/victory-zoom-container-demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { VictoryStack } from "../../packages/victory-stack/src/index";
import { VictoryGroup } from "../../packages/victory-group/src/index";
import { VictoryAxis } from "../../packages/victory-axis/src/index";
import { VictoryArea } from "../../packages/victory-area/src/index";
import { VictoryBar } from "../../packages/victory-bar/src/index";
import { VictoryLine } from "../../packages/victory-line/src/index";
import { VictoryScatter } from "../../packages/victory-scatter/src/index";
import { VictoryZoomContainer } from "../../packages/victory-zoom-container/src/index";
Expand Down Expand Up @@ -417,7 +418,18 @@ export default class App extends React.Component {
</VictoryStack>
<VictoryAxis dependentAxis/>
</VictoryChart>

<VictoryChart
style={{ parent: parentStyle }}
containerComponent={<VictoryZoomContainer/>}
>
<VictoryBar horizontal
style={{ data: { stroke: "#333", fill: "#888", opacity: 0.4 } }}
data={this.state.data}
x="a" y="b"
/>
<VictoryAxis/>
<VictoryAxis dependentAxis/>
</VictoryChart>

</div>
);
Expand Down
8 changes: 5 additions & 3 deletions packages/victory-zoom-container/src/zoom-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,17 @@ const RawZoomHelpers = {
},

getDomain(props) {
const { originalDomain, domain, children, zoomDimension } = props;
const { originalDomain, domain, children, zoomDimension, horizontal } = props;
const x = horizontal ? "y" : "x";
const y = horizontal ? "x" : "y";
const childComponents = Children.toArray(children);
let childrenDomain = {};
if (childComponents.length) {
childrenDomain = zoomDimension ?
{ [zoomDimension]: Wrapper.getDomainFromChildren(props, zoomDimension, childComponents) }
: ({
x: Wrapper.getDomainFromChildren(props, "x", childComponents),
y: Wrapper.getDomainFromChildren(props, "y", childComponents)
x: Wrapper.getDomainFromChildren(props, x, childComponents),
y: Wrapper.getDomainFromChildren(props, y, childComponents)
});
}
return defaults({}, childrenDomain, originalDomain, domain);
Expand Down