react-financial / react-financial-charts

Charts dedicated to finance.
https://react-financial.github.io/react-financial-charts/
MIT License
1.2k stars 211 forks source link

Simple chart plotting only 'close' of a stock #697

Open homerokzam opened 11 months ago

homerokzam commented 11 months ago

I'm submitting a...

What is the current behavior

evaluator.ts:157 Uncaught TypeError: Cannot read properties of undefined (reading 'invert')

What is the expected behavior

Simple line chart plot

Please tell us about your environment

node: v20.5.0 react: "^18.2.0"

Other information

import { ChartCanvas, Chart, LineSeries, CandlestickSeries, XAxis, YAxis, discontinuousTimeScaleProvider } from "react-financial-charts";

const CustomChartCanvas = (props) => { const ohlcData = props.data.map(item => ({ date: new Date(item.Date), open: item.Open, high: item.High, low: item.Low, close: item.Close, volume: item.Volume }));

// console.log(ohlcData);

return ( <> {ohlcData && ( <ChartCanvas height={400} width={800} ratio={3} type={'svg'} margin={{ left: 50, right: 50, top: 10, bottom: 30 }} data={ohlcData} seriesName="OHLC" xAccessor={d => d.date} xScaleProvider={discontinuousTimeScaleProvider} xExtents={[ohlcData[0].date, ohlcData[ohlcData.length - 1].date]} > <Chart id={1} yExtents={d => [d.high, d.low]}>

        <YAxis />

          <LineSeries yAccessor={d => d.close} />
      </Chart>
    </ChartCanvas>
  )}
</>

) }

export default CustomChartCanvas;