Skip to content

Commit

Permalink
Fix the label background position when using dy fns (#2720)
Browse files Browse the repository at this point in the history
  • Loading branch information
carbonrobot authored Jan 16, 2024
1 parent 3073fa0 commit 8854c16
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/moody-mayflies-attack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"victory-core": patch
---

Fix the label background position when using dy fns
2 changes: 1 addition & 1 deletion packages/victory-core/src/victory-label/victory-label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ const getCalculatedProps = <T extends VictoryLabelProps>(props: T) => {
verticalAnchor,
dx,
dy,
originalDy: props.dy,
originalDy: Helpers.evaluateProp(props.dy, props),
transform,
x,
y,
Expand Down
32 changes: 32 additions & 0 deletions stories/victory-label.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,38 @@ export const BackgroundStyles = () => {
/>
}
/>
<VictoryScatter
{...defaultScatterProps}
labelComponent={
<VictoryLabel
dy={({ datum }) => (datum.y > 0 ? -5 : 8)}
verticalAnchor="end"
backgroundPadding={{ top: 5, right: 5, bottom: 5, left: 5 }}
backgroundStyle={{ fill: "plum", stroke: "#000000" }}
text={[
"Victory is awesome.",
"background styles",
"work with dy functions",
]}
/>
}
/>
<VictoryScatter
{...defaultScatterProps}
labelComponent={
<VictoryLabel
dx={({ datum }) => (datum.y > 0 ? -5 : 8)}
verticalAnchor="end"
backgroundPadding={{ top: 5, right: 5, bottom: 5, left: 5 }}
backgroundStyle={{ fill: "thistle", stroke: "#000000" }}
text={[
"Victory is awesome.",
"background styles",
"work with dx functions",
]}
/>
}
/>
</div>
);
};
Expand Down

1 comment on commit 8854c16

@vercel
Copy link

@vercel vercel bot commented on 8854c16 Jan 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.