From 9b92c1ded7a4cd6f7bb64a16bee1429a7dbf58fb Mon Sep 17 00:00:00 2001 From: Haneet Singh Date: Tue, 21 Jan 2025 11:15:30 -0500 Subject: [PATCH 1/2] fix: handle empty labelStyle values --- packages/victory-candlestick/src/helper-methods.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/victory-candlestick/src/helper-methods.ts b/packages/victory-candlestick/src/helper-methods.ts index f9918e578..954fc3abf 100644 --- a/packages/victory-candlestick/src/helper-methods.ts +++ b/packages/victory-candlestick/src/helper-methods.ts @@ -268,13 +268,13 @@ const calculatePlotValues = (props) => { const dy = orientation === "top" || orientation === "bottom" - ? signY * (candleWidth / 2) + signY * (labelStyle.padding || 0) + ? signY * (candleWidth / 2) + signY * (labelStyle?.padding || 0) : 0; const dx = orientation === "top" || orientation === "bottom" ? 0 - : signX * (labelStyle.padding || 1); + : signX * (labelStyle?.padding || 1); return { yValue, xValue, dx, dy }; } @@ -283,13 +283,13 @@ const calculatePlotValues = (props) => { const dy = orientation === "top" || orientation === "bottom" - ? signY * (labelStyle.padding || 1) + ? signY * (labelStyle?.padding || 1) : 0; const dx = orientation === "top" || orientation === "bottom" ? 0 - : signX * (candleWidth / 2) + signX * (labelStyle.padding || 0); + : signX * (candleWidth / 2) + signX * (labelStyle?.padding || 0); return { yValue, xValue, dx, dy }; }; @@ -358,10 +358,10 @@ const getLabelProps = (props, text, style, type?: string) => { datum, data, orientation, - textAnchor: labelStyle.textAnchor || defaultTextAnchors[orientation], + textAnchor: labelStyle?.textAnchor || defaultTextAnchors[orientation], verticalAnchor: - labelStyle.verticalAnchor || defaultVerticalAnchors[orientation], - angle: labelStyle.angle, + labelStyle?.verticalAnchor || defaultVerticalAnchors[orientation], + angle: labelStyle?.angle, horizontal, }; From 1c2764878ceae94035247786fa38238978e79365 Mon Sep 17 00:00:00 2001 From: Haneet Singh Date: Tue, 21 Jan 2025 11:29:28 -0500 Subject: [PATCH 2/2] Add changeset --- .changeset/silver-crabs-deliver.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/silver-crabs-deliver.md diff --git a/.changeset/silver-crabs-deliver.md b/.changeset/silver-crabs-deliver.md new file mode 100644 index 000000000..65d924f97 --- /dev/null +++ b/.changeset/silver-crabs-deliver.md @@ -0,0 +1,5 @@ +--- +"victory-candlestick": minor +--- + +Handle undefined labelStyle properties in VictoryCandlestick. Fixes #3039