-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
40 lines (34 loc) · 1.43 KB
/
app.js
File metadata and controls
40 lines (34 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Add this to a new file or at the end of your main JavaScript file
document.addEventListener('DOMContentLoaded', function() {
// Tab navigation
const tabButtons = document.querySelectorAll('.tab-btn');
const tabPanes = document.querySelectorAll('.tab-pane');
tabButtons.forEach(button => {
button.addEventListener('click', function() {
// Remove active class from all buttons and panes
tabButtons.forEach(btn => btn.classList.remove('active'));
tabPanes.forEach(pane => pane.classList.remove('active'));
// Add active class to clicked button
this.classList.add('active');
// Show corresponding tab pane
const tabId = this.getAttribute('data-tab');
document.getElementById(tabId).classList.add('active');
// Trigger resize event to ensure charts render correctly
window.dispatchEvent(new Event('resize'));
// If this is the forecast tab, make sure to redraw the chart
if (tabId === 'forecast' && window.forecastChart) {
setTimeout(() => {
window.forecastChart.resize();
window.forecastChart.update();
}, 10);
}
// If this is the historical tab, make sure to redraw the chart
if (tabId === 'historical' && window.historicalChart) {
setTimeout(() => {
window.historicalChart.resize();
window.historicalChart.update();
}, 10);
}
});
});
});