mirror of
https://github.com/apache/superset.git
synced 2026-04-25 11:04:48 +00:00
fix: Drill to detail blocked by tooltip (#22082)
Co-authored-by: Ville Brofeldt <ville.brofeldt@apple.com>
This commit is contained in:
committed by
GitHub
parent
1809d2b957
commit
3bc0865d90
@@ -20,17 +20,14 @@ import React, { MouseEvent } from 'react';
|
||||
import {
|
||||
t,
|
||||
getNumberFormatter,
|
||||
NumberFormatter,
|
||||
smartDateVerboseFormatter,
|
||||
TimeFormatter,
|
||||
computeMaxFontSize,
|
||||
BRAND_COLOR,
|
||||
styled,
|
||||
BinaryQueryObjectFilterClause,
|
||||
} from '@superset-ui/core';
|
||||
import { EChartsCoreOption } from 'echarts';
|
||||
import Echart from '../components/Echart';
|
||||
import { BigNumberWithTrendlineFormData, TimeSeriesDatum } from './types';
|
||||
import { BigNumberVizProps } from './types';
|
||||
import { EventHandlers } from '../types';
|
||||
|
||||
const defaultNumberFormatter = getNumberFormatter();
|
||||
@@ -44,36 +41,7 @@ const PROPORTION = {
|
||||
TRENDLINE: 0.3,
|
||||
};
|
||||
|
||||
type BigNumberVisProps = {
|
||||
className?: string;
|
||||
width: number;
|
||||
height: number;
|
||||
bigNumber?: number | null;
|
||||
bigNumberFallback?: TimeSeriesDatum;
|
||||
headerFormatter: NumberFormatter | TimeFormatter;
|
||||
formatTime: TimeFormatter;
|
||||
headerFontSize: number;
|
||||
kickerFontSize: number;
|
||||
subheader: string;
|
||||
subheaderFontSize: number;
|
||||
showTimestamp?: boolean;
|
||||
showTrendLine?: boolean;
|
||||
startYAxisAtZero?: boolean;
|
||||
timeRangeFixed?: boolean;
|
||||
timestamp?: number;
|
||||
trendLineData?: TimeSeriesDatum[];
|
||||
mainColor: string;
|
||||
echartOptions: EChartsCoreOption;
|
||||
onContextMenu?: (
|
||||
clientX: number,
|
||||
clientY: number,
|
||||
filters?: BinaryQueryObjectFilterClause[],
|
||||
) => void;
|
||||
xValueFormatter?: TimeFormatter;
|
||||
formData?: BigNumberWithTrendlineFormData;
|
||||
};
|
||||
|
||||
class BigNumberVis extends React.PureComponent<BigNumberVisProps> {
|
||||
class BigNumberVis extends React.PureComponent<BigNumberVizProps> {
|
||||
static defaultProps = {
|
||||
className: '',
|
||||
headerFormatter: defaultNumberFormatter,
|
||||
@@ -108,7 +76,7 @@ class BigNumberVis extends React.PureComponent<BigNumberVisProps> {
|
||||
|
||||
renderFallbackWarning() {
|
||||
const { bigNumberFallback, formatTime, showTimestamp } = this.props;
|
||||
if (!bigNumberFallback || showTimestamp) return null;
|
||||
if (!formatTime || !bigNumberFallback || showTimestamp) return null;
|
||||
return (
|
||||
<span
|
||||
className="alert alert-warning"
|
||||
@@ -125,7 +93,13 @@ class BigNumberVis extends React.PureComponent<BigNumberVisProps> {
|
||||
|
||||
renderKicker(maxHeight: number) {
|
||||
const { timestamp, showTimestamp, formatTime, width } = this.props;
|
||||
if (!showTimestamp) return null;
|
||||
if (
|
||||
!formatTime ||
|
||||
!showTimestamp ||
|
||||
typeof timestamp === 'string' ||
|
||||
typeof timestamp === 'boolean'
|
||||
)
|
||||
return null;
|
||||
|
||||
const text = timestamp === null ? '' : formatTime(timestamp);
|
||||
|
||||
@@ -155,6 +129,7 @@ class BigNumberVis extends React.PureComponent<BigNumberVisProps> {
|
||||
|
||||
renderHeader(maxHeight: number) {
|
||||
const { bigNumber, headerFormatter, width } = this.props;
|
||||
// @ts-ignore
|
||||
const text = bigNumber === null ? t('No data') : headerFormatter(bigNumber);
|
||||
|
||||
const container = this.createTemporaryContainer();
|
||||
@@ -231,7 +206,7 @@ class BigNumberVis extends React.PureComponent<BigNumberVisProps> {
|
||||
}
|
||||
|
||||
renderTrendline(maxHeight: number) {
|
||||
const { width, trendLineData, echartOptions } = this.props;
|
||||
const { width, trendLineData, echartOptions, refs } = this.props;
|
||||
|
||||
// if can't find any non-null values, no point rendering the trendline
|
||||
if (!trendLineData?.some(d => d[1] !== null)) {
|
||||
@@ -264,12 +239,15 @@ class BigNumberVis extends React.PureComponent<BigNumberVisProps> {
|
||||
};
|
||||
|
||||
return (
|
||||
<Echart
|
||||
width={Math.floor(width)}
|
||||
height={maxHeight}
|
||||
echartOptions={echartOptions}
|
||||
eventHandlers={eventHandlers}
|
||||
/>
|
||||
echartOptions && (
|
||||
<Echart
|
||||
refs={refs}
|
||||
width={Math.floor(width)}
|
||||
height={maxHeight}
|
||||
echartOptions={echartOptions}
|
||||
eventHandlers={eventHandlers}
|
||||
/>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -292,7 +270,9 @@ class BigNumberVis extends React.PureComponent<BigNumberVisProps> {
|
||||
<div className="text-container" style={{ height: allTextHeight }}>
|
||||
{this.renderFallbackWarning()}
|
||||
{this.renderKicker(
|
||||
Math.ceil(kickerFontSize * (1 - PROPORTION.TRENDLINE) * height),
|
||||
Math.ceil(
|
||||
(kickerFontSize || 0) * (1 - PROPORTION.TRENDLINE) * height,
|
||||
),
|
||||
)}
|
||||
{this.renderHeader(
|
||||
Math.ceil(headerFontSize * (1 - PROPORTION.TRENDLINE) * height),
|
||||
@@ -311,7 +291,7 @@ class BigNumberVis extends React.PureComponent<BigNumberVisProps> {
|
||||
return (
|
||||
<div className={className} style={{ height }}>
|
||||
{this.renderFallbackWarning()}
|
||||
{this.renderKicker(kickerFontSize * height)}
|
||||
{this.renderKicker((kickerFontSize || 0) * height)}
|
||||
{this.renderHeader(Math.ceil(headerFontSize * height))}
|
||||
{this.renderSubheader(Math.ceil(subheaderFontSize * height))}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user