d3-force-bubble-chart
Create force-simulation bubble charts with D3.js v6, including sector clustering, collision avoidance, tooltips, and legends.
- License 许可
- MIT
- 最近更新
- 2026-10-02
- Stars
- ★ 93
- Forks
- 8
01 前言 Front Matter
- name
- d3-force-bubble-chart
- description
- Create force-simulation bubble charts with D3.js v6, including sector clustering, collision avoidance, tooltips, and legends.
03 SKILL.md 正文
D3.js v6 Force-Simulation Bubble Chart
Key Concepts
- Use
d3.forceSimulation()withforceX,forceY,forceCollide, andforceManyBodyto position bubbles. - Cluster by category using
forceX(sectorX).strength(...)andforceY(sectorY).strength(...). - Size bubbles via a
d3.scaleSqrt()mapped from data (e.g., market cap) to radius. - Color bubbles via
d3.scaleOrdinal(d3.schemeTableau10)keyed on sector.
Force Simulation Pattern
const simulation = d3.forceSimulation(data)
.force("x", d3.forceX(d => sectorX(d.sector)).strength(0.3))
.force("y", d3.forceY(d => sectorY(d.sector)).strength(0.3))
.force("collide", d3.forceCollide(d => radiusScale(d.marketCap) + 1.5))
.force("charge", d3.forceManyBody().strength(-2))
.on("tick", ticked);
Sector Clustering
Assign each sector a target (x, y) position to group bubbles:
const sectors = [...new Set(data.map(d => d.sector))];
const sectorPositions = {};
sectors.forEach((s, i) => {
const angle = (2 * Math.PI * i) / sectors.length;
sectorPositions[s] = {
x: centerX + clusterRadius * Math.cos(angle),
y: centerY + clusterRadius * Math.sin(angle)
};
});
Tooltips
Use a div.tooltip with position: absolute and pointer-events: none. Show on mouseover, hide on mouseout.
Legend
Render colored rectangles + text labels for each sector using SVG <g> elements.
04 同仓库更多 Skills
object_counter
Count occurrences of an object in the image using computer vision algorithm.
travel-planning-workflow
Invoke this skill when performing travel planning. It defines a structured workflow for generating itineraries. Following this workflow is essential to ensure the final plan satisfies user requirements.
bundled-dataset-search-tool
invoke this skill when you need to perform database search for travel planning. This skill provides some useful pre-packaged tools to look up accommodations, attractions, cities, driving distance, flights, and restaurants from the bundled dataset.
glm-output
Output-processing guidance for GLM tasks. Especially useful after glm-basics and glm-calibration when you need verifier-matching metrics from output.nc and a final /root/metrics.json.
glm-calibration
Calibration guidance for GLM tasks. Often most effective after glm-basics has clarified the setup; glm-output is the companion skill for exact final metric computation.
glm-basics
A good starting point for GLM calibration tasks. Use to inspect glm3.nml, confirm how GLM runs, and identify the relevant files before moving on to calibration and output evaluation.