fix: decimation for Equitherm chart fixed; chartjs updated

This commit is contained in:
Yurii
2025-09-19 02:09:12 +03:00
parent 30b55f1946
commit e751c3aba0
2 changed files with 13 additions and 26 deletions

View File

@@ -897,7 +897,8 @@
unitSystem: null, unitSystem: null,
targetTemp: null, targetTemp: null,
minTemp: null, minTemp: null,
maxTemp: null maxTemp: null,
decimated: false
}; };
const hasNeedDecimationChart = () => { const hasNeedDecimationChart = () => {
@@ -957,12 +958,6 @@
}, },
legend: { legend: {
display: false display: false
},
decimation: {
enabled: hasNeedDecimationChart(),
algorithm: 'lttb',
samples: 30,
threshold: 30
} }
}, },
scales: { scales: {
@@ -1008,19 +1003,18 @@
return; return;
} }
while (etChart.data.datasets[0].data.length) { let data = [];
etChart.data.datasets[0].data.pop(); etChartConfig.decimated = hasNeedDecimationChart();
} for (let value = 30; value >= -30; value -= etChartConfig.decimated ? 2 : 1) {
for (let value = 30; value >= -30; value--) {
const outdoorTemp = etChartConfig.unitSystem == 0 ? value : c2f(value); const outdoorTemp = etChartConfig.unitSystem == 0 ? value : c2f(value);
etChart.data.datasets[0].data.push({ data.push({
x: parseFloat(outdoorTemp.toFixed(1)), x: parseFloat(outdoorTemp.toFixed(1)),
y: parseFloat(calculateEquithermTemp(outdoorTemp).toFixed(1)) y: parseFloat(calculateEquithermTemp(outdoorTemp).toFixed(1))
}); });
} }
etChart.data.datasets[0].data = data;
etChart.data.datasets[0].label = i18n("settings.equitherm.chart.setpointTemp"); etChart.data.datasets[0].label = i18n("settings.equitherm.chart.setpointTemp");
etChart.options.scales.x.title.text = i18n("settings.equitherm.chart.outdoorTemp"); etChart.options.scales.x.title.text = i18n("settings.equitherm.chart.outdoorTemp");
etChart.options.scales.y.title.text = i18n("settings.equitherm.chart.setpointTemp"); etChart.options.scales.y.title.text = i18n("settings.equitherm.chart.setpointTemp");
@@ -1336,9 +1330,8 @@
if (etChart) { if (etChart) {
etChart.resize(); etChart.resize();
if (etChart.options.plugins.decimation.enabled != hasNeedDecimationChart()) { if (etChartConfig.decimated != hasNeedDecimationChart()) {
etChart.options.plugins.decimation.enabled = hasNeedDecimationChart(); makeEquithermChart();
etChart.update();
} }
} }
}); });

File diff suppressed because one or more lines are too long