refactoring
This commit is contained in:
@@ -80,7 +80,7 @@ class FreeBedsChartView {
|
|||||||
},
|
},
|
||||||
tooltip: {
|
tooltip: {
|
||||||
callbacks: {
|
callbacks: {
|
||||||
label: UIUtils.labelWithPercentCallback
|
label: UIUtils.getLabelWithPercent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -96,17 +96,7 @@ class FreeBedsChartView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
y: {
|
y: UIUtils.getPercentageScale(label)
|
||||||
min: 0,
|
|
||||||
max: 100,
|
|
||||||
title: {
|
|
||||||
display: true,
|
|
||||||
text: label
|
|
||||||
},
|
|
||||||
ticks: {
|
|
||||||
callback: value => value + "%"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
parsing: {
|
parsing: {
|
||||||
xAxisKey: 'date'
|
xAxisKey: 'date'
|
||||||
|
|||||||
@@ -45,24 +45,13 @@ class MedianOfFreeBedsByKreisChartView {
|
|||||||
},
|
},
|
||||||
tooltip: {
|
tooltip: {
|
||||||
callbacks: {
|
callbacks: {
|
||||||
label: UIUtils.labelWithPercentCallback
|
label: UIUtils.getLabelWithPercent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
responsive: true,
|
responsive: true,
|
||||||
scales: {
|
scales: {
|
||||||
y: {
|
y: UIUtils.getPercentageScale(label)
|
||||||
min: 0,
|
|
||||||
max: 100,
|
|
||||||
title: {
|
|
||||||
display: true,
|
|
||||||
text: label
|
|
||||||
},
|
|
||||||
// FK-TODO: DRY with FreeBedsChartView.js
|
|
||||||
ticks: {
|
|
||||||
callback: value => value + "%"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
parsing: {
|
parsing: {
|
||||||
xAxisKey: 'Kreis'
|
xAxisKey: 'Kreis'
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class UIUtils {
|
|||||||
return selectElement.options[selectElement.selectedIndex];
|
return selectElement.options[selectElement.selectedIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
static labelWithPercentCallback(context) {
|
static getLabelWithPercent(context) {
|
||||||
let label = context.dataset.label || '';
|
let label = context.dataset.label || '';
|
||||||
|
|
||||||
if (label) {
|
if (label) {
|
||||||
@@ -28,4 +28,18 @@ class UIUtils {
|
|||||||
}
|
}
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static getPercentageScale(label) {
|
||||||
|
return {
|
||||||
|
min: 0,
|
||||||
|
max: 100,
|
||||||
|
title: {
|
||||||
|
display: true,
|
||||||
|
text: label
|
||||||
|
},
|
||||||
|
ticks: {
|
||||||
|
callback: value => value + "%"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user