refactor: cosmetic changes (equitherm chart)

This commit is contained in:
Yurii
2025-03-03 02:05:33 +03:00
parent 3e61dabeab
commit 061136b13e

View File

@@ -824,11 +824,13 @@
tension: 0.1, tension: 0.1,
pointRadius: 2, pointRadius: 2,
pointHoverRadius: 4, pointHoverRadius: 4,
indexAxis: "x",
data: [] data: []
}] }]
}, },
options: { options: {
responsive: true, responsive: true,
parsing: false,
interaction: { interaction: {
mode: 'nearest', mode: 'nearest',
intersect: false intersect: false
@@ -837,21 +839,37 @@
tooltip: { tooltip: {
enabled: true, enabled: true,
position: 'nearest', position: 'nearest',
displayColors: false displayColors: false,
callbacks: {
title: (items) => {
return `${i18n("settings.equitherm.chart.outdoorTemp")}: ${items[0].label}`;
}
}
}, },
legend: { legend: {
display: false display: false
},
decimation: {
enabled: false,
algorithm: 'lttb',
samples: 30,
threshold: 30
} }
}, },
scales: { scales: {
x: { x: {
display: true, display: true,
type: "linear",
reverse: true,
title: { title: {
display: true display: true
}, },
ticks: { ticks: {
callback: function(value) { stepSize: 1,
return `${this.getLabelForValue(value)}°`; format: {
style: "unit",
unit: "degree",
unitDisplay: "narrow"
} }
} }
}, },
@@ -861,8 +879,10 @@
display: true display: true
}, },
ticks: { ticks: {
callback: (value, index, ticks) => { format: {
return `${value}°`; style: "unit",
unit: "degree",
unitDisplay: "narrow"
} }
} }
} }
@@ -887,8 +907,8 @@
const outdoorTemp = etChartConfig.unitSystem == 0 ? value : c2f(value); const outdoorTemp = etChartConfig.unitSystem == 0 ? value : c2f(value);
etChart.data.datasets[0].data.push({ etChart.data.datasets[0].data.push({
x: outdoorTemp.toString(), x: parseFloat(outdoorTemp.toFixed(1)),
y: calculateEquithermTemp(outdoorTemp) y: parseFloat(calculateEquithermTemp(outdoorTemp).toFixed(1))
}); });
} }
@@ -914,7 +934,7 @@
: -(Math.pow(-(tempDelta), 1 / etChartConfig.exponent)) : -(Math.pow(-(tempDelta), 1 / etChartConfig.exponent))
); );
return (Math.max(Math.min(result, etChartConfig.maxTemp), etChartConfig.minTemp)).toFixed(1); return Math.max(Math.min(result, etChartConfig.maxTemp), etChartConfig.minTemp);
} }
const fillData = (data) => { const fillData = (data) => {
@@ -1181,6 +1201,12 @@
window.addEventListener('resize', async (event) => { window.addEventListener('resize', async (event) => {
if (etChart) { if (etChart) {
etChart.resize(); etChart.resize();
const decimation = window.innerWidth <= 800;
if (etChart.options.plugins.decimation.enabled != decimation) {
etChart.options.plugins.decimation.enabled = decimation;
etChart.update();
}
} }
}); });
}); });