diff --git a/src/plugins/indicator/renderer/IndicatorWidget.tsx b/src/plugins/indicator/renderer/IndicatorWidget.tsx index 2a30d510..64e096bb 100644 --- a/src/plugins/indicator/renderer/IndicatorWidget.tsx +++ b/src/plugins/indicator/renderer/IndicatorWidget.tsx @@ -4,6 +4,7 @@ import {isEmpty} from 'lodash'; import {i18n} from '../../../i18n'; import {CHARTKIT_ERROR_CODE, ChartKitError} from '../../../libs'; import {CHARTKIT_SCROLLABLE_NODE_CLASSNAME} from '../../../constants'; +import {getChartPerformanceDuration, getRandomCKId, markChartPerformance} from '../../../utils'; import type {ChartKitWidgetRef, ChartKitProps} from '../../../types'; import {IndicatorItem} from './IndicatorItem'; @@ -19,13 +20,26 @@ const IndicatorWidget = React.forwardRef `${id}_${getRandomCKId()}`, + [data, defaultColor, formatNumber, id], + ); + React.useLayoutEffect(() => { - // TODO: swap to onRender after https://github.com/gravity-ui/chartkit/issues/33 - onLoad?.(); - // TODO: add onRender with renderTime Issue #114 - }); + markChartPerformance(generatedId); + }, [generatedId]); + + React.useEffect(() => { + if (onRender) { + onRender({renderTime: getChartPerformanceDuration(generatedId)}); + return; + } + onLoad?.({widgetRendering: getChartPerformanceDuration(generatedId)}); + }, [onLoad, onRender, generatedId]); if (isEmpty(data)) { throw new ChartKitError({