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

don't downsample stacked groups #1077

Merged
merged 1 commit into from
Aug 5, 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
5 changes: 4 additions & 1 deletion demo/components/debug-demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { VictoryScatter } from "../../packages/victory-scatter/src/index";
import { VictoryPortal } from "../../packages/victory-core/src/index";
import { VictorySelectionContainer } from "../../packages/victory-selection-container/src/index";
import { VictoryVoronoiContainer } from "../../packages/victory-voronoi-container/src/index";
import { VictoryZoomContainer } from "../../packages/victory-zoom-container/src/index";

class App extends React.Component {

Expand All @@ -24,7 +25,9 @@ class App extends React.Component {
const chartStyle = { parent: { border: "1px solid #ccc", margin: "2%", maxWidth: "40%" } };
return (
<div style={containerStyle}>
<VictoryChart style={chartStyle} >
<VictoryChart style={chartStyle}
containerComponent={<VictoryZoomContainer/>}
>
<VictoryStack colorScale="warm">
<VictoryGroup
data={[
Expand Down
15 changes: 7 additions & 8 deletions packages/victory-zoom-container/src/victory-zoom-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ export const zoomContainerMixin = (base) => class VictoryZoomContainer extends b

modifyChildren(props) {
const childComponents = React.Children.toArray(props.children);
// eslint-disable-next-line max-statements
return childComponents.map((child) => {
const role = child.type && child.type.role;
const isDataComponent = Data.isDataComponent(child);
const { currentDomain, zoomActive, allowZoom } = props;
const originalDomain = defaults({}, props.originalDomain, props.domain);
Expand All @@ -181,14 +183,11 @@ export const zoomContainerMixin = (base) => class VictoryZoomContainer extends b
[props.zoomDimension]: newDomain[props.zoomDimension]
};
}
return React.cloneElement(
child,
defaults({
domain: newDomain,
data: isDataComponent ?
undefined : this.downsampleZoomData(props, child, newDomain)
}, child.props)
);
// don't downsample stacked data
const newProps = isDataComponent && role !== "stack" ?
{ domain: newDomain, data: this.downsampleZoomData(props, child, newDomain) } :
{ domain: newDomain };
return React.cloneElement(child, defaults(newProps, child.props));
});
}

Expand Down