|
17 | 17 | * under the License.
|
18 | 18 | */
|
19 | 19 | import React, { createRef, useMemo } from 'react';
|
20 |
| -import { css, styled, useTheme } from '@superset-ui/core'; |
| 20 | +import { css, styled, t, useTheme } from '@superset-ui/core'; |
| 21 | +import { Tooltip } from '@superset-ui/chart-controls'; |
21 | 22 | import {
|
22 | 23 | PopKPIComparisonSymbolStyleProps,
|
23 | 24 | PopKPIComparisonValueStyleProps,
|
@@ -57,6 +58,7 @@ export default function PopKPI(props: PopKPIProps) {
|
57 | 58 | subheaderFontSize,
|
58 | 59 | comparisonColorEnabled,
|
59 | 60 | percentDifferenceNumber,
|
| 61 | + comparatorText, |
60 | 62 | } = props;
|
61 | 63 |
|
62 | 64 | const rootElem = createRef<HTMLDivElement>();
|
@@ -117,9 +119,21 @@ export default function PopKPI(props: PopKPIProps) {
|
117 | 119 |
|
118 | 120 | const SYMBOLS_WITH_VALUES = useMemo(
|
119 | 121 | () => [
|
120 |
| - ['#', prevNumber], |
121 |
| - ['△', valueDifference], |
122 |
| - ['%', percentDifferenceFormattedString], |
| 122 | + { |
| 123 | + symbol: '#', |
| 124 | + value: prevNumber, |
| 125 | + tooltipText: t('Data for %s', comparatorText), |
| 126 | + }, |
| 127 | + { |
| 128 | + symbol: '△', |
| 129 | + value: valueDifference, |
| 130 | + tooltipText: t('Value difference between the time periods'), |
| 131 | + }, |
| 132 | + { |
| 133 | + symbol: '%', |
| 134 | + value: percentDifferenceFormattedString, |
| 135 | + tooltipText: t('Percentage difference between the time periods'), |
| 136 | + }, |
123 | 137 | ],
|
124 | 138 | [prevNumber, valueDifference, percentDifferenceFormattedString],
|
125 | 139 | );
|
@@ -147,18 +161,24 @@ export default function PopKPI(props: PopKPIProps) {
|
147 | 161 | >
|
148 | 162 | {SYMBOLS_WITH_VALUES.map((symbol_with_value, index) => (
|
149 | 163 | <ComparisonValue
|
150 |
| - key={`comparison-symbol-${symbol_with_value[0]}`} |
| 164 | + key={`comparison-symbol-${symbol_with_value.symbol}`} |
151 | 165 | subheaderFontSize={subheaderFontSize}
|
152 | 166 | >
|
153 |
| - <SymbolWrapper |
154 |
| - backgroundColor={ |
155 |
| - index > 0 ? backgroundColor : defaultBackgroundColor |
156 |
| - } |
157 |
| - textColor={index > 0 ? textColor : defaultTextColor} |
| 167 | + <Tooltip |
| 168 | + id="tooltip" |
| 169 | + placement="top" |
| 170 | + title={symbol_with_value.tooltipText} |
158 | 171 | >
|
159 |
| - {symbol_with_value[0]} |
160 |
| - </SymbolWrapper> |
161 |
| - {symbol_with_value[1]} |
| 172 | + <SymbolWrapper |
| 173 | + backgroundColor={ |
| 174 | + index > 0 ? backgroundColor : defaultBackgroundColor |
| 175 | + } |
| 176 | + textColor={index > 0 ? textColor : defaultTextColor} |
| 177 | + > |
| 178 | + {symbol_with_value.symbol} |
| 179 | + </SymbolWrapper> |
| 180 | + {symbol_with_value.value} |
| 181 | + </Tooltip> |
162 | 182 | </ComparisonValue>
|
163 | 183 | ))}
|
164 | 184 | </div>
|
|
0 commit comments