refactoring
This commit is contained in:
@@ -80,17 +80,7 @@ class FreeBedsChartView {
|
|||||||
},
|
},
|
||||||
tooltip: {
|
tooltip: {
|
||||||
callbacks: {
|
callbacks: {
|
||||||
label: function (context) {
|
label: UIUtils.labelWithPercentCallback
|
||||||
let label = context.dataset.label || '';
|
|
||||||
|
|
||||||
if (label) {
|
|
||||||
label += ': ';
|
|
||||||
}
|
|
||||||
if (context.parsed.y !== null) {
|
|
||||||
label += context.parsed.y.toFixed(1) + "%";
|
|
||||||
}
|
|
||||||
return label;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -44,19 +44,8 @@ class MedianOfFreeBedsByKreisChartView {
|
|||||||
text: 'some Title'
|
text: 'some Title'
|
||||||
},
|
},
|
||||||
tooltip: {
|
tooltip: {
|
||||||
// FK-TODO: DRY with FreeBedsChartView.js
|
|
||||||
callbacks: {
|
callbacks: {
|
||||||
label: function (context) {
|
label: UIUtils.labelWithPercentCallback
|
||||||
let label = context.dataset.label || '';
|
|
||||||
|
|
||||||
if (label) {
|
|
||||||
label += ': ';
|
|
||||||
}
|
|
||||||
if (context.parsed.y !== null) {
|
|
||||||
label += context.parsed.y.toFixed(1) + "%";
|
|
||||||
}
|
|
||||||
return label;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -16,4 +16,16 @@ class UIUtils {
|
|||||||
static getSelectedOption(selectElement) {
|
static getSelectedOption(selectElement) {
|
||||||
return selectElement.options[selectElement.selectedIndex];
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user