-
Notifications
You must be signed in to change notification settings - Fork 524
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 #1882 from FormidableLabs/task/disable-more-inline…
…-styles Disable inline styles
- Loading branch information
Showing
30 changed files
with
383 additions
and
52 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -165,9 +165,9 @@ _default:_ `containerComponent={<VictoryContainer/>}` | |
|
||
Specify data via the `data` prop. By default, Victory components expect data as an array of objects with `x` and `y` properties. Use the [x][] and [y][] data accessor props to define a custom data format. The `data` prop must be given as an array. Data objects may also include information about ~~styles~~, labels, and props that may be applied to individual data components. | ||
|
||
*note:* All values stored on the data object will be interpolated during animation. Do not store functions on data objects. | ||
_note:_ All values stored on the data object will be interpolated during animation. Do not store functions on data objects. | ||
|
||
*note* As of `[email protected]` styles provided via the `data` prop are no longer automatically applied. To use styles from the data object, add functional styles as in the example below. | ||
_note_ As of `[email protected]` styles provided via the `data` prop are no longer automatically applied. To use styles from the data object, add functional styles as in the example below. | ||
|
||
```playground | ||
<VictoryScatter | ||
|
@@ -226,6 +226,65 @@ class App extends React.Component { | |
ReactDOM.render(<App/>, mountNode); | ||
``` | ||
|
||
## disableInlineStyles | ||
|
||
`type: boolean` | ||
|
||
The `disableInlineStyles` prop allows Victory components to work better with CSS classes or styled-components. By default, Victory provides inline styles to chart components, which will override any conflicting CSS styles. This flag will remove the inline styles, making it easier to provide custom styling for components via CSS. | ||
|
||
If this prop is passed to a chart type (e.g. `VictoryBar`), it will apply to all data and label components for that chart. | ||
|
||
```playground_norender | ||
const StyledBar = styled(Bar)` | ||
fill: purple; | ||
` | ||
const StyledLabel = styled(VictoryLabel)` | ||
tspan { | ||
fill: magenta; | ||
font-family: Papyrus, fantasy; | ||
} | ||
` | ||
function CustomStyledBarChart() { | ||
return ( | ||
<VictoryChart> | ||
<VictoryBar | ||
disableInlineStyles | ||
labels={[1, 2, 3, 4]} | ||
dataComponent={<StyledBar />} | ||
labelComponent={<StyledLabel />} | ||
/> | ||
</VictoryChart> | ||
) | ||
} | ||
ReactDOM.render(<CustomStyledBarChart/>, mountNode); | ||
``` | ||
|
||
It can also be passed to individual data or label components to disable styles on a more granular level. | ||
|
||
```playground_norender | ||
const StyledBar = styled(Bar)` | ||
fill: purple; | ||
` | ||
function CustomStyledBarChart() { | ||
return ( | ||
<VictoryChart> | ||
<VictoryBar | ||
labels={[1, 2, 3, 4]} | ||
dataComponent={<StyledBar disableInlineStyles />} | ||
/> | ||
</VictoryChart> | ||
) | ||
} | ||
ReactDOM.render(<CustomStyledBarChart/>, mountNode); | ||
``` | ||
|
||
## domain | ||
|
||
`type: array[low, high] || { x: [low, high], y: [low, high] }` | ||
|
@@ -260,7 +319,7 @@ _examples:_ | |
- `domainPadding={20}` | ||
- `domainPadding={{x: [20, 0]}}` | ||
|
||
*note* Values supplied for `domainPadding` will be coerced so that padding a domain will never result in charts including an additional quadrant. For example, if an original domain included only positive values, `domainPadding` will be coerced so that the resulted padded domain will not include negative values. | ||
_note_ Values supplied for `domainPadding` will be coerced so that padding a domain will never result in charts including an additional quadrant. For example, if an original domain included only positive values, `domainPadding` will be coerced so that the resulted padded domain will not include negative values. | ||
|
||
```playground | ||
<VictoryChart | ||
|
@@ -344,10 +403,7 @@ externalEventMutations: PropTypes.arrayOf( | |
childName: PropTypes.oneOfType([PropTypes.string, PropTypes.array]), | ||
eventKey: PropTypes.oneOfType([ | ||
PropTypes.array, | ||
CustomPropTypes.allOfType([ | ||
CustomPropTypes.integer, | ||
CustomPropTypes.nonNegative | ||
]), | ||
CustomPropTypes.allOfType([CustomPropTypes.integer, CustomPropTypes.nonNegative]), | ||
PropTypes.string | ||
]), | ||
mutation: PropTypes.function, | ||
|
@@ -824,11 +880,11 @@ style={{ | |
}} | ||
``` | ||
|
||
*note* The `style` prop used by `VictoryAxis` has a different format than the standard `style` prop. | ||
_note_ The `style` prop used by `VictoryAxis` has a different format than the standard `style` prop. | ||
|
||
*note* When a component is rendered as a child of another Victory component, or within a custom `<svg>` element with `standalone={false}` parent styles will be applied to the enclosing `<g>` tag. Many styles that can be applied to a parent `<svg>` will not be expressed when applied to a `<g>`. | ||
_note_ When a component is rendered as a child of another Victory component, or within a custom `<svg>` element with `standalone={false}` parent styles will be applied to the enclosing `<g>` tag. Many styles that can be applied to a parent `<svg>` will not be expressed when applied to a `<g>`. | ||
|
||
*note* custom `angle` and `verticalAnchor` properties maybe included in labels styles. | ||
_note_ custom `angle` and `verticalAnchor` properties maybe included in labels styles. | ||
|
||
_default (provided by default theme):_ See [grayscale theme][] for more detail | ||
|
||
|
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
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
Oops, something went wrong.