;
groupComponent?: React.ReactElement;
id?: StringOrNumberOrCallback;
@@ -679,6 +681,7 @@ export interface VictoryCommonPrimitiveProps {
clipPath?: string;
data?: any;
desc?: string | Function;
+ disableInlineStyles?: boolean;
events?: object;
id?: number | string | Function;
index?: number | string;
diff --git a/packages/victory-core/src/victory-label/victory-label.js b/packages/victory-core/src/victory-label/victory-label.js
index 40206cff3..749620709 100644
--- a/packages/victory-core/src/victory-label/victory-label.js
+++ b/packages/victory-core/src/victory-label/victory-label.js
@@ -60,7 +60,11 @@ const useMultiLineBackgrounds = (props) => {
const getStyles = (style, props) => {
if (props.disableInlineStyles) {
- return {};
+ const baseStyles = Helpers.evaluateStyle(style, props);
+ return {
+ // Font size is necessary to calculate the y position of the label
+ fontSize: getFontSize(baseStyles)
+ };
}
const getSingleStyle = (s) => {
s = s ? defaults({}, s, defaultStyles) : defaultStyles;
diff --git a/packages/victory-core/src/victory-util/common-props.js b/packages/victory-core/src/victory-util/common-props.js
index 6f9a4ada8..776787d8d 100644
--- a/packages/victory-core/src/victory-util/common-props.js
+++ b/packages/victory-core/src/victory-util/common-props.js
@@ -11,6 +11,7 @@ const dataProps = {
]),
data: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
dataComponent: PropTypes.element,
+ disableInlineStyles: PropTypes.bool,
labelComponent: PropTypes.element,
labels: PropTypes.oneOfType([PropTypes.func, PropTypes.array]),
samples: CustomPropTypes.nonNegative,
@@ -151,6 +152,7 @@ const primitiveProps = {
clipPath: PropTypes.string,
data: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
desc: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
+ disableInlineStyles: PropTypes.bool,
events: PropTypes.object,
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.func]),
index: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
diff --git a/packages/victory-core/src/victory-util/helpers.js b/packages/victory-core/src/victory-util/helpers.js
index 6284aa41a..eaf9e464c 100644
--- a/packages/victory-core/src/victory-util/helpers.js
+++ b/packages/victory-core/src/victory-util/helpers.js
@@ -128,6 +128,9 @@ function evaluateProp(prop, props) {
}
function evaluateStyle(style, props) {
+ if (props.disableInlineStyles) {
+ return {};
+ }
if (!style || !keys(style).some((value) => isFunction(style[value]))) {
return style;
}
diff --git a/packages/victory-errorbar/src/helper-methods.js b/packages/victory-errorbar/src/helper-methods.js
index cd370b39e..3d1117c0c 100644
--- a/packages/victory-errorbar/src/helper-methods.js
+++ b/packages/victory-errorbar/src/helper-methods.js
@@ -105,7 +105,18 @@ const getCalculatedValues = (props) => {
};
const getLabelProps = (dataProps, text, style) => {
- const { x, y, index, scale, errorY, errorX, horizontal, labelComponent, theme } = dataProps;
+ const {
+ x,
+ y,
+ index,
+ scale,
+ errorY,
+ errorX,
+ horizontal,
+ labelComponent,
+ theme,
+ disableInlineStyles
+ } = dataProps;
const getError = (type = "x") => {
const baseError = type === "y" ? errorY : errorX;
const error = baseError && Array.isArray(baseError) ? baseError[0] : baseError;
@@ -129,7 +140,8 @@ const getLabelProps = (dataProps, text, style) => {
textAnchor: labelStyle.textAnchor || textAnchor,
verticalAnchor: labelStyle.verticalAnchor || verticalAnchor,
angle: labelStyle.angle,
- horizontal
+ horizontal,
+ disableInlineStyles
};
if (!Helpers.isTooltip(labelComponent)) {
@@ -160,7 +172,8 @@ const getBaseProps = (props, fallbackProps) => {
standalone,
style,
theme,
- width
+ width,
+ disableInlineStyles
} = props;
const initialChildProps = {
parent: {
@@ -196,9 +209,10 @@ const getBaseProps = (props, fallbackProps) => {
horizontal,
index,
scale,
- style: style.data,
+ style: disableInlineStyles ? {} : style.data,
x,
- y
+ y,
+ disableInlineStyles
};
childProps[eventKey] = {
diff --git a/packages/victory-histogram/src/helper-methods.js b/packages/victory-histogram/src/helper-methods.js
index ac6e7580d..1aa27ab9e 100644
--- a/packages/victory-histogram/src/helper-methods.js
+++ b/packages/victory-histogram/src/helper-methods.js
@@ -176,7 +176,8 @@ const getBaseProps = (props, fallbackProps) => {
width,
labels,
name,
- getPath
+ getPath,
+ disableInlineStyles
} = props;
const initialChildProps = {
parent: {
@@ -223,14 +224,15 @@ const getBaseProps = (props, fallbackProps) => {
horizontal,
index,
scale,
- style: style.data,
+ style: disableInlineStyles ? {} : style.data,
width,
height,
x,
y,
y0,
x0,
- getPath
+ getPath,
+ disableInlineStyles
};
childProps[eventKey] = {
diff --git a/packages/victory-line/src/helper-methods.js b/packages/victory-line/src/helper-methods.js
index e9a729213..085d17222 100644
--- a/packages/victory-line/src/helper-methods.js
+++ b/packages/victory-line/src/helper-methods.js
@@ -52,7 +52,8 @@ const getBaseProps = (props, fallbackProps) => {
theme,
width,
labels,
- name
+ name,
+ disableInlineStyles
} = props;
const initialChildProps = {
parent: {
@@ -78,8 +79,9 @@ const getBaseProps = (props, fallbackProps) => {
data,
interpolation,
groupComponent,
- style: style.data,
- theme
+ style: disableInlineStyles ? {} : style.data,
+ theme,
+ disableInlineStyles
}
}
};
diff --git a/packages/victory-pie/src/helper-methods.js b/packages/victory-pie/src/helper-methods.js
index 1339886b2..314ab5354 100644
--- a/packages/victory-pie/src/helper-methods.js
+++ b/packages/victory-pie/src/helper-methods.js
@@ -232,7 +232,8 @@ export const getBaseProps = (props, fallbackProps) => {
name,
innerRadius,
cornerRadius,
- padAngle
+ padAngle,
+ disableInlineStyles
} = calculatedValues;
const radius = props.radius || defaultRadius;
const initialChildProps = {
@@ -256,7 +257,8 @@ export const getBaseProps = (props, fallbackProps) => {
radius,
cornerRadius,
padAngle,
- style: getSliceStyle(index, calculatedValues)
+ style: disableInlineStyles ? {} : getSliceStyle(index, calculatedValues),
+ disableInlineStyles
};
childProps[eventKey] = {
data: dataProps
diff --git a/packages/victory-pie/src/victory-pie.js b/packages/victory-pie/src/victory-pie.js
index a9e26256d..53e8b1ff9 100644
--- a/packages/victory-pie/src/victory-pie.js
+++ b/packages/victory-pie/src/victory-pie.js
@@ -89,6 +89,7 @@ class VictoryPie extends React.Component {
cornerRadius: PropTypes.oneOfType([CustomPropTypes.nonNegative, PropTypes.func]),
data: PropTypes.array,
dataComponent: PropTypes.element,
+ disableInlineStyes: PropTypes.bool,
endAngle: PropTypes.number,
eventKey: PropTypes.oneOfType([
PropTypes.func,
diff --git a/packages/victory-polar-axis/src/helper-methods.js b/packages/victory-polar-axis/src/helper-methods.js
index d40709433..5283a6a6e 100644
--- a/packages/victory-polar-axis/src/helper-methods.js
+++ b/packages/victory-polar-axis/src/helper-methods.js
@@ -82,6 +82,9 @@ const getScale = (props) => {
};
const getStyles = (props, styleObject) => {
+ if (props.disableInlineStyles) {
+ return {};
+ }
const style = props.style || {};
styleObject = styleObject || {};
const parentStyleProps = { height: "auto", width: "100%" };
diff --git a/packages/victory-polar-axis/src/victory-polar-axis.js b/packages/victory-polar-axis/src/victory-polar-axis.js
index 3f876d748..45657527d 100644
--- a/packages/victory-polar-axis/src/victory-polar-axis.js
+++ b/packages/victory-polar-axis/src/victory-polar-axis.js
@@ -73,6 +73,7 @@ class VictoryPolarAxis extends React.Component {
circularGridComponent: PropTypes.element,
containerComponent: PropTypes.element,
dependentAxis: PropTypes.bool,
+ disableInlineStyles: PropTypes.bool,
endAngle: PropTypes.number,
events: PropTypes.arrayOf(
PropTypes.shape({
diff --git a/packages/victory-scatter/src/helper-methods.js b/packages/victory-scatter/src/helper-methods.js
index 95a2cab75..276945b72 100644
--- a/packages/victory-scatter/src/helper-methods.js
+++ b/packages/victory-scatter/src/helper-methods.js
@@ -90,7 +90,8 @@ const getBaseProps = (props, fallbackProps) => {
theme,
width,
labels,
- horizontal
+ horizontal,
+ disableInlineStyles
} = props;
const initialChildProps = {
parent: {
@@ -125,7 +126,8 @@ const getBaseProps = (props, fallbackProps) => {
horizontal,
size: getSize(datum, props),
symbol: getSymbol(datum, props),
- style: style.data
+ style: disableInlineStyles ? {} : style.data,
+ disableInlineStyles
};
childProps[eventKey] = { data: dataProps };
diff --git a/stories/victory-area.stories.js b/stories/victory-area.stories.js
index 36e8fa2af..1b51daa88 100644
--- a/stories/victory-area.stories.js
+++ b/stories/victory-area.stories.js
@@ -8,6 +8,8 @@ import { VictoryTheme, VictoryLabel } from "../packages/victory-core/src";
import { VictoryChart } from "../packages/victory-chart/src";
import { getData, getMixedData, getTimeData, getLogData, getDataWithBaseline } from "./data";
import { fromJS } from "immutable";
+import Area from "../packages/victory-area/src/area";
+import styled from "styled-components";
const containerStyle = {
display: "flex",
@@ -453,3 +455,16 @@ export const Polar = () => {
);
};
+
+const StyledArea = styled(Area)`
+ fill: pink;
+`;
+
+export const DisableInlineStyles = () => {
+ return (
+
+
+ } />
+
+ );
+};
diff --git a/stories/victory-bar.stories.js b/stories/victory-bar.stories.js
index 07c558b00..9eeb850e6 100644
--- a/stories/victory-bar.stories.js
+++ b/stories/victory-bar.stories.js
@@ -17,6 +17,7 @@ import {
getDataWithBaseline
} from "./data";
import { fromJS } from "immutable";
+import styled from "styled-components";
const containerStyle = {
display: "flex",
@@ -937,14 +938,18 @@ export const Domain = () => {
);
};
+const StyledBar = styled(Bar)`
+ fill: purple;
+`;
+
export const DisableInlineStyles = () => {
return (
-
+
-
- } />
+
+ } />
);
diff --git a/stories/victory-box-plot.stories.js b/stories/victory-box-plot.stories.js
index 3b3c29109..d90557d72 100644
--- a/stories/victory-box-plot.stories.js
+++ b/stories/victory-box-plot.stories.js
@@ -4,10 +4,11 @@ import React from "react";
import { VictoryBoxPlot } from "../packages/victory-box-plot/src/index";
import { VictoryChart } from "../packages/victory-chart/src/index";
import { VictoryTooltip } from "../packages/victory-tooltip/src/index";
-import { VictoryTheme } from "../packages/victory-core/src/index";
+import { VictoryTheme, Box, Whisker, LineSegment } from "../packages/victory-core/src/index";
import { range } from "lodash";
import seedrandom from "seedrandom";
import { getArrayData } from "./data";
+import styled from "styled-components";
const getRepeatData = (num, samples) => {
const seed = "getRepeatData";
@@ -321,3 +322,35 @@ export const Domain = () => {
);
};
+
+const StyledBox = styled(Box)`
+ fill: blueviolet;
+`;
+
+const StyledWhisker = styled(Whisker)`
+ stroke: aqua;
+`;
+
+const StyledLineSegment = styled(LineSegment)`
+ stroke: lavender;
+`;
+
+export const DisableInlineStyles = () => {
+ return (
+
+
+
+
+
+ }
+ q3Component={}
+ maxComponent={}
+ minComponent={}
+ medianComponent={}
+ />
+
+
+ );
+};
diff --git a/stories/victory-candlestick.stories.js b/stories/victory-candlestick.stories.js
index cbd84abfc..67a21284b 100644
--- a/stories/victory-candlestick.stories.js
+++ b/stories/victory-candlestick.stories.js
@@ -1,13 +1,14 @@
/*eslint-disable no-magic-numbers*/
/*eslint-disable react/no-multi-comp*/
import React from "react";
-import { VictoryCandlestick } from "../packages/victory-candlestick/src/index";
+import { VictoryCandlestick, Candle } from "../packages/victory-candlestick/src/index";
import { VictoryChart } from "../packages/victory-chart/src/index";
import { VictoryTooltip } from "../packages/victory-tooltip/src/index";
import { VictoryTheme } from "../packages/victory-core/src/index";
import { range } from "lodash";
import seedrandom from "seedrandom";
import { fromJS } from "immutable";
+import styled from "styled-components";
const sampleData = [
{ x: 1, open: 9, close: 30, high: 56, low: 7 },
@@ -371,3 +372,24 @@ export const Domain = () => {
);
};
+
+const StyledCandle = styled(Candle)`
+ fill: lightblue;
+ stroke: magenta;
+`;
+
+export const DisableInlineStyles = () => {
+ return (
+
+
+
+
+
+ }
+ />
+
+
+ );
+};
diff --git a/stories/victory-errorbar.stories.js b/stories/victory-errorbar.stories.js
index c36faa40c..aef825b42 100644
--- a/stories/victory-errorbar.stories.js
+++ b/stories/victory-errorbar.stories.js
@@ -1,13 +1,14 @@
/*eslint-disable no-magic-numbers*/
/*eslint-disable react/no-multi-comp*/
import React from "react";
-import { VictoryErrorBar } from "../packages/victory-errorbar/src/index";
+import { VictoryErrorBar, ErrorBar } from "../packages/victory-errorbar/src/index";
import { VictoryChart } from "../packages/victory-chart/src/index";
import { VictoryTooltip } from "../packages/victory-tooltip/src/index";
import { VictoryTheme } from "../packages/victory-core/src/index";
import { range } from "lodash";
import seedrandom from "seedrandom";
import { fromJS } from "immutable";
+import styled from "styled-components";
const getData = (num, symmetric, seed) => {
seed = seed || "getData";
@@ -259,3 +260,20 @@ export const Domain = () => {
);
};
+
+const StyledErrorBar = styled(ErrorBar)`
+ stroke: deeppink;
+`;
+
+export const DisableInlineStyles = () => {
+ return (
+
+
+
+
+
+ } />
+
+
+ );
+};
diff --git a/stories/victory-histogram.stories.js b/stories/victory-histogram.stories.js
index 88fda0d09..be0c8d43d 100644
--- a/stories/victory-histogram.stories.js
+++ b/stories/victory-histogram.stories.js
@@ -10,10 +10,12 @@ import { VictoryStack } from "../packages/victory-stack/src";
import { VictoryTheme } from "../packages/victory-core/src";
import { getData } from "./data";
import { data, timeData } from "./victory-histogram-data";
+import { Bar } from "../packages/victory-bar/src";
import * as d3Array from "d3-array";
import * as d3Scale from "d3-scale";
import * as d3Time from "d3-time";
+import styled from "styled-components";
const containerStyle = {
display: "flex",
@@ -497,3 +499,21 @@ export const Domain = () => {
);
};
+
+const StyledBar = styled(Bar)`
+ stroke: black;
+ fill: teal;
+`;
+
+export const DisableInlineStyles = () => {
+ return (
+
+
+
+
+
+ } />
+
+
+ );
+};
diff --git a/stories/victory-line.stories.js b/stories/victory-line.stories.js
index 0dd222075..8ce079368 100644
--- a/stories/victory-line.stories.js
+++ b/stories/victory-line.stories.js
@@ -2,12 +2,13 @@
/*eslint-disable react/no-multi-comp*/
import React from "react";
import { VictoryStack } from "../packages/victory-stack/src/index";
-import { VictoryLine } from "../packages/victory-line/src/index";
+import { VictoryLine, Curve } from "../packages/victory-line/src/index";
import { VictoryChart } from "../packages/victory-chart/src/index";
import { VictoryTooltip } from "../packages/victory-tooltip/src/index";
import { VictoryTheme, VictoryLabel } from "../packages/victory-core/src/index";
import { getData, getMixedData, getTimeData, getLogData } from "./data";
import { fromJS } from "immutable";
+import styled from "styled-components";
const containerStyle = {
display: "flex",
@@ -455,3 +456,21 @@ export const Polar = () => {
);
};
+
+const StyledCurve = styled(Curve)`
+ stroke: purple;
+ stroke-width: 10px;
+`;
+
+export const DisableInlineStyles = () => {
+ return (
+
+
+
+
+
+ } />
+
+
+ );
+};
diff --git a/stories/victory-pie.stories.js b/stories/victory-pie.stories.js
index 76631620a..8bb9181f2 100644
--- a/stories/victory-pie.stories.js
+++ b/stories/victory-pie.stories.js
@@ -6,6 +6,7 @@ import { VictoryPie, Slice } from "../packages/victory-pie/src/index";
import { VictoryTooltip } from "../packages/victory-tooltip/src/index";
import { VictoryTheme, Helpers } from "../packages/victory-core/src/index";
import { fromJS } from "immutable";
+import styled from "styled-components";
const containerStyle = {
display: "flex",
@@ -544,3 +545,16 @@ export const LabelPlacement = () => {
);
};
+
+const StyledSlice = styled(Slice)`
+ fill: pink;
+`;
+
+export const DisableInlineStyles = () => {
+ return (
+
+
+ } />
+
+ );
+};
diff --git a/stories/victory-scatter.stories.js b/stories/victory-scatter.stories.js
index 71bd5d99a..62966350b 100644
--- a/stories/victory-scatter.stories.js
+++ b/stories/victory-scatter.stories.js
@@ -6,9 +6,10 @@ import { VictoryStack } from "../packages/victory-stack/src/index";
import { VictoryScatter } from "../packages/victory-scatter/src/index";
import { VictoryChart } from "../packages/victory-chart/src/index";
import { VictoryTooltip } from "../packages/victory-tooltip/src/index";
-import { VictoryTheme } from "../packages/victory-core/src/index";
+import { VictoryTheme, Point } from "../packages/victory-core/src/index";
import { getData, getMixedData, getTimeData, getLogData } from "./data";
import { fromJS } from "immutable";
+import styled from "styled-components";
const SYMBOLS = [
"circle",
@@ -509,3 +510,20 @@ export const Domain = () => {
);
};
+
+const StyledPoint = styled(Point)`
+ fill: darkmagenta;
+`;
+
+export const DisableInlineStyles = () => {
+ return (
+
+
+
+
+
+ } />
+
+
+ );
+};
diff --git a/stories/victory-tooltip.stories.js b/stories/victory-tooltip.stories.js
index 61ed12e12..fc9eb97f4 100644
--- a/stories/victory-tooltip.stories.js
+++ b/stories/victory-tooltip.stories.js
@@ -2,8 +2,10 @@
/*eslint-disable react/no-multi-comp*/
import React from "react";
import { VictoryBar } from "../packages/victory-bar/src/index";
-import { VictoryTooltip } from "../packages/victory-tooltip/src/index";
+import { VictoryTooltip, Flyout } from "../packages/victory-tooltip/src/index";
+import { VictoryLabel } from "victory-core/src";
import { getData, getMixedData } from "./data";
+import styled from "styled-components";
const containerStyle = {
display: "flex",
@@ -681,3 +683,32 @@ export const FlyoutPadding = () => {
);
};
+
+const StyledFlyout = styled(Flyout)`
+ fill: aquamarine;
+`;
+
+const StyledLabel = styled(VictoryLabel)`
+ fill: blue;
+`;
+
+export const DisableInlineStyles = () => {
+ return (
+
+ }
+ />
+ }
+ labelComponent={}
+ />
+ }
+ />
+
+ );
+};
diff --git a/test/client/spec/victory-core/victory-util/helpers.spec.js b/test/client/spec/victory-core/victory-util/helpers.spec.js
index 17061553b..28cb2db1a 100644
--- a/test/client/spec/victory-core/victory-util/helpers.spec.js
+++ b/test/client/spec/victory-core/victory-util/helpers.spec.js
@@ -78,6 +78,15 @@ describe("victory-util/helpers", () => {
};
expect(Helpers.evaluateStyle(style, data)).to.deep.equal({ color: "red", size: 5 });
});
+ it("returns no styles if disableInlineStyles is true", () => {
+ const style = {
+ color: "blue"
+ };
+ const props = {
+ disableInlineStyles: true
+ };
+ expect(Helpers.evaluateStyle(style, props)).to.deep.equal({});
+ });
});
describe("getRange", () => {