Skip to content

Commit

Permalink
Chart autorun in preview (#2180)
Browse files Browse the repository at this point in the history
  • Loading branch information
Marginy605 authored Feb 21, 2025
1 parent 22f7fbb commit a162a17
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/ui/units/editor/components/Preview/Preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import React from 'react';

import block from 'bem-cn-lite';
import PropTypes from 'prop-types';
import {useDispatch} from 'react-redux';
import {useLocation} from 'react-router-dom';
import {MenuType} from 'ui/libs/DatalensChartkit/menu/constants';

import {ChartWrapper} from '../../../../components/Widgets/Chart/ChartWidgetWithProvider';
import {URL_QUERY} from '../../../../constants';
import Utils, {UrlSearch} from '../../../../utils';
import {Status} from '../../constants/common';
import {drawPreview} from '../../store/actions';

import './Preview.scss';

Expand Down Expand Up @@ -74,12 +76,19 @@ function PreviewWrap(props) {
}, [search]);
const {actionParamsEnabled} = Utils.getOptionsFromSearch(search);

const dispatch = useDispatch();

React.useEffect(() => {
if (widgetRef.current && typeof widgetRef.current.reflow === 'function') {
widgetRef.current.reflow();
}
}, [paneSize]);

React.useEffect(() => {
dispatch(drawPreview());
// dependance from chartData?.id for loading chart preview after opening other chart from navigation
}, [chartData?.id]);

if (chartData === null) {
return null;
}
Expand Down

0 comments on commit a162a17

Please sign in to comment.