refactoring

This commit is contained in:
frankknoll
2022-03-19 21:24:41 +01:00
parent be2b0e33bb
commit b08da1c310
3 changed files with 14 additions and 23 deletions

View File

@@ -80,17 +80,7 @@ class FreeBedsChartView {
},
tooltip: {
callbacks: {
label: function (context) {
let label = context.dataset.label || '';
if (label) {
label += ': ';
}
if (context.parsed.y !== null) {
label += context.parsed.y.toFixed(1) + "%";
}
return label;
}
label: UIUtils.labelWithPercentCallback
}
}
},

View File

@@ -44,19 +44,8 @@ class MedianOfFreeBedsByKreisChartView {
text: 'some Title'
},
tooltip: {
// FK-TODO: DRY with FreeBedsChartView.js
callbacks: {
label: function (context) {
let label = context.dataset.label || '';
if (label) {
label += ': ';
}
if (context.parsed.y !== null) {
label += context.parsed.y.toFixed(1) + "%";
}
return label;
}
label: UIUtils.labelWithPercentCallback
}
}
},

View File

@@ -16,4 +16,16 @@ class UIUtils {
static getSelectedOption(selectElement) {
return selectElement.options[selectElement.selectedIndex];
}
static labelWithPercentCallback(context) {
let label = context.dataset.label || '';
if (label) {
label += ': ';
}
if (context.parsed.y !== null) {
label += context.parsed.y.toFixed(1) + "%";
}
return label;
}
}