@kumo-charts/react
The API reference is generated from the source comments.
import { … } from '@kumo-charts/react';
Functions
useKumoChartfunctionSource
function useKumoChart<const M extends readonly ChartModule[] = readonly []>(
options?: CreateChartOptions<M>
): [ref: (element: HTMLElement | null) => void, chart: Chart<M> | null]
Creates a chart in the element that receives the returned ref, with the modules of the
options as they are then, and destroys it when the element goes away. The other options are
applied with chart.applyOptions() whenever a new object is passed, so keep them stable (a
module constant or useMemo).
const [ref, chart] = useKumoChart({ modules: [indicators(allIndicators)] });
useEffect(() => chart?.data.set(bars), [chart, bars]);
return <div ref={ref} style={{ height: 480 }} />;Interfaces
KumoChartPropsinterfaceSource
interface KumoChartProps extends KumoChartEventHandlers
modules?: readonly ChartModule[]The chart's modules, such as [indicators(allIndicators)], read when it is created.
options?: ChartOptionsInput & Readonly<Record<string, unknown>>Applied with chart.applyOptions() whenever a new object is passed, the options of the
modules too.
data?: readonly BarInput[]Replaces all bars when a new array or interval is passed.
interval?: IntervalInputResolution of data, such as '1m'; needed for timeframe and chart.data.addTrades().
timeframe?: IntervalInput | nullThe displayed timeframe, such as '15m'; null shows the source resolution.
transform?: BarTransformInput | nullBuilds the displayed bars, e.g. { type: 'renko' }; null shows the timeframe's bars.
orders?: readonly OrderInput[]Needs the orders module.
markers?: readonly MarkerInput[]Needs the markers module.
alerts?: readonly AlertInput[]Needs the alerts module.
className?: stringstyle?: CSSPropertiesMerged over the default width: 100%; height: 100%.
onReady?: (chart: Chart) => voidCalled once the chart is created, after the props above were applied.
Types
KumoChartEventHandlerstypeSource
type KumoChartEventHandlers = {
[K in KumoChartEventName as `on${Capitalize<K>}`]?: (event: KumoChartEventMap[K]) => void;
}
One optional on* prop per event of the chart and its modules, e.g. onCrosshairMove or
onOrderDrag.
KumoChartEventMaptypeSource
type KumoChartEventMap = AllEventMap
The events of the chart and of its modules; those of a module the chart lacks never fire.
KumoChartEventNametypeSource
type KumoChartEventName = keyof KumoChartEventMap
The name of an event of the chart or of one of its modules.
Variables
KumoChartvariableSource
const KumoChart: React.ForwardRefExoticComponent<KumoChartProps & React.RefAttributes<ChartBase<unknown, unknown, unknown> | null>>
React component around createChart(). modules are read when the chart is created. Props
replace the chart's data, orders, markers or alerts whenever a new value is passed (compare by
reference, as React state does); every event of the chart and its modules is available as an
on* prop, plus onReady with the chart instance. A ref receives the chart instance. Stream
real-time bars with chart.data.update().