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

VictoryChart: adds an option for adding background for chart area #1558

Merged
merged 20 commits into from
May 11, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
4a339c8
Added new Background primitive, set up methods in VictoryChart to ren…
maddles May 5, 2020
26554d9
Rendering background as first child in charts if background property …
maddles May 6, 2020
f41363a
Make sure background property remains on style prop for VictoryChart …
maddles May 6, 2020
6c6253a
Get the chart background rendering in correct range, fix bug with zer…
maddles May 6, 2020
5fdf2cf
Adds additional stories to show the background property on the style …
wsparsons May 6, 2020
1856706
React proptypes for Chart Background, Polar chart background
maddles May 6, 2020
0493017
Make sure getHeight and getRangeBounds return the right values in bac…
maddles May 6, 2020
e0e0f1f
Remove an unused import in Background, alphebetise props
maddles May 6, 2020
fc8cf42
Adds additional stories to show background style on circle and rect c…
wsparsons May 7, 2020
0142050
Removes uninvoked functions
wsparsons May 7, 2020
ce270ae
Adds background property to the style prop for VictoryChartProps inte…
wsparsons May 7, 2020
8ddb47c
Add separate props for VictoryChart background
maddles May 8, 2020
95cd939
Refactors backgroundProps to take into account the x and y coordinate…
wsparsons May 8, 2020
f0c280e
Adds a few more UI tests for chart background (stack, group, and hori…
maddles May 8, 2020
1e824ec
Undefined check for style in victory-chart
maddles May 8, 2020
bdd6128
Remove background styles from props passed to other children of chart…
maddles May 8, 2020
a28aa7d
Remove disused cx and cy props from Background, ensure that backgroun…
maddles May 8, 2020
226d9a2
Adds a few more demos to victory charts
wsparsons May 11, 2020
6e0f1b3
defaults object for background props in chart helper methods, export …
maddles May 11, 2020
ee88dbd
Remove disused import from chart js demo
maddles May 11, 2020
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
Prev Previous commit
Next Next commit
Make sure background property remains on style prop for VictoryChart …
…children
  • Loading branch information
maddles authored and wsparsons committed May 7, 2020
commit f41363a23296da2a2d1b59d3cfb68f78d96e43fd
8 changes: 6 additions & 2 deletions packages/victory-chart/src/helper-methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,15 @@ function getChildProps(child, props, calculatedProps) {

function getStyles(props) {
const styleProps = props.style && props.style.parent;
const background = props.style && props.style.background;

return {
parent: defaults({}, styleProps, {
height: "100%",
width: "100%",
userSelect: "none"
})
}),
background
};
}

Expand Down Expand Up @@ -126,14 +129,15 @@ function getChildren(props, childComponents, calculatedProps) {
childComponents = childComponents || getChildComponents(props);
calculatedProps = calculatedProps || getCalculatedProps(props, childComponents);
const baseStyle = calculatedProps.style.parent;
const backgroundStyle = calculatedProps.style.background;
const { height, polar, theme, width } = props;
const { origin, horizontal } = calculatedProps;
const parentName = props.name || "chart";
return childComponents.map((child, index) => {
const role = child.type && child.type.role;
const style = Array.isArray(child.props.style)
? child.props.style
: defaults({}, child.props.style, { parent: baseStyle });
: defaults({}, child.props.style, { parent: baseStyle, background: backgroundStyle });
const childProps = getChildProps(child, props, calculatedProps);
const name = child.props.name || `${parentName}-${role}-${index}`;
const newProps = defaults(
Expand Down
4 changes: 0 additions & 4 deletions packages/victory-chart/src/victory-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,6 @@ export default class VictoryChart extends React.Component {
const axes = props.polar ? modifiedProps.defaultPolarAxes : modifiedProps.defaultAxes;
const childComponents = getChildComponents(modifiedProps, axes);
const calculatedProps = getCalculatedProps(modifiedProps, childComponents);
const backgroundProps =
props.style && props.style.background
? this.getBackgroundProps(modifiedProps, calculatedProps)
: {};
const newChildren = this.getNewChildren(modifiedProps, childComponents, calculatedProps);
const containerProps = standalone ? this.getContainerProps(modifiedProps, calculatedProps) : {};
const container = standalone
Expand Down