From 22c4e2161abe73b13130a9e7110899e7592128ad Mon Sep 17 00:00:00 2001 From: Osama Ahmed Date: Sun, 4 Jun 2023 22:14:53 +0500 Subject: [PATCH] Fixed usePrice.ts dataIndex issue --- src/charts/line/usePrice.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/charts/line/usePrice.ts b/src/charts/line/usePrice.ts index 280d31c..7ec0a2f 100644 --- a/src/charts/line/usePrice.ts +++ b/src/charts/line/usePrice.ts @@ -19,7 +19,8 @@ export function useLineChartPrice({ ) return ''; let price = 0; - price = data[Math.min(index ?? currentIndex.value, data.length - 1)].value; + const dataIndex = Math.min(index ?? currentIndex.value, data.length - 1); + price = data[dataIndex !== -1 ? dataIndex : 0].value; return price.toFixed(precision).toString(); }, [currentIndex, data, precision]); const formatted = useDerivedValue(() => {