D3.js Visualisation workflow skill. Use this skill when the user needs This skill provides guidance for creating sophisticated, interactive data visualisations using d3.js and the operator should preserve the upstream workflow, copied support files, and provenance before merging or handing off.
D3.js Visualisation workflow skill. Use this skill when the user needs This skill provides guidance for creating sophisticated, interactive data visualisations using d3.js and the operator should preserve the upstream workflow, copied support files, and provenance before merging or handing off.
This public intake copy packages plugins/antigravity-bundle-data-analytics/skills/claude-d3js-skill from https://github.com/sickn33/antigravity-awesome-skills into the native Omni Skills editorial shape without hiding its origin.
Use it when the operator needs the upstream workflow, support files, and repository context to stay intact while the public validator and private enhancer continue their normal downstream flow.
This intake keeps the copied upstream files intact and uses the external_source block in metadata.json plus ORIGIN.md as the provenance anchor for review.
D3.js Visualisation
Imported source sections that did not map cleanly to the public headings are still preserved below or in the support files. Notable imported sections: Common visualisation patterns, Adding interactivity, Transitions and animations, Common issues and solutions, Limitations.
When to Use This Skill
Use this section as the trigger filter. It should make the activation boundary explicit before the operator loads files, runs commands, or opens a pull request.
Custom visualisations requiring unique visual encodings or layouts
Interactive explorations with complex pan, zoom, or brush behaviours
Network/graph visualisations (force-directed layouts, tree diagrams, hierarchies, chord diagrams)
Publication-quality graphics with fine-grained styling control
Operating Table
Situation
Start here
Why it matters
First-time use
metadata.json
Confirms repository, branch, commit, and imported path through the external_source block before touching the copied workflow
Provenance review
ORIGIN.md
Gives reviewers a plain-language audit trail for the imported source
Workflow execution
references/colour-schemes.md
Starts with the smallest copied file that materially changes execution
Supporting context
references/d3-patterns.md
Adds the next most relevant copied source file without loading the entire package
Handoff decision
## Related Skills
Helps the operator switch to a stronger native skill when the task drifts
Workflow
This workflow is intentionally editorial and operational at the same time. It keeps the imported source useful to the operator while still satisfying the public intake standards that feed the downstream enhancer flow.
Set up d3.js Import d3 at the top of your script: `javascript import as d3 from 'd3'; Or use the CDN version (7.x): html All modules (scales, axes, shapes, transitions, etc.) are accessible through the d3 namespace.
Choose the integration pattern Pattern A: Direct DOM manipulation (recommended for most cases) Use d3 to select DOM elements and manipulate them imperatively.
This works in any JavaScript environment: `javascript function drawChart(data) { if (!data || data.length === 0) return; const svg = d3.select('#chart'); // Select by ID, class, or DOM element // Clear previous content svg.selectAll("").remove(); // Set up dimensions const width = 800; const height = 400; const margin = { top: 20, right: 30, bottom: 40, left: 50 }; // Create scales, axes, and draw visualisation // ...
} // Call when data changes drawChart(myData); Pattern B: Declarative rendering (for frameworks with templating) Use d3 for data calculations (scales, layouts) but render elements via your framework: javascript function getChartElements(data) { const xScale = d3.scaleLinear() .domain([0, d3.max(data, d => d.value)]) .range([0, 400]); return data.map((d, i) => ({ x: 50, y: i 30, width: xScale(d.value), height: 25 })); } // In React: {getChartElements(data).map((d, i) => <rect key={i} {...d} fill="steelblue" />)} // In Vue: v-for directive over the returned array // In vanilla JS: Create elements manually from the returned data ` Use Pattern A for complex visualisations with transitions, interactions, or when leveraging d3's full capabilities.
Use Pattern B for simpler visualisations or when your framework prefers declarative rendering.
Structure the visualisation code Follow this standard structure in your drawing function: `javascript function drawVisualization(data) { if (!data || data.length === 0) return; const svg = d3.select('#chart'); // Or pass a selector/element svg.selectAll("").remove(); // Clear previous render // 1.
All modules (scales, axes, shapes, transitions, etc.) are accessible through the d3 namespace.
2. Choose the integration pattern
Pattern A: Direct DOM manipulation (recommended for most cases)
Use d3 to select DOM elements and manipulate them imperatively. This works in any JavaScript environment:
functiondrawChart(data) {
if (!data || data.length === 0) return;
const svg = d3.select('#chart'); // Select by ID, class, or DOM element// Clear previous content
svg.selectAll("*").remove();
// Set up dimensionsconst width = 800;
const height = 400;
const margin = { top: 20, right: 30, bottom: 40, left: 50 };
// Create scales, axes, and draw visualisation// ... d3 code here ...
}
// Call when data changesdrawChart(myData);
Pattern B: Declarative rendering (for frameworks with templating)
Use d3 for data calculations (scales, layouts) but render elements via your framework:
functiongetChartElements(data) {
const xScale = d3.scaleLinear()
.domain([0, d3.max(data, d => d.value)])
.range([0, 400]);
return data.map((d, i) => ({
x: 50,
y: i * 30,
width: xScale(d.value),
height: 25
}));
}
// In React: {getChartElements(data).map((d, i) => <rect key={i} {...d} fill="steelblue" />)}// In Vue: v-for directive over the returned array// In vanilla JS: Create elements manually from the returned data
Use Pattern A for complex visualisations with transitions, interactions, or when leveraging d3's full capabilities. Use Pattern B for simpler visualisations or when your framework prefers declarative rendering.
3. Structure the visualisation code
Follow this standard structure in your drawing function:
functiondrawVisualization(data) {
if (!data || data.length === 0) return;
const svg = d3.select('#chart'); // Or pass a selector/element
svg.selectAll("*").remove(); // Clear previous render// 1. Define dimensionsconst width = 800;
const height = 400;
const margin = { top: 20, right: 30, bottom: 40, left: 50 };
const innerWidth = width - margin.left - margin.right;
const innerHeight = height - margin.top - margin.bottom;
// 2. Create main group with marginsconst g = svg.append("g")
.attr("transform", `translate(${margin.left},${margin.top})`);
// 3. Create scalesconst xScale = d3.scaleLinear()
.domain([0, d3.max(data, d => d.x)])
.range([0, innerWidth]);
const yScale = d3.scaleLinear()
.domain([0, d3.max(data, d => d.y)])
.range([innerHeight, 0]); // Note: inverted for SVG coordinates// 4. Create and append axesconst xAxis = d3.axisBottom(xScale);
const yAxis = d3.axisLeft(yScale);
g.append("g")
.attr("transform", `translate(0,${innerHeight})`)
.call(xAxis);
g.append("g")
.call(yAxis);
// 5. Bind data and create visual elements
g.selectAll("circle")
.data(data)
.join("circle")
.attr("cx", d =>xScale(d.x))
.attr("cy", d =>yScale(d.y))
.attr("r", 5)
.attr("fill", "steelblue");
}
// Call when data changesdrawVisualization(myData);
4. Implement responsive sizing
Make visualisations responsive to container size:
functionsetupResponsiveChart(containerId, data) {
const container = document.getElementById(containerId);
const svg = d3.select(`#${containerId}`).append('svg');
functionupdateChart() {
const { width, height } = container.getBoundingClientRect();
svg.attr('width', width).attr('height', height);
// Redraw visualisation with new dimensionsdrawChart(data, svg, width, height);
}
// Update on initial loadupdateChart();
// Update on window resizewindow.addEventListener('resize', updateChart);
// Return cleanup functionreturn() =>window.removeEventListener('resize', updateChart);
}
// Usage:// const cleanup = setupResponsiveChart('chart-container', myData);// cleanup(); // Call when component unmounts or element removed
Or use ResizeObserver for more direct container monitoring:
This skill provides guidance for creating sophisticated, interactive data visualisations using d3.js. D3.js (Data-Driven Documents) excels at binding data to DOM elements and applying data-driven transformations to create custom, publication-quality visualisations with precise control over every visual element. The techniques work across any JavaScript environment, including vanilla JavaScript, React, Vue, Svelte, and other frameworks.
Use @claude-d3js-skill-v3 to handle <task>. Start from the copied upstream workflow, load only the files that change the outcome, and keep provenance visible in the answer.
Explanation: This is the safest starting point when the operator needs the imported workflow, but not the entire repository.
Example 2: Ask for a provenance-grounded review
Review @claude-d3js-skill-v3 against metadata.json and ORIGIN.md, then explain which copied upstream files you would load first and why.
Explanation: Use this before review or troubleshooting when you need a precise, auditable explanation of origin and file selection.
Example 3: Narrow the copied support files before execution
Use @claude-d3js-skill-v3 for <task>. Load only the copied references, examples, or scripts that change the outcome, and name the files explicitly before proceeding.
Explanation: This keeps the skill aligned with progressive disclosure instead of loading the whole copied package by default.
Example 4: Build a reviewer packet
Review @claude-d3js-skill-v3 using the copied upstream files plus provenance, then summarize any gaps before merge.
Explanation: This is useful when the PR is waiting for human review and you want a repeatable audit packet.
Best Practices
Treat the generated public skill as a reviewable packaging layer around the upstream repository. The goal is to keep provenance explicit and load only the copied source material that materially improves execution.
Data preparation Always validate and prepare data before visualisation: javascript // Filter invalid values const cleanData = data.filter(d => d.value != null && !isNaN(d.value)); // Sort data if order matters const sortedData = [...data].sort((a, b) => b.value - a.value); // Parse dates const parsedData = data.map(d => ({ ...d, date: d3.timeParse("%Y-%m-%d")(d.date) })); ### Performance optimisation For large datasets (>1000 elements): javascript // Use canvas instead of SVG for many elements // Use quadtree for collision detection // Simplify paths with d3.line().curve(d3.curveStep) // Implement virtual scrolling for large lists // Use requestAnimationFrame for custom animations ### Accessibility Make visualisations accessible: javascript // Add ARIA labels svg.attr("role", "img") .attr("aria-label", "Bar chart showing quarterly revenue"); // Add title and description svg.append("title").text("Quarterly Revenue 2024"); svg.append("desc").text("Bar chart showing revenue growth across four quarters"); // Ensure sufficient colour contrast // Provide keyboard navigation for interactive elements // Include data table alternative ### Styling Use consistent, professional styling: javascript // Define colour palettes upfront const colours = { primary: '#4A90E2', secondary: '#7B68EE', background: '#F5F7FA', text: '#333333', gridLines: '#E0E0E0' }; // Apply consistent typography svg.selectAll("text") .style("font-family", "Inter, sans-serif") .style("font-size", "12px"); // Use subtle grid lines g.selectAll(".tick line") .attr("stroke", colours.gridLines) .attr("stroke-dasharray", "2,2");
Keep the imported skill grounded in the upstream repository; do not invent steps that the source material cannot support.
Prefer the smallest useful set of support files so the workflow stays auditable and fast to review.
Keep provenance, source commit, and imported file paths visible in notes and PR descriptions.
Point directly at the copied upstream files that justify the workflow instead of relying on generic review boilerplate.
Treat generated examples as scaffolding; adapt them to the concrete task before execution.
Route to a stronger native skill when architecture, debugging, design, or security concerns become dominant.
Imported Operating Notes
Imported: Best practices
Data preparation
Always validate and prepare data before visualisation:
// Filter invalid valuesconst cleanData = data.filter(d => d.value != null && !isNaN(d.value));
// Sort data if order mattersconst sortedData = [...data].sort((a, b) => b.value - a.value);
// Parse datesconst parsedData = data.map(d => ({
...d,
date: d3.timeParse("%Y-%m-%d")(d.date)
}));
Performance optimisation
For large datasets (>1000 elements):
// Use canvas instead of SVG for many elements// Use quadtree for collision detection// Simplify paths with d3.line().curve(d3.curveStep)// Implement virtual scrolling for large lists// Use requestAnimationFrame for custom animations
Accessibility
Make visualisations accessible:
// Add ARIA labels
svg.attr("role", "img")
.attr("aria-label", "Bar chart showing quarterly revenue");
// Add title and description
svg.append("title").text("Quarterly Revenue 2024");
svg.append("desc").text("Bar chart showing revenue growth across four quarters");
// Ensure sufficient colour contrast// Provide keyboard navigation for interactive elements// Include data table alternative
Problem: The operator skipped the imported context and answered too generically
Symptoms: The result ignores the upstream workflow in plugins/antigravity-bundle-data-analytics/skills/claude-d3js-skill, fails to mention provenance, or does not use any copied source files at all.
Solution: Re-open metadata.json, ORIGIN.md, and the most relevant copied upstream files. Check the external_source block first, then restate the provenance before continuing.
Problem: The imported workflow feels incomplete during review
Symptoms: Reviewers can see the generated SKILL.md, but they cannot quickly tell which references, examples, or scripts matter for the current task.
Solution: Point at the exact copied references, examples, scripts, or assets that justify the path you took. If the gap is still real, record it in the PR instead of hiding it.
Problem: The task drifted into a different specialization
Symptoms: The imported skill starts in the right place, but the work turns into debugging, architecture, design, security, or release orchestration that a native skill handles better.
Solution: Use the related skills section to hand off deliberately. Keep the imported provenance visible so the next skill inherits the right context instead of starting blind.
Related Skills
@ab-test-setup-v3 - Use when the work is better handled by that native specialization after this imported skill establishes context.
@algolia-search-v3 - Use when the work is better handled by that native specialization after this imported skill establishes context.
@algorithmic-art-v3 - Use when the work is better handled by that native specialization after this imported skill establishes context.
@analytics-tracking-v3 - Use when the work is better handled by that native specialization after this imported skill establishes context.
Additional Resources
Use this support matrix and the linked files below as the operator packet for this imported skill. They should reflect real copied source material, not generic scaffolding.
Resource family
What it gives the reviewer
Example path
references
copied reference notes, guides, or background material from upstream
references/colour-schemes.md
examples
worked examples or reusable prompts copied from upstream
examples/n/a
scripts
upstream helper scripts that change execution or validation
scripts/n/a
agents
routing or delegation notes that are genuinely part of the imported package
agents/n/a
assets
supporting assets or schemas copied from the source package
d3-patterns.md - Comprehensive collection of visualisation patterns and code examples
scale-reference.md - Complete guide to d3 scales with examples
colour-schemes.md - D3 colour schemes and palette recommendations
assets/
Contains boilerplate templates:
chart-template.js - Starter template for basic chart
interactive-template.js - Template with tooltips, zoom, and interactions
sample-data.json - Example datasets for testing
These templates work with vanilla JavaScript, React, Vue, Svelte, or any other JavaScript environment. Adapt them as needed for your specific framework.
To use these resources, read the relevant files when detailed guidance is needed for specific visualisation types or patterns.