diff --git a/src/plugins/yagr/renderer/YagrWidget.tsx b/src/plugins/yagr/renderer/YagrWidget.tsx index 0654c7cd..c4e50815 100644 --- a/src/plugins/yagr/renderer/YagrWidget.tsx +++ b/src/plugins/yagr/renderer/YagrWidget.tsx @@ -1,6 +1,7 @@ import React from 'react'; import moment from 'moment'; import debounce from 'lodash/debounce'; +import isEmpty from 'lodash/isEmpty'; import {useThemeType} from '@gravity-ui/uikit'; import YagrComponent, {YagrChartProps} from 'yagr/dist/react'; import { @@ -11,10 +12,12 @@ import { ValueFormatter, MinimalValidConfig, } from 'yagr'; +import {i18n} from '../../../i18n'; import type {ChartKitWidgetRef, ChartKitProps} from '../../../types'; -import {settings} from '../../../libs'; +import {settings, CHARTKIT_ERROR_CODE, ChartKitError} from '../../../libs'; import {formatTooltip, TooltipData, TooltipLine} from './tooltip/tooltip'; import {synchronizeTooltipTablesCellsWidth} from './synchronizeTooltipTablesCellsWidth'; + import './polyfills'; import './YagrWidget.scss'; @@ -120,6 +123,13 @@ const YagrWidget = React.forwardRef((props const {id, onLoad} = props; const theme = useThemeType() as YagrConfig['settings']['theme']; + if (!data || isEmpty(data)) { + throw new ChartKitError({ + code: CHARTKIT_ERROR_CODE.NO_DATA, + message: i18n('error', 'label_no-data'), + }); + } + const handlers: Record void)> = { mouseMove: null, mouseDown: null,