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
Remove disused cx and cy props from Background, ensure that backgroun…
…d prop getter is only invoked when it's going to be used
  • Loading branch information
maddles committed May 8, 2020
commit a28aa7d50b2bd87b877b01a80ae4374d08b96fbc
5 changes: 2 additions & 3 deletions demo/js/components/victory-chart-demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,7 @@ class App extends React.Component {
};
const chartStyle = {
parent: { border: "1px solid #ccc", margin: "2%", maxWidth: "40%" }
}
;
};
const axisStyle = {
grid: { stroke: "grey", strokeWidth: 1 },
axis: { stroke: "transparent" },
Expand All @@ -193,7 +192,7 @@ class App extends React.Component {

const bgStyle = {
background: { fill: "#e6e6ff" }
}
};

return (
<div className="demo">
Expand Down
1 change: 1 addition & 0 deletions packages/victory-chart/src/helper-methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ function getBackgroundWithProps(props, calculatedProps) {
const backgroundProps = {
height,
polar: props.polar,
scale: calculatedProps.scale,
style: props.style.background,
x: xCoordinate,
y: yCoordinate,
Expand Down
3 changes: 2 additions & 1 deletion packages/victory-chart/src/victory-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,15 @@ export default class VictoryChart extends React.Component {
getNewChildren(props, childComponents, calculatedProps) {
const children = getChildren(props, childComponents, calculatedProps);
const getAnimationProps = Wrapper.getAnimationProps.bind(this);
const backgroundComponent = getBackgroundWithProps(props, calculatedProps);

const newChildren = children.map((child, index) => {
const childProps = assign({ animate: getAnimationProps(props, child, index) }, child.props);
return React.cloneElement(child, childProps);
});

if (props.style && props.style.background) {
const backgroundComponent = getBackgroundWithProps(props, calculatedProps);

newChildren.unshift(backgroundComponent);
}

Expand Down
2 changes: 0 additions & 2 deletions packages/victory-core/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -662,8 +662,6 @@ export class VictoryPortal extends React.Component<VictoryPortalProps, any> {}

export interface BackgroundProps extends VictoryCommonPrimitiveProps {
circleComponent?: React.ReactElement;
cx?: number;
cy?: number;
height?: number;
rectComponent?: React.ReactElement;
width?: number;
Expand Down
2 changes: 0 additions & 2 deletions packages/victory-core/src/victory-primitives/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ const Background = (props) => {
Background.propTypes = {
...CommonProps.primitiveProps,
circleComponent: PropTypes.element,
cx: PropTypes.number,
cy: PropTypes.number,
height: PropTypes.number,
rectComponent: PropTypes.element,
width: PropTypes.number,
Expand Down