').addClass('cazubu-table-frameless p-2').append(humidityCanvas));
if(humidityChart) { humidityChart.destroy(); }
humidityChart = new Chart(humidityCanvas, { type: 'line', data: { labels: response.data.labels, datasets: [{ label: 'Feuchtigkeit (%)', data: response.data.humidity, borderColor: 'rgba(54, 162, 235, 1)', backgroundColor: 'rgba(54, 162, 235, 0.2)', fill: true, tension: 0.2, spanGaps: true, pointRadius: 3, pointHoverRadius: 5, borderWidth: 2 }] }, options: { maintainAspectRatio: false, scales: { x: { ticks: { color: '#212529', font: { size: 11 } } }, y: { ticks: { color: '#212529', font: { size: 11 } } } }, plugins: { legend: { labels: { color: '#212529', font: { size: 12 } } } } } });
} else { humidityWrapper.append('
Keine Feuchtigkeitsdaten vorhanden.
'); }
} else { chartsContainer.html('
Keine Sensordaten für diesen Zeitraum.
'); }
},
error: function() { chartsContainer.html('
Fehler beim Laden der Sensordaten.
'); }
});
}
$('#sensor-tab-btn').on('shown.bs.tab', function () {
if ($(this).data('loaded')) { return; }
$(this).data('loaded', true);
const plantId = new URLSearchParams(window.location.search).get('id');
loadSensorData(plantId, '24h');
});
$(document).on('click', '.sensor-range-btn', function() {
$('.sensor-range-btn').removeClass('active');
$(this).addClass('active');
const range = $(this).data('range');
const plantId = new URLSearchParams(window.location.search).get('id');
loadSensorData(plantId, range);
});
});