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

add renderGroup method to override in native #480

Merged
merged 1 commit into from
Jun 15, 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
20 changes: 11 additions & 9 deletions src/components/victory-polar-axis/victory-polar-axis.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,6 @@ class VictoryPolarAxis extends React.Component {
"tickComponent", "tickLabelComponent", "gridComponent", "circularGridComponent"
];

getTransform(props) {
const groupComponentProps = props.groupComponent.props || {};
const origin = Helpers.getPolarOrigin(props);
const transform = `translate(${origin.x}, ${origin.y})`;
return groupComponentProps.transform || transform;
}

renderAxisLine(props) {
const { dependentAxis } = props;
const axisComponent = dependentAxis ? props.axisComponent : props.circularAxisComponent;
Expand All @@ -112,7 +105,7 @@ class VictoryPolarAxis extends React.Component {
}

renderAxis(props) {
const { tickComponent, tickLabelComponent, groupComponent } = props;
const { tickComponent, tickLabelComponent } = props;
const axisType = props.dependentAxis ? "radial" : "angular";
const gridComponent = axisType === "radial" ? props.circularGridComponent : props.gridComponent;
const tickComponents = this.dataKeys.map((key, index) => {
Expand Down Expand Up @@ -140,7 +133,16 @@ class VictoryPolarAxis extends React.Component {
const children = [
axis, axisLabel, ...tickComponents, ...gridComponents, ...tickLabelComponents
];
return React.cloneElement(groupComponent, { transform: this.getTransform(props) }, children);
return this.renderGroup(props, children);
}

// Overridden in victory-native
renderGroup(props, children) {
const { groupComponent } = props;
const groupComponentProps = groupComponent.props || {};
const origin = Helpers.getPolarOrigin(props);
const transform = groupComponentProps.transform || `translate(${origin.x}, ${origin.y})`;
return React.cloneElement(groupComponent, { transform }, children);
}

shouldAnimate() {
Expand Down