Embed Chart.js inline — report is now fully self-contained

No internet connection required to open dc_md_va_unemployment_report.html.
chart.umd.min.js (200 KB) is bundled into the HTML at generation time.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-16 11:34:25 -04:00
parent fd9491f869
commit ae46e429a8
3 changed files with 50 additions and 2 deletions

20
chart.umd.min.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -6,9 +6,12 @@ Output: dc_md_va_unemployment_report.html (open in any browser)
import requests import requests
import json import json
import os
from datetime import datetime from datetime import datetime
from config import BLS_API_KEY, BLS_API_BASE from config import BLS_API_KEY, BLS_API_BASE
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Series config (same as dashboard script) # Series config (same as dashboard script)
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
@ -237,7 +240,7 @@ HTML_TEMPLATE = """<!DOCTYPE html>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DC / MD / VA Unemployment Report — {report_date}</title> <title>DC / MD / VA Unemployment Report — {report_date}</title>
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.0/dist/chart.umd.min.js"></script> <script>{chartjs}</script>
<style> <style>
*, *::before, *::after {{ box-sizing: border-box; }} *, *::before, *::after {{ box-sizing: border-box; }}
body {{ body {{
@ -382,6 +385,10 @@ def main():
report_date = datetime.now().strftime("%B %d, %Y") report_date = datetime.now().strftime("%B %d, %Y")
chartjs_path = os.path.join(SCRIPT_DIR, "chart.umd.min.js")
with open(chartjs_path) as f:
chartjs = f.read()
labels, datasets = build_rate_chart_data(results, months=24) labels, datasets = build_rate_chart_data(results, months=24)
rate_chart_json = json.dumps({"labels": labels, "datasets": datasets}) rate_chart_json = json.dumps({"labels": labels, "datasets": datasets})
@ -390,6 +397,7 @@ def main():
cards=build_cards(results), cards=build_cards(results),
summary_table=build_summary_table(results), summary_table=build_summary_table(results),
rate_chart_json=rate_chart_json, rate_chart_json=rate_chart_json,
chartjs=chartjs,
) )
out = "dc_md_va_unemployment_report.html" out = "dc_md_va_unemployment_report.html"