From dc04d256c4f5864ca9ab4476c99c3592539e77f9 Mon Sep 17 00:00:00 2001 From: leutinatasya Date: Thu, 6 Apr 2023 11:43:24 +0300 Subject: [PATCH] feat(Indicator plugin): add renderTime --- .../indicator/renderer/IndicatorWidget.tsx | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/plugins/indicator/renderer/IndicatorWidget.tsx b/src/plugins/indicator/renderer/IndicatorWidget.tsx index 2a30d510..596ba53e 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,24 @@ const IndicatorWidget = React.forwardRef `${id}_${getRandomCKId()}`, + [data, defaultColor, 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(() => { + // TODO: swap to onRender after https://github.com/yandex-cloud/chartkit/issues/33 + onLoad?.({widgetRendering: getChartPerformanceDuration(generatedId)}); + onRender?.({renderTime: getChartPerformanceDuration(generatedId)}); + }, [onLoad, onRender]); if (isEmpty(data)) { throw new ChartKitError({