react-lightweight-charts-simple
Version:
A simple react wrapper for lightweight-charts library
22 lines (18 loc) • 526 B
text/typescript
import type { IChartApi, ISeriesApi, SeriesType } from 'lightweight-charts';
import { createContext, RefObject } from 'react';
export interface ChartContextValue {
/**
* The chart api object.
*/
chart?: IChartApi;
/**
* The chart container `<div />` element.
*/
containerRef: RefObject<HTMLDivElement>;
}
export const ChartContext = createContext<ChartContextValue>({
containerRef: { current: null },
});
export const SeriesContext = createContext<ISeriesApi<SeriesType> | undefined>(
undefined,
);