Skip to content

Commit dca1d5e

Browse files
Override VictoryGroup styles with VictoryBoxplot (#2824)
1 parent b3695c0 commit dca1d5e

File tree

4 files changed

+55
-0
lines changed

4 files changed

+55
-0
lines changed

.changeset/rare-spies-agree.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"victory-core": patch
3+
---
4+
5+
allow VictoryBoxPlot childStyles to override VictoryGroup parent styles

demo/ts/components/group-demo.tsx

+22
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { VictoryScatter } from "victory-scatter";
99
import { VictoryErrorBar } from "victory-errorbar";
1010
import { VictoryTooltip } from "victory-tooltip";
1111
import { VictoryVoronoi } from "victory-voronoi";
12+
import { VictoryBoxPlot } from "victory-box-plot";
1213
import { range, random } from "lodash";
1314

1415
class App extends React.Component {
@@ -160,6 +161,27 @@ class App extends React.Component {
160161
/>
161162
</VictoryGroup>
162163
</VictoryChart>
164+
<VictoryGroup style={chartStyle}>
165+
<VictoryBoxPlot
166+
minLabels
167+
maxLabels
168+
data={[
169+
{ x: 1, y: [1, 2, 3, 5] },
170+
{ x: 2, y: [3, 2, 8, 10] },
171+
{ x: 3, y: [2, 8, 6, 5] },
172+
{ x: 4, y: [1, 3, 2, 9] },
173+
]}
174+
style={{
175+
min: { stroke: "tomato" },
176+
max: { stroke: "orange" },
177+
q1: { fill: "tomato" },
178+
q3: { fill: "orange" },
179+
median: { stroke: "white", strokeWidth: 2 },
180+
minLabels: { fill: "tomato" },
181+
maxLabels: { fill: "orange" },
182+
}}
183+
/>
184+
</VictoryGroup>
163185
</div>
164186
</div>
165187
);

packages/victory-core/src/victory-util/wrapper.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ export function getChildStyle(child, index, calculatedProps) {
345345
);
346346
const labelsStyle = defaults({}, childStyle.labels, style.labels);
347347
return {
348+
...childStyle,
348349
parent: style.parent,
349350
data: dataStyle,
350351
labels: labelsStyle,

stories/victory-box-plot.stories.tsx

+27
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import seedrandom from "seedrandom";
66

77
import { VictoryBoxPlot } from "../packages/victory-box-plot";
88
import { VictoryChart } from "../packages/victory-chart";
9+
import { VictoryGroup } from "../packages/victory-group";
910
import { VictoryTooltip } from "../packages/victory-tooltip";
1011
import {
1112
VictoryTheme,
@@ -360,3 +361,29 @@ export const DisableInlineStyles = () => {
360361
</>
361362
);
362363
};
364+
365+
export const VictoryGroupAsParent = () => {
366+
return (
367+
<VictoryGroup style={parentStyle}>
368+
<VictoryBoxPlot
369+
minLabels
370+
maxLabels
371+
data={[
372+
{ x: 1, y: [1, 2, 3, 5] },
373+
{ x: 2, y: [3, 2, 8, 10] },
374+
{ x: 3, y: [2, 8, 6, 5] },
375+
{ x: 4, y: [1, 3, 2, 9] },
376+
]}
377+
style={{
378+
min: { stroke: "tomato" },
379+
max: { stroke: "orange" },
380+
q1: { fill: "tomato" },
381+
q3: { fill: "orange" },
382+
median: { stroke: "white", strokeWidth: 2 },
383+
minLabels: { fill: "tomato" },
384+
maxLabels: { fill: "orange" },
385+
}}
386+
/>
387+
</VictoryGroup>
388+
);
389+
};

0 commit comments

Comments
 (0)