prototype
MAmattpocock/skills337k近 7 天新增 4,978 个 star
Create self-contained D3 HTML embed charts for the research article template. Use when the user asks to create a chart, visualization, embed, D3 chart, line chart, bar chart, scatter plot, sankey diagram, or any data visualization as an HTML embed file.
Create self-contained D3.js chart embeds for the research article template.
Read the full directives file for all conventions, patterns, and checklists:
This covers: colors & palettes, layout, SVG scope, mounting, theming, controls, tooltips, data loading, responsiveness, legends, accessibility, performance, error handling, printing, and the full agent checklist.
Clarify with the user:
app/src/content/embeds/d3-<descriptive-name>.html (e.g., d3-training-loss.html).d3-<descriptive-name> (must match filename)Every embed must have this structure:
<div class="d3-yourname"></div>
<style>
.d3-yourname { /* scoped styles */ }
</style>
<script>
(() => {
const ensureD3 = (cb) => { /* D3 CDN loader */ };
const bootstrap = () => {
/* mount guard + container selection */
/* tooltip setup */
/* SVG scaffolding */
/* data loading */
/* render function with ResizeObserver */
};
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', () => ensureD3(bootstrap), { once: true });
} else { ensureD3(bootstrap); }
})();
</script>
Import and use the HtmlEmbed component:
import HtmlEmbed from '../../components/HtmlEmbed.astro';
<HtmlEmbed src="d3-yourname.html" title="Chart Title" desc="Description text" />
| Prop | Type | Description |
|---|---|---|
src | string | Path to HTML file in embeds/ (required) |
title | string | Title above the card |
desc | string | Description below (supports HTML) |
frameless | boolean | Removes card background/border |
wide | boolean | Wide layout (~1100px) |
data | string or string[] | Path(s) to data files |
config | object | JSON config passed via data-config attribute |
<!-- Simple embed -->
<HtmlEmbed src="d3-training-loss.html" title="Training Loss" />
<!-- With external data -->
<HtmlEmbed src="d3-line-simple.html" title="Attention" data="attention_loss.csv" />
<!-- With config -->
<HtmlEmbed
src="d3-line-simple.html"
title="Learning Rate"
data="lr_loss.csv"
config={{ defaultMetric: 'loss', xDomain: [0, 45e9] }}
/>
<!-- Multiple data files -->
<HtmlEmbed
src="d3-comparison.html"
title="A vs B"
data={['formatting_filters.csv', 'relevance_filters.csv']}
/>
<!-- Frameless -->
<HtmlEmbed frameless src="d3-banner.html" />
Full details in the directives file. The critical ones:
window.ColorPalettes.getColors('categorical', n) — never hardcode palettes--text-color, --surface-bg, --border-color, --axis-color, --tick-color, --grid-colordocument.documentElement.getAttribute('data-theme') === 'dark'container.dataset.mounted = 'true'/data/<file> first, then ./assets/data/<file> — use fetchFirstAvailable()ResizeObserver on container, recompute on resize.d3-tooltip absolutely positioned inside containerwindowapp/src/content/assets/data//data/ (public) at build timeAfter creating the embed, verify against the Agent Checklist (section 14.1) and Definition of Done (section 14.2) in directives.md.
MAmattpocock/skills337k近 7 天新增 4,978 个 star
AFaffaan-m/ECC315k近 7 天新增 4,381 个 star
FIfirecrawl/firecrawl215k近 7 天新增 5,595 个 star
ANanthropics/skills203k近 7 天新增 3,265 个 star
用 React、Tailwind 和 shadcn/ui 构建多组件页面。
ANanthropics/skills203k近 7 天新增 3,265 个 star