|
@@ -5,6 +5,7 @@ import type {TooltipComponentFormatterCallback, TooltipComponentOption} from 'ec
|
|
|
import moment from 'moment';
|
|
|
|
|
|
import BaseChart from 'sentry/components/charts/baseChart';
|
|
|
+import {tct} from 'sentry/locale';
|
|
|
import {DataPoint} from 'sentry/types/echarts';
|
|
|
import {getFormattedDate, getTimeFormat} from 'sentry/utils/dates';
|
|
|
import toArray from 'sentry/utils/toArray';
|
|
@@ -178,7 +179,7 @@ function getFormatter({
|
|
|
${truncatedName}: ${formattedValue}
|
|
|
</div>`,
|
|
|
'</div>',
|
|
|
- `<div class="tooltip-date">${label}</div>`,
|
|
|
+ `<div class="tooltip-footer">${label}</div>`,
|
|
|
'</div>',
|
|
|
].join('');
|
|
|
}
|
|
@@ -204,45 +205,64 @@ function getFormatter({
|
|
|
seriesParamsOrParam
|
|
|
);
|
|
|
|
|
|
- return [
|
|
|
- '<div class="tooltip-series">',
|
|
|
- seriesParams
|
|
|
- .filter(getFilter)
|
|
|
- .map(s => {
|
|
|
- const formattedLabel = nameFormatter(
|
|
|
- truncationFormatter(s.seriesName ?? '', truncate)
|
|
|
- );
|
|
|
- const value = valueFormatter(getSeriesValue(s, 1), s.seriesName, s);
|
|
|
-
|
|
|
- const marker = markerFormatter(s.marker ?? '', s.seriesName);
|
|
|
-
|
|
|
- const filteredSubLabels = subLabels.filter(
|
|
|
- subLabel => subLabel.parentLabel === s.seriesName
|
|
|
- );
|
|
|
-
|
|
|
- if (filteredSubLabels.length) {
|
|
|
- const labelWithSubLabels = [
|
|
|
- `<div><span class="tooltip-label">${marker} <strong>${formattedLabel}</strong></span> ${value}</div>`,
|
|
|
- ];
|
|
|
-
|
|
|
- for (const subLabel of filteredSubLabels) {
|
|
|
- labelWithSubLabels.push(
|
|
|
- `<div><span class="tooltip-label tooltip-label-indent"><strong>${
|
|
|
- subLabel.label
|
|
|
- }</strong></span> ${valueFormatter(
|
|
|
- subLabel.data[s.dataIndex].value
|
|
|
- )}</div>`
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- return labelWithSubLabels.join('');
|
|
|
+ const {series, total} = seriesParams.filter(getFilter).reduce(
|
|
|
+ (acc, serie) => {
|
|
|
+ const formattedLabel = nameFormatter(
|
|
|
+ truncationFormatter(serie.seriesName ?? '', truncate)
|
|
|
+ );
|
|
|
+
|
|
|
+ const value = valueFormatter(getSeriesValue(serie, 1), serie.seriesName, serie);
|
|
|
+
|
|
|
+ const marker = markerFormatter(serie.marker ?? '', serie.seriesName);
|
|
|
+
|
|
|
+ const filteredSubLabels = subLabels.filter(
|
|
|
+ subLabel => subLabel.parentLabel === serie.seriesName
|
|
|
+ );
|
|
|
+
|
|
|
+ if (filteredSubLabels.length) {
|
|
|
+ const labelWithSubLabels = [
|
|
|
+ `<div><span class="tooltip-label">${marker} <strong>${formattedLabel}</strong></span> <strong>${value}</strong></div>`,
|
|
|
+ ];
|
|
|
+
|
|
|
+ for (const subLabel of filteredSubLabels) {
|
|
|
+ const serieValue = subLabel.data[serie.dataIndex].value;
|
|
|
+
|
|
|
+ labelWithSubLabels.push(
|
|
|
+ `<div><span class="tooltip-label tooltip-label-indent"><strong>${
|
|
|
+ subLabel.label
|
|
|
+ }</strong></span> ${valueFormatter(serieValue)}</div>`
|
|
|
+ );
|
|
|
+
|
|
|
+ acc.total = acc.total + subLabel.data[serie.dataIndex].value;
|
|
|
}
|
|
|
|
|
|
- return `<div><span class="tooltip-label">${marker} <strong>${formattedLabel}</strong></span> ${value}</div>`;
|
|
|
- })
|
|
|
- .join(''),
|
|
|
+ acc.series.push(labelWithSubLabels.join(''));
|
|
|
+ return acc;
|
|
|
+ }
|
|
|
+
|
|
|
+ acc.total = acc.total + getSeriesValue(serie, 1);
|
|
|
+
|
|
|
+ acc.series.push(
|
|
|
+ `<div><span class="tooltip-label">${marker} <strong>${formattedLabel}</strong></span> <strong>${value}</strong></div>`
|
|
|
+ );
|
|
|
+ return acc;
|
|
|
+ },
|
|
|
+ {
|
|
|
+ series: [],
|
|
|
+ total: 0,
|
|
|
+ }
|
|
|
+ );
|
|
|
+
|
|
|
+ return [
|
|
|
+ `<div class="tooltip-series">${series.join('')}</div>`,
|
|
|
+ '<div class="tooltip-footer">',
|
|
|
+ `<div>${tct(`[term:Date:] [value]`, {term: <strong />, value: date})}</div>`,
|
|
|
+ `<div>${tct(`[term:Total:] [value]`, {
|
|
|
+ term: <strong />,
|
|
|
+ value: valueFormatter(total),
|
|
|
+ })}</div>`,
|
|
|
+
|
|
|
'</div>',
|
|
|
- `<div class="tooltip-date">${date}</div>`,
|
|
|
'<div class="tooltip-arrow"></div>',
|
|
|
].join('');
|
|
|
};
|