Historical Chart and Final Validation
12 min read
Map Chart Ranges to Data Windows
Map Chart Ranges to Data Windows
Open app.js near the chart code.
The UI exposes 1D, 1W, 1M, 3M, and 1Y. Translate those labels into day counts before making a request:
function chartDays() {
return range === "1D" ? 2
: range === "1W" ? 7
: range === "1M" ? 30
: range === "3M" ? 90
: 365;
}
Keep range as shared state so both the range buttons and chart loader read the same selection.
Test it
Log chartDays() after changing range in the console.
Checkpoint
Each supported range resolves to the intended request window.