refactor: remove settooltip (#9332)
This commit is contained in:
parent
5e6662ab12
commit
f4087d2ad2
|
|
@ -21,7 +21,6 @@ import { snakeCase } from 'lodash';
|
|||
import PropTypes from 'prop-types';
|
||||
import React from 'react';
|
||||
import { SuperChart } from '@superset-ui/chart';
|
||||
import { Tooltip } from 'react-bootstrap';
|
||||
import { Logger, LOG_ACTIONS_RENDER_CHART } from '../logger/LogUtils';
|
||||
|
||||
const propTypes = {
|
||||
|
|
@ -62,11 +61,8 @@ const defaultProps = {
|
|||
class ChartRenderer extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {};
|
||||
|
||||
this.hasQueryResponseChange = false;
|
||||
|
||||
this.setTooltip = this.setTooltip.bind(this);
|
||||
this.handleAddFilter = this.handleAddFilter.bind(this);
|
||||
this.handleRenderSuccess = this.handleRenderSuccess.bind(this);
|
||||
this.handleRenderFailure = this.handleRenderFailure.bind(this);
|
||||
|
|
@ -76,13 +72,12 @@ class ChartRenderer extends React.Component {
|
|||
onAddFilter: this.handleAddFilter,
|
||||
onError: this.handleRenderFailure,
|
||||
setControlValue: this.handleSetControlValue,
|
||||
setTooltip: this.setTooltip,
|
||||
onFilterMenuOpen: this.props.onFilterMenuOpen,
|
||||
onFilterMenuClose: this.props.onFilterMenuClose,
|
||||
};
|
||||
}
|
||||
|
||||
shouldComponentUpdate(nextProps, nextState) {
|
||||
shouldComponentUpdate(nextProps) {
|
||||
const resultsReady =
|
||||
nextProps.queryResponse &&
|
||||
['success', 'rendered'].indexOf(nextProps.chartStatus) > -1 &&
|
||||
|
|
@ -98,7 +93,6 @@ class ChartRenderer extends React.Component {
|
|||
nextProps.annotationData !== this.props.annotationData ||
|
||||
nextProps.height !== this.props.height ||
|
||||
nextProps.width !== this.props.width ||
|
||||
nextState.tooltip !== this.state.tooltip ||
|
||||
nextProps.triggerRender ||
|
||||
nextProps.formData.color_scheme !== this.props.formData.color_scheme
|
||||
) {
|
||||
|
|
@ -108,10 +102,6 @@ class ChartRenderer extends React.Component {
|
|||
return false;
|
||||
}
|
||||
|
||||
setTooltip(tooltip) {
|
||||
this.setState({ tooltip });
|
||||
}
|
||||
|
||||
handleAddFilter(col, vals, merge = true, refresh = true) {
|
||||
this.props.addFilter(col, vals, merge, refresh);
|
||||
}
|
||||
|
|
@ -164,33 +154,6 @@ class ChartRenderer extends React.Component {
|
|||
}
|
||||
}
|
||||
|
||||
renderTooltip() {
|
||||
const { tooltip } = this.state;
|
||||
if (tooltip && tooltip.content) {
|
||||
return (
|
||||
<Tooltip
|
||||
className="chart-tooltip"
|
||||
id="chart-tooltip"
|
||||
placement="right"
|
||||
positionTop={tooltip.y + 30}
|
||||
positionLeft={tooltip.x + 30}
|
||||
arrowOffsetTop={10}
|
||||
>
|
||||
{typeof tooltip.content === 'string' ? (
|
||||
<div // eslint-disable-next-line react/no-danger
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: dompurify.sanitize(tooltip.content),
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
tooltip.content
|
||||
)}
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
render() {
|
||||
const {
|
||||
chartAlert,
|
||||
|
|
@ -233,25 +196,22 @@ class ChartRenderer extends React.Component {
|
|||
: snakeCaseVizType;
|
||||
|
||||
return (
|
||||
<>
|
||||
{this.renderTooltip()}
|
||||
<SuperChart
|
||||
disableErrorBoundary
|
||||
id={`chart-id-${chartId}`}
|
||||
className={chartClassName}
|
||||
chartType={vizType}
|
||||
width={width}
|
||||
height={height}
|
||||
annotationData={annotationData}
|
||||
datasource={datasource}
|
||||
initialValues={initialValues}
|
||||
formData={formData}
|
||||
hooks={this.hooks}
|
||||
queryData={queryResponse}
|
||||
onRenderSuccess={this.handleRenderSuccess}
|
||||
onRenderFailure={this.handleRenderFailure}
|
||||
/>
|
||||
</>
|
||||
<SuperChart
|
||||
disableErrorBoundary
|
||||
id={`chart-id-${chartId}`}
|
||||
className={chartClassName}
|
||||
chartType={vizType}
|
||||
width={width}
|
||||
height={height}
|
||||
annotationData={annotationData}
|
||||
datasource={datasource}
|
||||
initialValues={initialValues}
|
||||
formData={formData}
|
||||
hooks={this.hooks}
|
||||
queryData={queryResponse}
|
||||
onRenderSuccess={this.handleRenderSuccess}
|
||||
onRenderFailure={this.handleRenderFailure}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue