import * as React from 'react'; import smoothie from 'smoothie'; import type { IChartOptions, ITimeSeriesOptions, ITimeSeriesPresentationOptions } from 'smoothie'; import { RenderCoordinator, RenderCoordinatorOptions, globalCoordinator } from './RenderCoordinator.js'; declare const SmoothieChart: typeof smoothie.SmoothieChart, TimeSeries: typeof smoothie.TimeSeries; type SmoothieChart = import('smoothie').SmoothieChart; type TimeSeries = import('smoothie').TimeSeries; export type SmoothieContextValue = { /** Coordinator rendering this subtree's charts, or `null` when charts should self-animate */ coordinator: RenderCoordinator | null; }; /** * `undefined` (no provider) means charts use the module-wide `globalCoordinator`. */ declare const SmoothieContext: React.Context; export type SmoothieProviderProps = RenderCoordinatorOptions & { /** * Set to `false` to restore per-chart self-animation (one `requestAnimationFrame` loop * per chart, as driven by Smoothie Charts itself) for all charts in this subtree. * * _default: `true`_ */ coordinate?: boolean; children?: React.ReactNode; }; /** * Renders all `SmoothieComponent` charts beneath it from a single shared animation loop — * separate from the global one — with optional frame rate cap and pausing. * * Charts don't need a provider to be coordinated; without one they share the global loop. * Use a provider to control `fps`/`paused` for a subtree, or `coordinate={false}` to opt * a subtree out of coordination entirely. The nearest provider wins. */ export declare function SmoothieProvider(props: SmoothieProviderProps): React.JSX.Element; declare function DefaultTooltip(props: { display?: boolean; time?: number; data?: TooltipData; }): React.JSX.Element; export type ToolTip = typeof DefaultTooltip; type CanvasStyle = CanvasGradient | CanvasPattern; /** * undefined means 0 */ type rgba = { r?: number; g?: number; b?: number; a?: number; }; export type PresentationOptions = rgba & { fillStyle?: rgba | CanvasStyle | ITimeSeriesPresentationOptions['fillStyle']; strokeStyle?: rgba | CanvasStyle | ITimeSeriesPresentationOptions['strokeStyle']; } & Omit; type TooltipData = { series: any; index: number; value: number; }[]; type SmoothieComponentState = { tooltip: { time?: number; data?: TooltipData; display?: boolean; top?: number; left?: number; }; }; type Style = { [x: string]: number | string; }; export type SmoothieComponentSeries = { data: TimeSeries; } & PresentationOptions; type Omit = Pick>; /** * Props that we've defined in this package */ type ReactSmoothieProps = { streamDelay?: number; /** Freeze this chart (skip its frames) while `true`. The chart stays mounted and registered. */ paused?: boolean; height?: number; width?: number; series?: SmoothieComponentSeries[]; tooltip?: true | false | ToolTip; doNotSimplifyData?: boolean; style?: Style; tooltipParentStyle?: Style; containerStyle?: Style; classNameCanvas?: string; className?: string; classNameTooltip?: string; classNameContainer?: string; }; /** * Props that we pass onto underlying Smoothie instance */ type SmoothieProps = Omit; export type SmoothieComponentProps = ReactSmoothieProps & SmoothieProps; declare class SmoothieComponent extends React.Component { smoothie: SmoothieChart; canvas: HTMLCanvasElement | null; /** Current canvas binding, so changes to the canvas or animation mode can be detached cleanly */ private streaming?; static contextType: React.Context; context: React.ContextType; static defaultProps: { width: number; height: number; streamDelay: number; }; constructor(props: SmoothieComponentProps); componentWillUnmount(): void; componentDidUpdate(prevProps: SmoothieComponentProps, prevState: SmoothieComponentState): void; private handleCanvasRef; /** The coordinator this chart should register with, or `null` to self-animate */ private activeCoordinator; /** * Make the chart's animation match the current canvas, context, and props. * Idempotent; called on canvas (un)mount and on every update. */ private syncStreaming; /** Undo whatever syncStreaming() set up. Idempotent. */ private detachStreaming; render(): React.JSX.Element; addTimeSeries(addOpts: PresentationOptions): TimeSeries; addTimeSeries(tsOpts: ITimeSeriesOptions, addOpts: PresentationOptions): TimeSeries; removeTimeSeries(ts: TimeSeries): void; } export { SmoothieComponent as default, TimeSeries, DefaultTooltip }; export { RenderCoordinator, globalCoordinator }; export type { RenderCoordinatorOptions };