-
Notifications
You must be signed in to change notification settings - Fork 525
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1558 from FormidableLabs/task/add-chart-backgroun…
…d-primitive VictoryChart: adds an option for adding background for chart area
- Loading branch information
Showing
12 changed files
with
241 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,32 @@ | ||
import * as React from "react"; | ||
import { | ||
CategoryPropType, | ||
EventPropTypeInterface, | ||
DomainPropType, | ||
EventPropTypeInterface, | ||
StringOrNumberOrCallback, | ||
VictoryCommonProps, | ||
VictoryStyleInterface | ||
VictoryStyleInterface, | ||
VictoryStyleObject | ||
} from "victory-core"; | ||
|
||
export type AxesType = { | ||
independent?: React.ReactElement; | ||
dependent?: React.ReactElement; | ||
independent?: React.ReactElement; | ||
}; | ||
|
||
export interface VictoryChartProps extends VictoryCommonProps { | ||
defaultAxes?: AxesType; | ||
defaultPolarAxes?: AxesType; | ||
categories?: CategoryPropType; | ||
children?: React.ReactNode | React.ReactNode[]; | ||
defaultAxes?: AxesType; | ||
defaultPolarAxes?: AxesType; | ||
domain?: DomainPropType; | ||
endAngle?: number; | ||
events?: EventPropTypeInterface<string, string[] | number[] | string | number>[]; | ||
eventKey?: StringOrNumberOrCallback; | ||
events?: EventPropTypeInterface<string, string[] | number[] | string | number>[]; | ||
innerRadius?: number; | ||
prependDefaultAxes?: boolean; | ||
startAngle?: number; | ||
style?: Pick<VictoryStyleInterface, "parent">; | ||
style?: Pick<VictoryStyleInterface, "parent"> & { background?: VictoryStyleObject }; | ||
} | ||
|
||
export class VictoryChart extends React.Component<VictoryChartProps, any> {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
packages/victory-core/src/victory-primitives/background.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import React from "react"; | ||
import PropTypes from "prop-types"; | ||
import CommonProps from "../victory-util/common-props"; | ||
import Rect from "./rect"; | ||
import Circle from "./circle"; | ||
|
||
const Background = (props) => { | ||
return props.polar | ||
? React.cloneElement(props.circleComponent, { | ||
...props.events, | ||
style: props.style, | ||
role: props.role, | ||
shapeRendering: props.shapeRendering, | ||
cx: props.x, | ||
cy: props.y, | ||
r: props.height | ||
}) | ||
: React.cloneElement(props.rectComponent, { | ||
...props.events, | ||
style: props.style, | ||
role: props.role, | ||
shapeRendering: props.shapeRendering, | ||
x: props.x, | ||
y: props.y, | ||
width: props.width, | ||
height: props.height | ||
}); | ||
}; | ||
|
||
Background.propTypes = { | ||
...CommonProps.primitiveProps, | ||
circleComponent: PropTypes.element, | ||
height: PropTypes.number, | ||
rectComponent: PropTypes.element, | ||
width: PropTypes.number, | ||
x: PropTypes.number, | ||
y: PropTypes.number | ||
}; | ||
|
||
Background.defaultProps = { | ||
circleComponent: <Circle />, | ||
rectComponent: <Rect />, | ||
role: "presentation", | ||
shapeRendering: "auto" | ||
}; | ||
|
||
export default Background; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.