feat: Utility function to render chart tooltips (#27950)

This commit is contained in:
Michael S. Molina
2024-05-07 13:00:30 -03:00
committed by GitHub
parent 467e612533
commit b549977f05
23 changed files with 512 additions and 425 deletions

View File

@@ -16,7 +16,11 @@
* specific language governing permissions and limitations
* under the License.
*/
import { getMetricLabel, DataRecordValue } from '@superset-ui/core';
import {
getMetricLabel,
DataRecordValue,
tooltipHtml,
} from '@superset-ui/core';
import { EChartsCoreOption, TreeSeriesOption } from 'echarts';
import {
TreeSeriesCallbackDataParams,
@@ -44,11 +48,8 @@ export function formatTooltip({
const treePath = (treeAncestors ?? [])
.map(pathInfo => pathInfo?.name || '')
.filter(path => path !== '');
return [
`<div>${treePath.join(' ▸ ')}</div>`,
value ? `${metricLabel}: ${value}` : '',
].join('');
const row = value ? [metricLabel, String(value)] : [];
return tooltipHtml([row], treePath.join(' ▸ '));
}
export default function transformProps(