fixing tooltips

This commit is contained in:
frankknoll
2022-04-01 11:40:57 +02:00
parent 950c6a70a9
commit 34edacc8d1
3 changed files with 13 additions and 5 deletions

View File

@@ -17,14 +17,22 @@ class UIUtils {
return selectElement.options[selectElement.selectedIndex];
}
static getLabelWithPercent(context) {
static getYLabelWithPercent(context) {
return UIUtils._getLabelWithPercent(context, context.parsed.y);
}
static getXLabelWithPercent(context) {
return UIUtils._getLabelWithPercent(context, context.parsed.x);
}
static _getLabelWithPercent(context, value) {
let label = context.dataset.label || '';
if (label) {
label += ': ';
}
if (context.parsed.y !== null) {
label += context.parsed.y.toFixed(1) + "%";
if (value !== null) {
label += value.toFixed(1) + "%";
}
return label;
}