mirror of
https://github.com/apache/superset.git
synced 2026-04-23 18:14:56 +00:00
[vis] bug num improvements (#2523)
* fix js error, make should render viz more readable, add tooltips, style axis and add min/max to xaxis * put getTextWidth in utils * add document to eslint globals config
This commit is contained in:
@@ -56,19 +56,22 @@ class ChartContainer extends React.PureComponent {
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps) {
|
||||
if (
|
||||
(
|
||||
prevProps.queryResponse !== this.props.queryResponse ||
|
||||
prevProps.height !== this.props.height ||
|
||||
this.props.triggerRender
|
||||
) && !this.props.queryResponse.error
|
||||
&& this.props.chartStatus !== 'failed'
|
||||
&& this.props.chartStatus !== 'stopped'
|
||||
) {
|
||||
if (this.shouldRenderViz(prevProps)) {
|
||||
this.renderViz();
|
||||
}
|
||||
}
|
||||
|
||||
shouldRenderViz(prevProps) {
|
||||
const hasHeightChanged = prevProps.height !== this.props.height;
|
||||
const hasQueryChanged = prevProps.queryResponse !== this.props.queryResponse;
|
||||
const hasErrors = this.props.queryResponse && this.props.queryResponse.error;
|
||||
|
||||
return (hasQueryChanged || hasHeightChanged || this.props.triggerRender)
|
||||
&& !hasErrors
|
||||
&& this.props.chartStatus !== 'failed'
|
||||
&& this.props.chartStatus !== 'stopped';
|
||||
}
|
||||
|
||||
getMockedSliceObject() {
|
||||
const props = this.props;
|
||||
const getHeight = () => {
|
||||
|
||||
@@ -188,3 +188,11 @@ export function customizeToolTip(chart, xAxisFormatter, yAxisFormatters) {
|
||||
return tooltip;
|
||||
});
|
||||
}
|
||||
|
||||
export function getTextWidth(text, fontDetails) {
|
||||
const canvas = document.createElement('canvas');
|
||||
const context = canvas.getContext('2d');
|
||||
context.font = fontDetails;
|
||||
const metrics = context.measureText(text);
|
||||
return metrics.width;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user