Skip to content

Commit bdd6128

Browse files
committed
Remove background styles from props passed to other children of chart, add a chart with background to chart demos
1 parent 1e824ec commit bdd6128

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

demo/js/components/victory-chart-demo.js

+12-3
Original file line numberDiff line numberDiff line change
@@ -182,30 +182,39 @@ class App extends React.Component {
182182
};
183183
const chartStyle = {
184184
parent: { border: "1px solid #ccc", margin: "2%", maxWidth: "40%" }
185-
};
185+
}
186+
;
186187
const axisStyle = {
187188
grid: { stroke: "grey", strokeWidth: 1 },
188189
axis: { stroke: "transparent" },
189190
ticks: { stroke: "transparent" },
190191
tickLabels: { fill: "none" }
191192
};
192193

194+
const bgStyle = {
195+
background: { fill: "#e6e6ff" }
196+
}
197+
193198
return (
194199
<div className="demo">
195200
<h1>VictoryChart</h1>
196201
<div style={containerStyle}>
197202
<VictoryChart style={chartStyle} polar>
198-
<VictoryScatter data={[{ x: -3, y: -3 }]} />
203+
<VictoryScatter />
199204
</VictoryChart>
200205

201-
<VictoryChart style={chartStyle}>
206+
<VictoryChart style={assign({}, chartStyle, bgStyle)}>
202207
<VictoryScatter data={[{ x: -3, y: -3 }]} />
203208
</VictoryChart>
204209

205210
<VictoryChart style={chartStyle} theme={dependentAxisTheme}>
206211
<VictoryScatter />
207212
</VictoryChart>
208213

214+
<VictoryChart style={chartStyle} theme={dependentAxisTheme}>
215+
<VictoryScatter />
216+
</VictoryChart>
217+
209218
<VictoryChart style={chartStyle} domainPadding={{ x: [0, 20] }}>
210219
<VictoryAxis dependentAxis style={axisStyle} />
211220
<VictoryAxis style={axisStyle} tickCount={6} />

packages/victory-chart/src/helper-methods.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,13 @@ function getChildProps(child, props, calculatedProps) {
7777

7878
function getStyles(props) {
7979
const styleProps = props.style && props.style.parent;
80-
const background = props.style && props.style.background;
8180

8281
return {
8382
parent: defaults({}, styleProps, {
8483
height: "100%",
8584
width: "100%",
8685
userSelect: "none"
87-
}),
88-
background
86+
})
8987
};
9088
}
9189

@@ -159,7 +157,6 @@ function getChildren(props, childComponents, calculatedProps) {
159157
childComponents = childComponents || getChildComponents(props);
160158
calculatedProps = calculatedProps || getCalculatedProps(props, childComponents);
161159
const baseStyle = calculatedProps.style.parent;
162-
const backgroundStyle = calculatedProps.style.background;
163160
const { height, polar, theme, width } = props;
164161
const { origin, horizontal } = calculatedProps;
165162
const parentName = props.name || "chart";
@@ -168,7 +165,7 @@ function getChildren(props, childComponents, calculatedProps) {
168165
const role = child.type && child.type.role;
169166
const style = Array.isArray(child.props.style)
170167
? child.props.style
171-
: defaults({}, child.props.style, { parent: baseStyle, background: backgroundStyle });
168+
: defaults({}, child.props.style, { parent: baseStyle });
172169
const childProps = getChildProps(child, props, calculatedProps);
173170
const name = child.props.name || `${parentName}-${role}-${index}`;
174171
const newProps = defaults(

0 commit comments

Comments
 (0)