Skip to content

Instantly share code, notes, and snippets.

@codetricity
Last active October 14, 2018 13:55
Show Gist options
  • 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

https://i.imgur.com/cWi3cfe.png

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

https://i.imgur.com/S6gGkwy.png

Add Tooltip Labels

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

https://i.imgur.com/wTLFd29.png

Remove Text Label on mouseout

Add Border States

https://i.imgur.com/wUXCSax.png

Add Titles and Transitions

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