Demo: https://covidnyc.blakerayvid.com
This project presents a clean, modern, and responsive dashboard for tracking key COVID-19 trends in New York City. It fetches the latest 7-day trailing average data for cases, hospitalizations, and deaths directly from the NYC Health Department, and visualizes the 30-day trend of new cases with an interactive line chart. All data processing and rendering occur client-side, ensuring fast updates and minimal server overhead.
- Modern & Responsive Design:
- Utilizes a clean, professional color palette and typography (Google Fonts: Inter).
- Implements a flexible CSS Grid layout for optimal presentation on both desktop and mobile devices.
- Card-based UI for clear separation and emphasis of data sections.
- Optimized for mobile viewports, ensuring content fits without excessive scrolling.
- Enhanced Data Visualization:
- Switched from a scatter plot to a line chart (Chart.js v4) for better visualization of time-series data.
- Improved chart styling with gradients, customized tooltips, and refined axis labels for better readability.
- Modern JavaScript Architecture:
- Transitioned from
XMLHttpRequestand jQuery to nativefetchAPI withasync/awaitfor cleaner, more readable asynchronous operations. - Robust error handling with user-friendly messages for network or data parsing issues.
- Efficient data parsing and processing, including a dedicated function to find the latest complete data entry to account for reporting lags.
- No external JavaScript libraries beyond Chart.js, making the codebase lighter and easier to maintain.
- Transitioned from
- Performance & SEO Enhancements:
- Optimized HTML structure with semantic tags (
<main>,<header>,<footer>,<h1>,<table>with<caption>andscopeattributes) for better SEO and accessibility. - Comprehensive
metatags (charset, viewport, description, canonical, author, Open Graph, Twitter Cards) for improved search engine visibility and social media sharing. deferattribute on local scripts andpreconnecthints for CDN resources to improve page load performance.- Subresource Integrity (SRI) on CDN assets for enhanced security.
- Optimized HTML structure with semantic tags (
The dashboard's functionality is entirely client-side, driven by HTML, CSS, and vanilla JavaScript.
-
Dashboard Initialization (
initializeDashboard):- This is the primary asynchronous function executed on
DOMContentLoaded. - It manages the overall flow: setting initial loading states, orchestrating data fetching and parsing, updating the UI, and handling any errors gracefully.
- This is the primary asynchronous function executed on
-
Data Fetching (
fetchData):- Uses the modern
fetchAPI to asynchronously retrieve thedata-by-day.csvfile from the NYC Health Department's GitHub repository. - Includes robust error handling for network issues or non-OK HTTP responses.
- Uses the modern
-
CSV Parsing and Data Preparation (
parseCSV,findLatestCompleteEntry):parseCSV: Converts the raw CSV text into a structured array of JavaScript objects, where each object represents a row and its properties correspond to the CSV headers. It includes error checks for empty or malformed CSV data.findLatestCompleteEntry: Iterates backward through the parsed data to identify the most recent day for which complete 7-day average values for cases, hospitalizations, and deaths are available. This is crucial as the latest entries in the raw data often have missing values due to reporting delays.
-
Metrics Display (
updateMetrics):- Takes the
latestCompleteEntrydata and populates the dedicated metrics table in the HTML. - Formats the numerical values with locale-specific thousand separators for improved readability (e.g.,
1,234). - Displays the date corresponding to the latest data.
- Takes the
-
Chart Rendering (
renderChart):- Utilizes Chart.js v4 to create a responsive line chart visualizing the 30-day trend of new COVID-19 cases (7-day average).
- Configures chart options for a clean aesthetic, including:
- Smooth line tension (
tension: 0.4). - Gradient fill under the line for a modern look.
- Customized axis ticks and grid lines for clarity.
- Enhanced tooltip styling for better user interaction.
- Smooth line tension (
- Handles the destruction of previous chart instances to prevent memory leaks and ensure fresh rendering on updates.
- HTML5: Semantic structure and content.
- CSS3: Responsive layout (CSS Grid, Flexbox), custom properties (variables), modern styling.
- JavaScript (ES6+): Asynchronous operations (
fetch,async/await), DOM manipulation, data processing. - Chart.js v4: Powerful and flexible JavaScript charting library.
- Google Fonts (Inter): Modern and legible typography.
To run this project locally:
- Clone the repository (if applicable, otherwise just download the files):
git clone https://github.com/brayvid/covid-report.git
- Navigate to the project directory:
cd covid-report - Open
index.htmlin your web browser.
No special server setup or build process is required, as all functionality is handled by the browser.
© Copyright 2026 Blake Rayvid. All rights reserved.