From 48e28c1f8a366096fa39ff4c646e9838f2cf8ddd Mon Sep 17 00:00:00 2001 From: Charlie Brown Date: Tue, 16 Jan 2024 10:39:37 -0600 Subject: [PATCH 1/2] Fix the label background position when using dy fns --- .changeset/moody-mayflies-attack.md | 5 ++++ .../src/victory-label/victory-label.tsx | 2 +- stories/victory-label.stories.js | 24 +++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 .changeset/moody-mayflies-attack.md diff --git a/.changeset/moody-mayflies-attack.md b/.changeset/moody-mayflies-attack.md new file mode 100644 index 000000000..997e98d8c --- /dev/null +++ b/.changeset/moody-mayflies-attack.md @@ -0,0 +1,5 @@ +--- +"victory-core": patch +--- + +Fix the label background position when using dy fns diff --git a/packages/victory-core/src/victory-label/victory-label.tsx b/packages/victory-core/src/victory-label/victory-label.tsx index 3b671a6a9..41dcbe9a9 100644 --- a/packages/victory-core/src/victory-label/victory-label.tsx +++ b/packages/victory-core/src/victory-label/victory-label.tsx @@ -508,7 +508,7 @@ const getCalculatedProps = (props: T) => { verticalAnchor, dx, dy, - originalDy: props.dy, + originalDy: Helpers.evaluateProp(props.dy, props), transform, x, y, diff --git a/stories/victory-label.stories.js b/stories/victory-label.stories.js index 66b094861..d0fca92e0 100644 --- a/stories/victory-label.stories.js +++ b/stories/victory-label.stories.js @@ -581,6 +581,30 @@ export const BackgroundStyles = () => { /> } /> + (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"]} + /> + } + /> + (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"]} + /> + } + /> ); }; From 1bf75eb093a598d3ca80091003f3e2785e9fcd7b Mon Sep 17 00:00:00 2001 From: Charlie Brown Date: Tue, 16 Jan 2024 10:47:08 -0600 Subject: [PATCH 2/2] Formatting --- stories/victory-label.stories.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/stories/victory-label.stories.js b/stories/victory-label.stories.js index d0fca92e0..20c9752e4 100644 --- a/stories/victory-label.stories.js +++ b/stories/victory-label.stories.js @@ -589,7 +589,11 @@ export const BackgroundStyles = () => { 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"]} + text={[ + "Victory is awesome.", + "background styles", + "work with dy functions", + ]} /> } /> @@ -601,7 +605,11 @@ export const BackgroundStyles = () => { 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"]} + text={[ + "Victory is awesome.", + "background styles", + "work with dx functions", + ]} /> } />