agentsclimarketplace

D3 force bubble

Skill cxcscmu/SkillLearnBench/skills/b1-one-shot-gemini-3.1-pro-preview/stock-data-visualization/d3-force-bubble

Guide for creating clustered bubble charts using D3.js force simulations (v6+), including collision and categorization.From its SKILL.md

Install
npx -y skills add cxcscmu/SkillLearnBench --skill d3-force-bubble

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

SKILL.md

1.2 KB, 286 tokens by cl100k_base, as published. Nobody here has run it

D3.js Force Bubble Chart

This skill covers setting up a D3 force simulation to create a clustered bubble chart.

Setup

You need d3.forceSimulation combined with positioning forces (forceX, forceY) and collision forces (forceCollide).

const simulation = d3.forceSimulation(data)
  .force("x", d3.forceX(d => clusterCenters[d.category].x).strength(0.1))
  .force("y", d3.forceY(d => clusterCenters[d.category].y).strength(0.1))
  .force("collide", d3.forceCollide().radius(d => d.radius + 1).iterations(2))
  .on("tick", ticked);

function ticked() {
  node
    .attr("cx", d => d.x)
    .attr("cy", d => d.y);
}

Considerations

  • Radius Scaling: Use d3.scaleSqrt() for sizing bubbles by area (e.g., Market Cap).
  • Collision: Ensure the radius in forceCollide matches the visible radius. Add a small buffer (e.g., + 1) for visual separation.
  • Clustering: Calculate centers for each category beforehand, or dynamically adjust forceX/forceY based on the category of the node.

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.