fixing tooltips
This commit is contained in:
@@ -86,7 +86,7 @@ class FreeBedsChartView {
|
|||||||
},
|
},
|
||||||
tooltip: {
|
tooltip: {
|
||||||
callbacks: {
|
callbacks: {
|
||||||
label: UIUtils.getLabelWithPercent
|
label: UIUtils.getYLabelWithPercent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ class MedianOfFreeBedsByKreisChartView {
|
|||||||
},
|
},
|
||||||
tooltip: {
|
tooltip: {
|
||||||
callbacks: {
|
callbacks: {
|
||||||
label: UIUtils.getLabelWithPercent
|
label: UIUtils.getXLabelWithPercent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -17,14 +17,22 @@ class UIUtils {
|
|||||||
return selectElement.options[selectElement.selectedIndex];
|
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 || '';
|
let label = context.dataset.label || '';
|
||||||
|
|
||||||
if (label) {
|
if (label) {
|
||||||
label += ': ';
|
label += ': ';
|
||||||
}
|
}
|
||||||
if (context.parsed.y !== null) {
|
if (value !== null) {
|
||||||
label += context.parsed.y.toFixed(1) + "%";
|
label += value.toFixed(1) + "%";
|
||||||
}
|
}
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user