Skip to content

Commit 75549cf

Browse files
haneetsinghHaneet Singh
andauthored
fix: handle empty labelStyle values (#3043)
Co-authored-by: Haneet Singh <haneet.singh@everstream.ai>
1 parent 1687982 commit 75549cf

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

.changeset/silver-crabs-deliver.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"victory-candlestick": minor
3+
---
4+
5+
Handle undefined labelStyle properties in VictoryCandlestick. Fixes #3039

packages/victory-candlestick/src/helper-methods.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -268,13 +268,13 @@ const calculatePlotValues = (props) => {
268268

269269
const dy =
270270
orientation === "top" || orientation === "bottom"
271-
? signY * (candleWidth / 2) + signY * (labelStyle.padding || 0)
271+
? signY * (candleWidth / 2) + signY * (labelStyle?.padding || 0)
272272
: 0;
273273

274274
const dx =
275275
orientation === "top" || orientation === "bottom"
276276
? 0
277-
: signX * (labelStyle.padding || 1);
277+
: signX * (labelStyle?.padding || 1);
278278

279279
return { yValue, xValue, dx, dy };
280280
}
@@ -283,13 +283,13 @@ const calculatePlotValues = (props) => {
283283

284284
const dy =
285285
orientation === "top" || orientation === "bottom"
286-
? signY * (labelStyle.padding || 1)
286+
? signY * (labelStyle?.padding || 1)
287287
: 0;
288288

289289
const dx =
290290
orientation === "top" || orientation === "bottom"
291291
? 0
292-
: signX * (candleWidth / 2) + signX * (labelStyle.padding || 0);
292+
: signX * (candleWidth / 2) + signX * (labelStyle?.padding || 0);
293293

294294
return { yValue, xValue, dx, dy };
295295
};
@@ -358,10 +358,10 @@ const getLabelProps = (props, text, style, type?: string) => {
358358
datum,
359359
data,
360360
orientation,
361-
textAnchor: labelStyle.textAnchor || defaultTextAnchors[orientation],
361+
textAnchor: labelStyle?.textAnchor || defaultTextAnchors[orientation],
362362
verticalAnchor:
363-
labelStyle.verticalAnchor || defaultVerticalAnchors[orientation],
364-
angle: labelStyle.angle,
363+
labelStyle?.verticalAnchor || defaultVerticalAnchors[orientation],
364+
angle: labelStyle?.angle,
365365
horizontal,
366366
};
367367

0 commit comments

Comments
 (0)