react-lightweight-charts-simple
Version:
A simple react wrapper for lightweight-charts library
43 lines (42 loc) • 1.79 kB
TypeScript
import type { IChartApi, ISeriesApi, MouseEventParams, SeriesOptionsMap } from 'lightweight-charts';
import * as React from 'react';
export declare type MakeTransform = (chart: IChartApi | undefined, event: MouseEventParams | undefined, container: HTMLDivElement | null, tooltipSize: {
width: number;
height: number;
}) => string | undefined;
export interface TooltipProps extends React.HTMLAttributes<HTMLDivElement> {
/**
* A render function for creating `ReactNode` base on the crosshair event.
*/
content?: (props: {
/**
* crosshair event object.
*/
event: MouseEventParams;
/**
* chart api object.
*/
chart: IChartApi | undefined;
/**
* series api object, exist only when the component is placed inside `<Series />`.
*/
series?: ISeriesApi<keyof SeriesOptionsMap> | undefined;
}) => React.ReactNode;
/**
* Should return a transform string for the tooltip wrapper, return `undefined` to keep unchanged.
* Useful for changing the tooltip position.
*/
makeTransform?: MakeTransform;
}
export declare const DEFAULT_TOOLTIP_STYLE: React.CSSProperties;
/**
* Default transform makes tooltip to be horizontally centered with cursor, and above the cursor.
* Tooltip is also bounded inside the chart box and may be below the cursor if not enough vertical space.
*/
export declare const DEFAULT_TOOLTIP_MAKE_TRANSFORM: MakeTransform;
/**
* A tooltip will be flow in front of the chart and follow the crosshair movement.
*
* ❗Only use inside `<Chart />` or `<Series />`.
*/
export declare const Tooltip: React.ForwardRefExoticComponent<TooltipProps & React.RefAttributes<HTMLDivElement>>;