Repository navigation
Conversation
…ing for chart.js (#5033) - start the loaddata fetches as soon as the inline script runs, and render the stat cards and tables as their data arrives - draw the charts once chart.js has loaded (chartjsready); if it fails to load, only the charts are missing - draw charts in inter straight away when it is already loaded, otherwise draw them in the fallback stack and switch chart.defaults.font.family to --fui-font-family once the inter stylesheet and face have loaded, so chart.js measures the labels again - split the event trend chart drawing out of rendereventcounts - re-render gh-pages anvil-explorer, hca-explorer and lungmap with their existing data, and bump the analytics package to 5.1.4 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: cc-claude-tools <cc-claude-tools@clevercanary.com>
…ile fails to load (#5033) - handle the document.fonts.load rejection (for example a csp that allows fonts.googleapis.com but blocks fonts.gstatic.com) so it isn't an unhandled promise rejection; errors from useinterincharts still surface - re-render gh-pages anvil-explorer, hca-explorer and lungmap Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: cc-claude-tools <cc-claude-tools@clevercanary.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The chart/data coordination handler is attached too late, allowing an early Chart.js failure to produce duplicate unhandled rejections in the template and generated pages.
1 open issue
What changed in this PR
Addresses #5033 by separating analytics data loading from Chart.js readiness and redrawing charts in Inter when the font loads, building on the deferred loading introduced in #5026.
Changes:
- Starts data requests immediately and renders non-chart content independently of Chart.js.
- Separates event cards from chart drawing and adds fallback-to-Inter font updates.
- Regenerates all three published pages and bumps the analytics package to 5.1.4.
| File | Description |
|---|---|
gh-pages/lungmap/index.html |
Regenerated with independent data loading and chart font updates. |
gh-pages/hca-explorer/index.html |
Regenerated with independent data loading and chart font updates. |
gh-pages/anvil-explorer/index.html |
Regenerated with independent data loading and chart font updates. |
analytics/uv.lock |
Updates the locked analytics version to 5.1.4. |
analytics/analytics_package/pyproject.toml |
Bumps the analytics package version to 5.1.4. |
analytics/analytics_package/analytics/static_site/template/index.html |
Implements immediate fetching, chart readiness coordination, and Inter redraws. |
Review effort: Balanced
- attach the chart drawing chain at startup, waiting on chartjsready and a chartdataready promise that loaddata resolves, so a chart.js failure that lands before the data is no longer reported twice - re-render gh-pages anvil-explorer, hca-explorer and lungmap Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: cc-claude-tools <cc-claude-tools@clevercanary.com>
frano-m
added a commit
to DataBiosphere/findable-ui
that referenced
this pull request
Nov 13, 2026
…template The Chart.js notes now follow the pattern DataBiosphere/data-browser#5035 ships, plus a catch for a blocked font file: - Test `media === "all"` instead of `link.sheet` to tell whether the font stylesheet is in use, since Chrome also sets `sheet` after a failed load. - When Inter has already loaded, create the charts in it rather than drawing and redrawing them. - Take the font from `--fui-font-family`, and match the fallback stack to it, so a page that overrides the token gets its font in charts. - Say to run the code after Chart.js, in a `DOMContentLoaded` listener when Chart.js is deferred. - Catch a `document.fonts.load` rejection when the font file is blocked, leaving the charts in the fallback font. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: cc-claude-tools <cc-claude-tools@clevercanary.com>
3 tasks
frano-m
added a commit
to DataBiosphere/findable-ui
that referenced
this pull request
Nov 13, 2026
…template The Chart.js notes now follow the pattern DataBiosphere/data-browser#5035 ships, plus a catch for a blocked font file: - Test `media === "all"` instead of `link.sheet` to tell whether the font stylesheet is in use, since Chrome also sets `sheet` after a failed load. - When Inter has already loaded, create the charts in it rather than drawing and redrawing them. - Take the font from `--fui-font-family`, and match the fallback stack to it, so a page that overrides the token gets its font in charts. - Say to run the code after Chart.js, in a `DOMContentLoaded` listener when Chart.js is deferred. - Catch a `document.fonts.load` rejection when the font file is blocked, leaving the charts in the fallback font. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: cc-claude-tools <cc-claude-tools@clevercanary.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Closes #5033
What changed
In the static analytics template (
analytics/analytics_package/analytics/static_site/template/index.html):loadData()now runs as soon as the inline script does, instead of onDOMContentLoaded. The stat cards, tables and event stats render as soon as their data arrives.chartJsReadypromise resolves onDOMContentLoadedonce Chart.js has run, andloadDataresolves achartDataReadypromise with the charts' data. Chart drawing (traffic, pageviews, event trend charts) is one chain on both, attached at startup and kept out ofloadData'stry. If Chart.js fails to load, the promise rejects, only the charts are missing, and the console shows one "Chart.js failed to load" error, whichever of Chart.js and the data settles first.renderEventCountsnow renders only the card HTML. The neweventChartDataByKeybuilds the lookup, and the newrenderEventTrendChartsdraws the trend charts once Chart.js is ready.<link>'smediaisallanddocument.fonts.check('400 12px Inter')is true), the charts start in--fui-font-family.FALLBACK_FONT_FAMILY, which is--fui-font-familywithout Inter). Once the stylesheet'sloadfires anddocument.fonts.load('400 12px Inter')resolves,useInterInChartssetsChart.defaults.font.familyto--fui-font-familyand callsupdate('none')on every chart.<link>itself is unchanged (onload="this.media='all'").The generated pages
gh-pages/{anvil-explorer,hca-explorer,lungmap}/index.htmlare re-rendered from the updated template, and the analytics package version is now 5.1.4.Why
#5026 deferred Chart.js and stopped the Inter stylesheet from blocking first paint, which caused three problems:
data/*.jsonrequests waited for the cross-origin Chart.js download.Assumptions I made
display=swap), and it is the pattern the findable-uianalytics.cssnotes document (findable-ui#1213).update(). A plainupdate()with an unchanged family would reuse the widths measured in the fallback font. So the charts start with a family string that leaves out Inter, and switching to the Inter string makes Chart.js measure the labels again.mediacheck, notlink.sheet. "Inter is ready" is detected with the link'smedia === 'all', which itsonloadattribute sets.link.sheetisn't used because Chrome sets it even after the stylesheet fails, andmediastaysprintuntil the stylesheet is actually applied.document.fonts.loadrejects; that rejection is handled with no further action, because the fallback font is the intended result and the browser already logs the failed request.configliteral was read from itsgenerate_static_site.pywithout running the script, so there was no GA login and no data refresh. Thedata/folders are unchanged.How to verify
Serve a generated page, for example
cd gh-pages/hca-explorer && python -m http.server 8080, and open http://localhost:8080 in Chrome with DevTools open and Disable cache on.data/*.jsonrequests start before thechart.js@4.5.1request finishes.cdn.jsdelivr.netand reload. Check that the stat cards and tables render, only the charts are missing, and the console shows one "Chart.js failed to load" error.git diff main -- gh-pagesshows the same changes as the template diff for all three sites.Definition of done:
data/*.jsonrequests starting before the Chart.js request finishes. Step 2cdn.jsdelivr.netblocked, the stat cards and tables still render, and only the charts are missing. Step 3gh-pages/are re-rendered from the updated template. Step 5What I checked in Chrome on local copies of
hca-explorer:data/*.jsonrequests started at 77 ms, and the Chart.js download finished at 131 ms.🤖 Generated with Claude Code
🐦 Built with cc-claude-tools