Skip to content
This repository has been archived by the owner on Feb 19, 2022. It is now read-only.

use Wrapper.getDomainFromChildren in zoom helpers #476

Merged
merged 1 commit into from
Jun 3, 2017
Merged
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
17 changes: 14 additions & 3 deletions src/components/containers/zoom-helpers.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/*eslint no-magic-numbers: ["error", { "ignore": [-1, 0, 1, 2, 1000] }]*/
import { Children } from "react";
import { Selection, Collection } from "victory-core";
import { throttle, isFunction, defaults, isEqual } from "lodash";
import { attachId } from "../../helpers/event-handlers.js";
import Wrapper from "../../helpers/wrapper";

const Helpers = {

Expand Down Expand Up @@ -141,9 +143,18 @@ const Helpers = {
},

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

onMouseDown(evt) {
Expand Down