2021-08-29 22:54:21 +03:00
|
|
|
import { ActiveElement, ChartEvent, ChartType, TooltipItem } from 'chart.js';
|
2020-09-20 12:46:07 +03:00
|
|
|
import { prettify } from './numbers';
|
2020-09-20 12:43:24 +03:00
|
|
|
|
2021-08-29 22:54:21 +03:00
|
|
|
export const pointerOnHover = ({ native }: ChartEvent, [ firstElement ]: ActiveElement[]) => {
|
|
|
|
if (!native?.target) {
|
|
|
|
return;
|
|
|
|
}
|
2020-09-20 12:46:07 +03:00
|
|
|
|
2021-08-29 22:54:21 +03:00
|
|
|
(native.target as any).style.cursor = firstElement ? 'pointer' : 'default';
|
2020-09-20 12:46:07 +03:00
|
|
|
};
|
|
|
|
|
2021-08-29 22:54:21 +03:00
|
|
|
export const renderChartLabel = ({ dataset, label }: TooltipItem<ChartType>) => `${dataset.label}: ${prettify(label)}`;
|