Skip to content

Instantly share code, notes, and snippets.

@codetricity
Last active October 14, 2018 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codetricity/0b990560c021410190059442f7016d01 to your computer and use it in GitHub Desktop.
Save codetricity/0b990560c021410190059442f7016d01 to your computer and use it in GitHub Desktop.
Civil War Part 2 - Adding Confederate and Border States

Civil War Part 2 - Adding Confederate and Border States

Demo

https://codetricity.github.io/d3-maps/

Append Group to svg

Create Group for confederate circles.

const confederateGroup = svg.append('g');

Draw Confederate Circles

image

const confederateCircles = confederateGroup.selectAll('circle')
.data(confederate)
.enter()
.append('circle')
.style('fill', '#848484')
.attr('cx', (d, i) => i * xScale.bandwidth())
.attr('cy', 300)
.attr('r', 15);

Add Confederate Title

  • place title 50 pixels above the y coordinate of the Confederate circles

image

Add Tooltip Labels

  1. put 20 pixels above the center of each Confederate circle

image

Remove Text Label on mouseout

Add Border States

image

Add Titles and Transitions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment