A simple react wrapper for lightweight-charts library.
npm install --save react-lightweight-charts-simple lightweight-charts
// or
yarn add react-lightweight-charts-simple lightweight-chartsimport React from 'react';
import { Chart, AreaSeries } from 'react-lightweight-charts';
export const App = () => {
// Memoize data to prevent setting data multiple times
const data = React.useMemo(() => [
{ time: '2022-02-01', value: 100 },
{ time: '2022-02-02', value: 300 },
{ time: '2022-02-03', value: 500 },
{ time: '2022-02-04', value: 700 },
{ time: '2022-02-05', value: 600 },
{ time: '2022-02-06', value: 400 },
{ time: '2022-02-07', value: 200 },
{ time: '2022-02-08', value: 500 },
{ time: '2022-02-09', value: 800 },
{ time: '2022-02-10', value: 1000 },
]);
return (
<Chart height={300}>
<AreaSeries data={data} />
</Chart>
);
}Here is also a complex example
These are the wrapper components for using lightweight-charts.
-
<Series />(abstract type)Only usable inside
<Chart /><AreaSeries /><BarSeries /><BaselineSeries /><CandlestickSeries /><HistogramSeries /><LineSeries />
-
Only usable inside
<Series />
-
Only usable inside
<Chart />or<Series />You can also add your custom helper components by referencing it.
These do not render any visual, just for effect.
<ChartAutoResizer /><ChartFitContentTrigger /><ChartOnClickSubscriber /><ChartOnCrosshairMoveSubscriber /><TimeScaleOnSizeChangeSubscriber /><TimeScaleOnVisibleTimeRangeChangeSubscriber /><TimeScaleOnVisibleLogicalRangeChangeSubscriber /><SeriesHoverDataSubscriber />
You can also add your custom utility components by referencing any one of the above.
useChart()to getIChartApiobject and containerdivreference.useSeries()to getISeriesApiobject.