betodealmeida closed pull request #5952: [deck_polyline] show metric in geohash
URL: https://github.com/apache/incubator-superset/pull/5952
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/superset/assets/src/chart/Chart.jsx
b/superset/assets/src/chart/Chart.jsx
index 43d13b1845..0d550272d6 100644
--- a/superset/assets/src/chart/Chart.jsx
+++ b/superset/assets/src/chart/Chart.jsx
@@ -1,6 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Tooltip } from 'react-bootstrap';
+import dompurify from 'dompurify';
import ChartBody from './ChartBody';
import Loading from '../components/Loading';
@@ -180,9 +181,13 @@ class Chart extends React.PureComponent {
positionLeft={this.state.tooltip.x + 30}
arrowOffsetTop={10}
>
- <div // eslint-disable-next-line react/no-danger
- dangerouslySetInnerHTML={{ __html: this.state.tooltip.content }}
- />
+ {typeof (this.state.tooltip.content) === 'string' ?
+ <div // eslint-disable-next-line react/no-danger
+ dangerouslySetInnerHTML={{ __html:
dompurify.sanitize(this.state.tooltip.content) }}
+ />
+ :
+ this.state.tooltip.content
+ }
</Tooltip>
);
}
diff --git a/superset/assets/src/visualizations/deckgl/layers/common.js
b/superset/assets/src/visualizations/deckgl/layers/common.jsx
similarity index 82%
rename from superset/assets/src/visualizations/deckgl/layers/common.js
rename to superset/assets/src/visualizations/deckgl/layers/common.jsx
index 0a446dd098..8a3ecc5c7c 100644
--- a/superset/assets/src/visualizations/deckgl/layers/common.js
+++ b/superset/assets/src/visualizations/deckgl/layers/common.jsx
@@ -1,4 +1,4 @@
-import dompurify from 'dompurify';
+import React from 'react';
import { fitBounds } from 'viewport-mercator-project';
import d3 from 'd3';
@@ -37,10 +37,14 @@ export function commonLayerProps(formData, slice) {
let onHover;
let tooltipContentGenerator;
if (fd.js_tooltip) {
- const unsanitizedTooltipGenerator = sandboxedEval(fd.js_tooltip);
- tooltipContentGenerator = o =>
dompurify.sanitize(unsanitizedTooltipGenerator(o));
+ tooltipContentGenerator = sandboxedEval(fd.js_tooltip);
} else if (fd.line_column && fd.line_type === 'geohash') {
- tooltipContentGenerator = o => `${fd.line_column}:
${o.object[fd.line_column]}`;
+ tooltipContentGenerator = o => (
+ <div>
+ <div>{fd.line_column}:
<strong>{o.object[fd.line_column]}</strong></div>
+ {fd.metric &&
+ <div>{fd.metric}: <strong>{o.object[fd.metric]}</strong></div>}
+ </div>);
}
if (tooltipContentGenerator) {
onHover = (o) => {
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]