fix(legacy-plugin-chart-heatmap): fix adhoc column tooltip (#23507)

This commit is contained in:
Ville Brofeldt 2023-03-28 14:07:34 +03:00 committed by GitHub
parent a3ffc67238
commit 0cebe8bf18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 6 deletions

View File

@ -22,6 +22,8 @@ import PropTypes from 'prop-types';
import 'd3-svg-legend';
import d3tip from 'd3-tip';
import {
getColumnLabel,
getMetricLabel,
getNumberFormatter,
NumberFormats,
getSequentialSchemeRegistry,
@ -44,8 +46,8 @@ const propTypes = {
height: PropTypes.number,
bottomMargin: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
colorScheme: PropTypes.string,
columnX: PropTypes.string,
columnY: PropTypes.string,
columnX: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
columnY: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
leftMargin: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
metric: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
normalized: PropTypes.bool,
@ -338,12 +340,13 @@ function Heatmap(element, props) {
const k = d3.mouse(this);
const m = Math.floor(scale[0].invert(k[0]));
const n = Math.floor(scale[1].invert(k[1]));
const metricLabel = typeof metric === 'object' ? metric.label : metric;
if (m in matrix && n in matrix[m]) {
const obj = matrix[m][n];
s += `<div><b>${columnX}: </b>${obj.x}<div>`;
s += `<div><b>${columnY}: </b>${obj.y}<div>`;
s += `<div><b>${metricLabel}: </b>${valueFormatter(obj.v)}<div>`;
s += `<div><b>${getColumnLabel(columnX)}: </b>${obj.x}<div>`;
s += `<div><b>${getColumnLabel(columnY)}: </b>${obj.y}<div>`;
s += `<div><b>${getMetricLabel(metric)}: </b>${valueFormatter(
obj.v,
)}<div>`;
if (showPercentage) {
s += `<div><b>%: </b>${fp(normalized ? obj.rank : obj.perc)}<div>`;
}