|
|
|
@ -5,8 +5,12 @@ Chart.defaults.global.defaultFontFamily = "'Varela Round', sans-serif";
|
|
|
|
|
const chart_options = {
|
|
|
|
|
elements: {
|
|
|
|
|
line: {
|
|
|
|
|
backgroundColor: "#DEF2D9",
|
|
|
|
|
backgroundColor: "#DEF2D9",
|
|
|
|
|
get backgroundColor() {
|
|
|
|
|
return getComputedStyle(document.documentElement).getPropertyValue('--chart-fill-color');
|
|
|
|
|
},
|
|
|
|
|
get borderColor() {
|
|
|
|
|
return getComputedStyle(document.documentElement).getPropertyValue('--chart-line-color');
|
|
|
|
|
},
|
|
|
|
|
cubicInterpolationMode: "monotone",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
@ -21,14 +25,23 @@ function update_chart(input_data, possibilities) {
|
|
|
|
|
let ctx = $("#chart"),
|
|
|
|
|
datasets = [{
|
|
|
|
|
label: i18next.t("output.chart.input"),
|
|
|
|
|
get pointBorderColor() {
|
|
|
|
|
return getComputedStyle(document.documentElement).getPropertyValue('--chart-point-color');
|
|
|
|
|
},
|
|
|
|
|
data: input_data.slice(1),
|
|
|
|
|
fill: false,
|
|
|
|
|
}, {
|
|
|
|
|
label: i18next.t("output.chart.minimum"),
|
|
|
|
|
get pointBorderColor() {
|
|
|
|
|
return getComputedStyle(document.documentElement).getPropertyValue('--chart-point-color');
|
|
|
|
|
},
|
|
|
|
|
data: possibilities[0].prices.slice(1).map(day => day.min),
|
|
|
|
|
fill: false,
|
|
|
|
|
}, {
|
|
|
|
|
label: i18next.t("output.chart.maximum"),
|
|
|
|
|
get pointBorderColor() {
|
|
|
|
|
return getComputedStyle(document.documentElement).getPropertyValue('--chart-point-color');
|
|
|
|
|
},
|
|
|
|
|
data: possibilities[0].prices.slice(1).map(day => day.max),
|
|
|
|
|
fill: "-1",
|
|
|
|
|
},
|
|
|
|
@ -41,6 +54,7 @@ function update_chart(input_data, possibilities) {
|
|
|
|
|
if (chart_instance) {
|
|
|
|
|
chart_instance.data.datasets = datasets;
|
|
|
|
|
chart_instance.data.labels = labels;
|
|
|
|
|
chart_instance.options = chart_options;
|
|
|
|
|
chart_instance.update();
|
|
|
|
|
} else {
|
|
|
|
|
chart_instance = new Chart(ctx, {
|
|
|
|
@ -53,3 +67,10 @@ function update_chart(input_data, possibilities) {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
window.matchMedia("(prefers-color-scheme: dark)").addListener(() => {
|
|
|
|
|
if (chart_instance) {
|
|
|
|
|
chart_instance.options = chart_options;
|
|
|
|
|
chart_instance.update();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|