feat: add Frappe Charts integration examples (#546)#559
Conversation
Add example HTML files demonstrating how to use MAIDR with Frappe Charts, a lightweight open-source SVG charting library. Each example includes a binder/adapter pattern that extracts data from Frappe Charts instances and constructs the MAIDR JSON schema with appropriate CSS selectors for SVG highlighting. Supported chart types: - Bar chart (frappe-bar.html) - Line chart (frappe-line.html) - Scatter/dot plot (frappe-scatter.html) - Mixed axis chart with bar + line layers (frappe-mixed.html) https://claude.ai/code/session_01LpiQt2NvNwqEsNUo3sPTpg
Code ReviewThis PR adds four HTML example files demonstrating MAIDR integration with Frappe Charts. The adapter/binder pattern is well-conceived and the code is clearly commented. Here are my findings: Positive aspects
Issues1. Fragile timing with
|
Address bot code review feedback: - Replace setTimeout(100) with requestAnimationFrame() for reliable render timing - Add <main> semantic landmark for accessibility - Add CDN error handling with onerror and fallback message - Add version comments noting CSS selector dependency on Frappe Charts v1.6.2 - Fix scatter selector to use specific .dataset-line class instead of broad .dataset-units circle - Add comment about Frappe Charts' pseudo-scatter x-axis spacing - Fix line/mixed chart selectors to use path selector (.line-graph-path) as required by MAIDR's LineTrace (expects SVG path, not circles) Add new examples for remaining compatible MAIDR chart types: - Stacked bar (frappe-stacked-bar.html): Frappe barOptions.stacked → MAIDR stacked_bar with SegmentedPoint data - Multi-line (frappe-multiline.html): Multiple Frappe datasets → MAIDR line with per-dataset path selectors and legend MAIDR chart types not supported by Frappe Charts: box, candlestick, dodged_bar, heat (calendar vs grid format), hist, smooth, stacked_normalized_bar. https://claude.ai/code/session_01LpiQt2NvNwqEsNUo3sPTpg
PR Review: Frappe Charts Integration ExamplesOverall, this is a well-structured and useful addition. The adapter/binder pattern is clearly explained, and the CSS selector comments with version pins are especially helpful for maintainability. A few items worth addressing: Issues1. Unrelated version bump in
|
| Category | Finding | Severity |
|---|---|---|
| Code quality | Empty if branch; invert condition |
Low |
| Reliability | Single rAF may miss on slow devices |
Low |
| Security | Missing SRI hashes on CDN resources | Medium |
| Correctness | fill value format in stacked bar — verify |
Low |
| Style | Missing viewport meta | Trivial |
| Unrelated change | package-lock.json version bump |
Low |
The examples are well-commented and demonstrate the integration pattern clearly. Addressing the SRI hashes and the empty if branch would be the highest-priority changes before merging.
- Invert empty if-branch: use `if (typeof frappe !== 'undefined')` guard instead of empty-body-with-else pattern - Add retry loop: named requestAnimationFrame callback retries if SVG is not yet in DOM, handling slow device rendering - Add SRI hashes: integrity and crossorigin attributes on CDN script and link tags for supply-chain security - Add viewport meta: responsive design support via <meta name="viewport"> on all example files - Document dynamic loading: explain why maidr.js is loaded dynamically instead of statically (Frappe Charts generates SVG at runtime) - Clarify stacked bar fill: add comment noting that SegmentedTrace accepts both descriptive names and positional indices for fill field https://claude.ai/code/session_01LpiQt2NvNwqEsNUo3sPTpg
PR Review: Frappe Charts Integration ExamplesThanks for adding these examples — the adapter/binder pattern is well-structured and the inline documentation explaining Frappe Charts' DOM structure is genuinely helpful for anyone trying to integrate other libraries. Positive Highlights
Issues to Address1. PR Description Does Not Match Added Files (Minor)The PR description lists 4 chart types, but 6 files are added. 2. Unbounded
|
| Category | Status |
|---|---|
| Code quality | ✅ Good — consistent, readable, well-commented |
| Security | ✅ SRI hashes present |
| Correctness | |
| Accessibility | |
| PR completeness | |
| Tests | N/A — example files; no automated tests expected |
The core pattern is solid and well-suited for copying into real projects. Addressing the retry cap and the stale comment would be the most impactful changes before merging.
Add example HTML files demonstrating how to use MAIDR with Frappe Charts,
a lightweight open-source SVG charting library. Each example includes a
binder/adapter pattern that extracts data from Frappe Charts instances
and constructs the MAIDR JSON schema with appropriate CSS selectors for
SVG highlighting.
Supported chart types:
https://claude.ai/code/session_01LpiQt2NvNwqEsNUo3sPTpg