diff --git a/src/components/CandleChart.tsx b/src/components/CandleChart.tsx index 22c70c0..8f12c8e 100644 --- a/src/components/CandleChart.tsx +++ b/src/components/CandleChart.tsx @@ -136,13 +136,15 @@ const CandleChart = forwardRef( useEffect(() => { if (!seriesRef.current || candles.length === 0) return; - const chartData: CandlestickData[] = candles.map((candle) => ({ - time: candle.time as Time, - open: candle.open, - high: candle.high, - low: candle.low, - close: candle.close, - })); + const chartData: CandlestickData[] = candles + .map((candle) => ({ + time: candle.time as Time, + open: candle.open, + high: candle.high, + low: candle.low, + close: candle.close, + })) + .sort((a, b) => (a.time as number) - (b.time as number)); seriesRef.current.setData(chartData); }, [candles]);