Skip to content

Commit

Permalink
fix(Yagr): added common no-data case handling (#78)
Browse files Browse the repository at this point in the history
* chore(yagr): added common no-data case processing

* fix(Yagr): fixed import

* fix(Yagr): added i18n
  • Loading branch information
artemipanchuk authored Dec 1, 2022
1 parent ba9213d commit 100efaa
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/plugins/yagr/renderer/YagrWidget.tsx
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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';
Expand Down Expand Up @@ -120,6 +123,13 @@ const YagrWidget = React.forwardRef<ChartKitWidgetRef | undefined, Props>((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<string, null | ((event: MouseEvent) => void)> = {
mouseMove: null,
mouseDown: null,
Expand Down

0 comments on commit 100efaa

Please sign in to comment.