Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add area symbols as point clouds by type #1

Open
justinlewis opened this issue Oct 27, 2015 · 0 comments
Open

Add area symbols as point clouds by type #1

justinlewis opened this issue Oct 27, 2015 · 0 comments

Comments

@justinlewis
Copy link
Owner

A point cloud would be a single point for each route placed in a circular cloud colored by type. Andy Woodruff provided an basic example of how he did this:

////  Incomplet. For example only.
var g = symbols.append("g"),
statePath = d3.select( /* selector for the state polygon */ ),
centroid = path.centroid( statePath.datum() );

var total = // whatever the total number of dots is
  dotDiameter = 4,
  dist = 0,
  circumference = 0,
  canFit = 1,
  count = 0,
  angleDelta = 0;
for ( var i=0; i<total; i++ ){
  count++;
  if ( count > canFit ){
    dist += dotDiameter;
    circumference = 2 * dist * Math.PI;
    canFit = Math.floor( circumference / dotDiameter ),
    angleDelta = 2 * Math.PI / canFit;
    count = 0;
  }
  var currentAngle = angleDelta * count;
  var x = Math.cos(currentAngle) * dist,
      y = Math.sin(currentAngle) * dist;

  g.append( "circle" )
    .attr("cx",x+dotDiameter/2)
    .attr("cy",y+dotDiameter/2)
    .attr("r",dotDiameter/2)
    .attr("fill","#ccc")
    .attr("stroke","#666");
}
g.attr("transform","translate(" + centroid.toString() + ")");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant