From 29d42db8d82ac31fc10eb7b3a6de16f8f7121562 Mon Sep 17 00:00:00 2001 From: Kenan Date: Wed, 17 Jan 2024 08:51:40 +0000 Subject: [PATCH] Fix regression --- packages/victory-histogram/src/helper-methods.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/victory-histogram/src/helper-methods.ts b/packages/victory-histogram/src/helper-methods.ts index c9c40e0f1..1ca648105 100644 --- a/packages/victory-histogram/src/helper-methods.ts +++ b/packages/victory-histogram/src/helper-methods.ts @@ -98,16 +98,19 @@ export const getFormattedData = cacheLastValue( }); const formattedData = binnedData.map((bin) => { - const x0 = bin.x0 instanceof Date ? new Date(bin.x0) : bin.x0; - const x1 = bin.x1 instanceof Date ? new Date(bin.x1) : bin.x1; + const x0 = dataOrBinsContainsDates + ? new Date(bin.x0 as Date) + : bin.x0 || 0; + const x1 = dataOrBinsContainsDates + ? new Date(bin.x1 as Date) + : bin.x1 || 0; return { x0, x1, - x: - x0 instanceof Date && x1 instanceof Date - ? new Date((x0.getTime() + x1.getTime()) / 2) - : ((x0 as number) + (x1 as number)) / 2, + x: dataOrBinsContainsDates + ? new Date(((x0 as Date).getTime() + (x1 as Date).getTime()) / 2) + : ((x0 as number) + (x1 as number)) / 2, y: bin.length, binnedData: [...bin], };