Hooks API

React hooks provided by react-echarts-kit for enhanced functionality.

useResponsiveChart

A hook for making charts automatically responsive to container size changes.

Import

tsx

Usage

tsx

Return Value

PropertyTypeDescription
containerRefRefObject<HTMLDivElement>Ref to attach to the container element
dimensions{ width: number, height: number }Current container dimensions

useChartTheme

A hook for managing chart themes and accessing theme-related utilities.

Import

tsx

Usage

tsx

Return Value

PropertyTypeDescription
currentThemestringCurrent active theme name
setTheme(theme: string) => voidFunction to change the current theme
getThemeColors() => string[]Get color palette for current theme
themesstring[]Array of available theme names

useChartData

A hook for managing and transforming chart data with built-in utilities.

Import

tsx

Usage

tsx

Return Value

PropertyTypeDescription
dataChartData[]Current processed data array
sortData(key: string, order: 'asc' | 'desc') => voidSort data by specified key and order
filterData(predicate: (item: ChartData) => boolean) => voidFilter data using predicate function
transformData(transformer: (item: ChartData) => ChartData) => voidTransform data using mapper function
resetData() => voidReset data to original state