Session UI: fix day/year labels (#16919)

This commit is contained in:
Michael Geers 2024-10-29 23:00:50 +01:00 • committed by GitHub
parent 3c99810619
commit 4b51a3014b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 8 deletions

View file

@ -208,6 +208,9 @@ export default {
});
},
options() {
// capture vue component this to be used in chartjs callbacks
// eslint-disable-next-line @typescript-eslint/no-this-alias
const vThis = this;
return {
...commonOptions,
locale: this.$i18n?.locale,
@ -285,10 +288,11 @@ export default {
grid: { display: false },
ticks: {
color: colors.muted,
callback: (value) =>
this.period === PERIODS.YEAR
? this.fmtMonth(new Date(this.year, value, 1), true)
: value,
callback: function (value) {
return vThis.period === PERIODS.YEAR
? vThis.fmtMonth(new Date(vThis.year, value, 1), true)
: this.getLabelForValue(value);
},
},
},
y: {

View file

@ -145,6 +145,9 @@ export default {
}));
},
options() {
// capture vue component this to be used in chartjs callbacks
// eslint-disable-next-line @typescript-eslint/no-this-alias
const vThis = this;
return {
...commonOptions,
locale: this.$i18n?.locale,
@ -209,10 +212,11 @@ export default {
grid: { display: false },
ticks: {
color: colors.muted,
callback: (value) =>
this.period === PERIODS.YEAR
? this.fmtMonth(new Date(this.year, value, 1), true)
: value,
callback: function (value) {
return vThis.period === PERIODS.YEAR
? vThis.fmtMonth(new Date(vThis.year, value, 1), true)
: this.getLabelForValue(value);
},
},
},
y: {

View file

@ -192,6 +192,7 @@
import Modal from "bootstrap/js/dist/modal";
import "@h2d2/shopicons/es/regular/cablecharge";
import "@h2d2/shopicons/es/regular/car3";
import "@h2d2/shopicons/es/regular/eco1";
import "@h2d2/shopicons/es/regular/sun";
import formatter, { POWER_UNIT } from "../mixins/formatter";
import api from "../api";