Skip to content

Commit

Permalink
Override VictoryGroup styles with VictoryBoxplot (#2824)
Browse files Browse the repository at this point in the history
  • Loading branch information
acharyakavita authored Feb 29, 2024
1 parent b3695c0 commit dca1d5e
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/rare-spies-agree.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"victory-core": patch
---

allow VictoryBoxPlot childStyles to override VictoryGroup parent styles
22 changes: 22 additions & 0 deletions demo/ts/components/group-demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { VictoryScatter } from "victory-scatter";
import { VictoryErrorBar } from "victory-errorbar";
import { VictoryTooltip } from "victory-tooltip";
import { VictoryVoronoi } from "victory-voronoi";
import { VictoryBoxPlot } from "victory-box-plot";
import { range, random } from "lodash";

class App extends React.Component {
Expand Down Expand Up @@ -160,6 +161,27 @@ class App extends React.Component {
/>
</VictoryGroup>
</VictoryChart>
<VictoryGroup style={chartStyle}>
<VictoryBoxPlot
minLabels
maxLabels
data={[
{ x: 1, y: [1, 2, 3, 5] },
{ x: 2, y: [3, 2, 8, 10] },
{ x: 3, y: [2, 8, 6, 5] },
{ x: 4, y: [1, 3, 2, 9] },
]}
style={{
min: { stroke: "tomato" },
max: { stroke: "orange" },
q1: { fill: "tomato" },
q3: { fill: "orange" },
median: { stroke: "white", strokeWidth: 2 },
minLabels: { fill: "tomato" },
maxLabels: { fill: "orange" },
}}
/>
</VictoryGroup>
</div>
</div>
);
Expand Down
1 change: 1 addition & 0 deletions packages/victory-core/src/victory-util/wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ export function getChildStyle(child, index, calculatedProps) {
);
const labelsStyle = defaults({}, childStyle.labels, style.labels);
return {
...childStyle,
parent: style.parent,
data: dataStyle,
labels: labelsStyle,
Expand Down
27 changes: 27 additions & 0 deletions stories/victory-box-plot.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import seedrandom from "seedrandom";

import { VictoryBoxPlot } from "../packages/victory-box-plot";
import { VictoryChart } from "../packages/victory-chart";
import { VictoryGroup } from "../packages/victory-group";
import { VictoryTooltip } from "../packages/victory-tooltip";
import {
VictoryTheme,
Expand Down Expand Up @@ -360,3 +361,29 @@ export const DisableInlineStyles = () => {
</>
);
};

export const VictoryGroupAsParent = () => {
return (
<VictoryGroup style={parentStyle}>
<VictoryBoxPlot
minLabels
maxLabels
data={[
{ x: 1, y: [1, 2, 3, 5] },
{ x: 2, y: [3, 2, 8, 10] },
{ x: 3, y: [2, 8, 6, 5] },
{ x: 4, y: [1, 3, 2, 9] },
]}
style={{
min: { stroke: "tomato" },
max: { stroke: "orange" },
q1: { fill: "tomato" },
q3: { fill: "orange" },
median: { stroke: "white", strokeWidth: 2 },
minLabels: { fill: "tomato" },
maxLabels: { fill: "orange" },
}}
/>
</VictoryGroup>
);
};

0 comments on commit dca1d5e

Please sign in to comment.