You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by kr...@apache.org on 2020/03/23 19:35:46 UTC
[incubator-superset] branch master updated: refactor: remove
settooltip (#9332)
This is an automated email from the ASF dual-hosted git repository.
kristw pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
The following commit(s) were added to refs/heads/master by this push:
new f4087d2 refactor: remove settooltip (#9332)
f4087d2 is described below
commit f4087d2ad2801e3974ed715f32e6d17f991fcaa7
Author: Krist Wongsuphasawat <kr...@gmail.com>
AuthorDate: Mon Mar 23 12:35:31 2020 -0700
refactor: remove settooltip (#9332)
---
superset-frontend/src/chart/ChartRenderer.jsx | 74 ++++++---------------------
1 file changed, 17 insertions(+), 57 deletions(-)
diff --git a/superset-frontend/src/chart/ChartRenderer.jsx b/superset-frontend/src/chart/ChartRenderer.jsx
index 304644e..2adfd33 100644
--- a/superset-frontend/src/chart/ChartRenderer.jsx
+++ b/superset-frontend/src/chart/ChartRenderer.jsx
@@ -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}
+ />
);
}
}