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

Commit

Permalink
safety commit: transform on primitives experiment
Browse files Browse the repository at this point in the history
  • Loading branch information
boygirl committed May 27, 2017
1 parent 53e082c commit 691eca0
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 28 deletions.
2 changes: 1 addition & 1 deletion demo/components/victory-polar-chart-demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ class App extends React.Component {

<VictoryPolarChart
theme={VictoryTheme.material}
domain={{ x: [0, 360] }}
domain={{ x: [0, 360], y: [0, 65] }}
style={chartStyle}
>
<VictoryPolarAxis dependentAxis
Expand Down
8 changes: 4 additions & 4 deletions src/components/victory-area/helper-methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ export default {
const { scale, style, data, domain } = calculatedValues;
const {
standalone, interpolation, events, sharedEvents, width, height, groupComponent, theme,
polar, padding
polar, padding, origin
} = props;

const initialChildProps = {
parent: {
style: style.parent, width, height, scale, data, domain, standalone, theme, polar, padding
style: style.parent, width, height, scale, data,
domain, standalone, theme, polar, padding, origin
},
all: {
data: { polar, scale, data, interpolation, groupComponent, style: style.data }
data: { polar, scale, data, interpolation, groupComponent, style: style.data, origin }
}
};
return data.reduce((childProps, datum, index) => {
Expand Down
8 changes: 5 additions & 3 deletions src/components/victory-bar/helper-methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,19 @@ export default {
getBaseProps(props, fallbackProps) {
props = Helpers.modifyProps(props, fallbackProps, "bar");
const { style, data, scale, domain } = this.getCalculatedValues(props);
const { horizontal, width, height, padding, standalone, theme, polar } = props;
const { horizontal, width, height, padding, standalone, theme, polar, origin } = props;
const initialChildProps = { parent: {
domain, scale, width, height, data, standalone, theme, polar, padding, style: style.parent
domain, scale, width, height, data, standalone,
theme, polar, origin, padding, style: style.parent
} };

return data.reduce((childProps, datum, index) => {
const eventKey = datum.eventKey || index;
const { x, y, y0, x0 } = this.getBarPosition(props, datum, scale);
const barStyle = this.getBarStyle(datum, style.data);
const dataProps = {
data, datum, horizontal, index, padding, polar, scale, style: barStyle, width, height, x, y, y0, x0
data, datum, horizontal, index, padding, polar, origin,
scale, style: barStyle, width, height, x, y, y0, x0
};

childProps[eventKey] = {
Expand Down
7 changes: 4 additions & 3 deletions src/components/victory-candlestick/helper-methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ export default {
props = Helpers.modifyProps(props, fallbackProps, "candlestick");
const calculatedValues = this.getCalculatedValues(props);
const { data, style, scale, domain } = calculatedValues;
const { groupComponent, width, height, padding, standalone, theme, polar } = props;
const { groupComponent, width, height, padding, standalone, theme, polar, origin } = props;
const initialChildProps = { parent: {
domain, scale, width, height, data, standalone, theme, polar, style: style.parent, padding
domain, scale, width, height, data, standalone, theme,
polar, style: style.parent, padding, origin
} };

return data.reduce((childProps, datum, index) => {
Expand All @@ -22,7 +23,7 @@ export default {
const dataStyle = this.getDataStyles(datum, style.data, props);
const dataProps = {
x, y, y1, y2, candleHeight, scale, data, datum, groupComponent,
index, style: dataStyle, padding, width
index, style: dataStyle, padding, width, origin
};

childProps[eventKey] = {
Expand Down
7 changes: 5 additions & 2 deletions src/components/victory-errorbar/helper-methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ export default {
getBaseProps(props, fallbackProps) {
props = Helpers.modifyProps(props, fallbackProps, "errorbar");
const { data, style, scale, domain } = this.getCalculatedValues(props, fallbackProps);
const { groupComponent, height, width, borderWidth, standalone, theme, polar, padding } = props;
const {
groupComponent, height, width, borderWidth, standalone, theme, polar, padding, origin
} = props;
const initialChildProps = { parent: {
domain, style: style.parent, scale, data, height, width, standalone, theme, polar, padding
domain, style: style.parent, scale, data, height, width, standalone, theme,
polar, padding, origin
} };

return data.reduce((childProps, datum, index) => {
Expand Down
4 changes: 2 additions & 2 deletions src/components/victory-group/victory-group.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export default class VictoryGroup extends React.Component {
// the old ones were bad
getNewChildren(props, childComponents, calculatedProps) {
const { datasets, horizontal, domain } = calculatedProps;
const { theme, labelComponent, polar } = props;
const { theme, labelComponent, polar, origin } = props;
const childProps = this.getChildProps(props, calculatedProps);
const getAnimationProps = Wrapper.getAnimationProps.bind(this);

Expand All @@ -188,7 +188,7 @@ export default class VictoryGroup extends React.Component {
child.props.style : Wrapper.getChildStyle(child, index, calculatedProps);
const labels = props.labels ? this.getLabels(props, datasets, index) : child.props.labels;
return React.cloneElement(child, assign({
domain, labels, style, theme, horizontal, polar,
domain, labels, style, theme, horizontal, polar, origin,
data: this.getDataWithOffset(props, datasets[index], xOffset),
animate: getAnimationProps(props, child, index),
colorScale: this.getColorScale(props, child),
Expand Down
4 changes: 2 additions & 2 deletions src/components/victory-line/helper-methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ export default {
const { scale, data, domain, style } = calculatedValues;
const {
interpolation, width, height, events, sharedEvents, standalone, groupComponent, theme,
polar, padding
polar, padding, origin
} = props;
const initialChildProps = {
parent: {
style: style.parent, scale, data, height, width, domain, standalone, polar, padding
},
all: { data:
{ polar, scale, data, interpolation, groupComponent, theme, style: style.data }
{ polar, origin, scale, data, interpolation, groupComponent, theme, style: style.data }
}
};
return data.reduce((childProps, datum, index) => {
Expand Down
8 changes: 4 additions & 4 deletions src/components/victory-polar-chart/victory-polar-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export default class VictoryChart extends React.Component {
}

getAxisProps(child, props, calculatedProps) {
const { domain, scale, originSign, horizontal } = calculatedProps;
const { domain, scale, originSign, horizontal, origin } = calculatedProps;
const axis = child.type.getAxis(child.props, horizontal);
const axisOffset = ChartHelpers.getAxisOffset(props, calculatedProps);
const tickValues = ChartHelpers.getTicks(calculatedProps, axis, child);
Expand Down Expand Up @@ -211,7 +211,6 @@ export default class VictoryChart extends React.Component {
return childComponents.map((child, index) => {
const style = defaults({}, child.props.style, { parent: baseStyle });
const childProps = this.getChildProps(child, props, calculatedProps);
const transform = `translate(${origin.x}, ${origin.y})`;
const newProps = defaults({
animate: getAnimationProps(props, child, index),
height: props.height,
Expand All @@ -221,7 +220,7 @@ export default class VictoryChart extends React.Component {
theme: props.theme,
standalone: false,
polar: true,
groupComponent: React.cloneElement(child.props.groupComponent, { transform }),
origin,
style
}, childProps);

Expand All @@ -237,8 +236,9 @@ export default class VictoryChart extends React.Component {
getContainerProps(props, calculatedProps) {
const { width, height, standalone, theme } = props;
const { domain, scale, style } = calculatedProps;
const origin = Helpers.getOrigin(props);
return {
domain, scale, width, height, standalone, theme, style: style.parent
domain, scale, width, height, standalone, theme, style: style.parent, origin
};
}

Expand Down
7 changes: 4 additions & 3 deletions src/components/victory-scatter/helper-methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ export default {
getBaseProps(props, fallbackProps) {
props = Helpers.modifyProps(props, fallbackProps, "scatter");
const calculatedValues = this.getCalculatedValues(props);
const { height, width, standalone, theme, polar, padding } = props;
const { height, width, standalone, theme, polar, padding, origin } = props;
const { data, style, scale, domain } = calculatedValues;
const initialChildProps = { parent: {
style: style.parent, scale, domain, data, height, width, standalone, theme, polar, padding
style: style.parent, scale, domain, data, height, width,
standalone, theme, polar, padding, origin
} };

return data.reduce((childProps, datum, index) => {
const eventKey = datum.eventKey;
const { x, y } = Helpers.scalePoint(Helpers.getPoint(datum), scale, polar);
const dataProps = {
x, y, datum, data, index, scale, polar,
x, y, datum, data, index, scale, polar, origin,
size: this.getSize(datum, props, calculatedValues),
symbol: this.getSymbol(datum, props),
style: this.getDataStyles(datum, style.data)
Expand Down
3 changes: 2 additions & 1 deletion src/components/victory-stack/victory-stack.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ export default class VictoryStack extends React.Component {
style,
colorScale: this.getColorScale(props, child),
data,
polar: props.polar
polar: props.polar,
origin: props.origin
}, childProps));
});
}
Expand Down
7 changes: 4 additions & 3 deletions src/components/victory-voronoi/helper-methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@ export default {
getBaseProps(props, fallbackProps) {
props = Helpers.modifyProps(props, fallbackProps, "voronoi");
const { data, style, scale, polygons, domain } = this.getCalculatedValues(props);
const { width, height, standalone, theme, events, sharedEvents, polar, padding } = props;
const { width, height, standalone, theme, events, sharedEvents, polar, padding, origin } = props;
const initialChildProps = { parent: {
style: style.parent, scale, domain, data, standalone, height, width, theme, polar, padding
style: style.parent, scale, domain, data, standalone, height, width,
theme, polar, padding, origin
} };

return data.reduce((childProps, datum, index) => {
const polygon = without(polygons[index], "data");
const eventKey = datum.eventKey;
const { x, y } = Helpers.scalePoint(Helpers.getPoint(datum), scale, polar);
const dataProps = {
x, y, datum, data, index, scale, polygon,
x, y, datum, data, index, scale, polygon, polar, origin,
size: props.size,
style: this.getDataStyles(datum, style.data)
};
Expand Down
3 changes: 3 additions & 0 deletions src/helpers/common-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export default {
dataComponent: PropTypes.element,
labelComponent: PropTypes.element,
labels: PropTypes.oneOfType([ PropTypes.func, PropTypes.array ]),
origin: PropTypes.shape({
x: PropTypes.number, y: PropTypes.number
}),
samples: CustomPropTypes.nonNegative,
sortKey: PropTypes.oneOfType([
PropTypes.func,
Expand Down

0 comments on commit 691eca0

Please sign in to comment.