Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <h1>Under 18 Population Living in Poverty, 2014</h1>


                @import url(;
h1{font: small-caps 300 2em/1.5em 'Open Sans', sans-serif; text-align: center;margin: 20px auto 0;padding: 0;}
.land{ fill: #ccc; }
	stroke: #fff;
	fill: none;
	stroke-linejoin: round;
	stroke-linecap: round;
.states{fill: #aec7e8;}
.bubble{fill:red; fill-opacity: .5;}
.hover{stroke:#666; fill-opacity: .8;}




var width = 1000,
	height = 600;

var path = d3.geo.path()
	.projection(null) //albersUsa projection stated in Make file when creating the topojson data

var radius = d3.scale.sqrt() 
	.domain([0, 3e6]) // INPUT domain-range of possible input data values
	//To avoid distortion, make sure that the minimum "domain" and "range" values are both 0
	.range([0, 60]); // OUTPUT range of possible output values

var arc = d3.svg.arc()

var svg ='body').append('svg')
	.attr('height', height)
	.attr('width', width);

var toolTip ='body')
	.style('position', 'absolute')
	.style('padding', '0 10px')
	.style('background', '#fff')
	.style('opacity', 0)
  .style('font-family', 'Open Sans')
	.style('z-index', 1000);

d3.json('', function(error, usa){
	if (error) return console.log(error);

	//build the main land area
		.datum(topojson.feature(usa, usa.objects.nation))
		.attr('class', 'land')
		.attr('d', path); 

    // retrieve the features so that id is accessed
    .data(topojson.feature(usa, usa.objects.counties).features)
    .attr('id', function(d) { return; })
    .attr("class", "states states-hover")
    .attr('d', path)

         //add Tool Tip
    .on('mouseover', function(d, i){
			  .style('opacity', .9)
			  .style('left', (d3.event.pageX) + 'px')
			  .style('top', (d3.event.pageY) + 'px')  
			tempColor =; //store current color
			if( != null || != undefined){
				toolTip.html( + ", " +	
			} else {
		.on('mouseout', function(){
			 .style('opacity', 1)
			 .style('fill', tempColor)

	//build internal state lines
		.datum(topojson.mesh(usa, usa.objects.states, function(a, b) { 
			return a !== b; 
		})) //topojson.mesh
		.attr('class', 'border-states')
		.attr('d', path); 

	//show data as layered bubbles
		.attr("class", "bubble")
		.data(topojson.feature(usa, usa.objects.counties).features
			.sort(function(a, b) { //sort population low to high
				return -; 
			}) //sort
		) //data
   .on('mouseover', function(d, i){'class', 'hover')
		.on('mouseout', function(d, i){'class', '')
		.attr("transform", function(d) { 
			return "translate(" + path.centroid(d) + ")"; //Computes the projected centroid
		.attr("r", function(d) { 
			return radius(; //radius var with input (domain) and output (range)

}) //d3.json