chartjs / chartjs-chart-financial

Chart.js module for charting financial securities
MIT License
720 stars 195 forks source link

Using this module with react ? #124

Open Baribj opened 2 years ago

Baribj commented 2 years ago

Hi there,

Any idea how would one use this module with react.js

I did

import {
  Chart as ChartJS,
  CategoryScale,
  LinearScale,
  PointElement,
  LineElement,
  Title,
  Tooltip,
  Legend,
} from "chart.js"

import { Chart } from "react-chartjs-2";

import "../public/static/chartjs-chart-financial";

But then I got stuck, not sure where to take it from here.

P.S I am trying to use candlestick chart

MehGokalp commented 1 year ago

as i spent some hours on this repository i think i can answer 🤓 this plugin only registers it's component into chartjs. when you call "import" it registers automatically and only thing that you need is changing the chart type to "candlestick" instead of barchart or line..

anyway if you need to access it's components i think there is a way to do;

import { OhlcElement, OhlcController, CandlestickElement, CandlestickController } from 'chartjs-chart-financial'
import Chart from 'chart.js/auto' // Easy way of importing everything

Chart.register(OhlcElement, OhlcController, CandlestickElement, CandlestickController)

i found it from web. i hope it helps

posiaden123 commented 1 year ago

Necroing, but this helps a lot, thanks.