Built with blockbuilder.org
xxxxxxxxxx
<head>
<meta charset="utf-8">
<style>
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; }
#title {position:absolute;top:12px;left:0px;width:500px;text-align:center;}
svg { width:100%; height: 100% }
.axis path,
.axis line {
fill: none;
stroke: #000;
shape-rendering: crispEdges;
}
.div_style1 {
border: 2px solid grey;
width: 1050px;
height: 600px;
}
.div_style2 {
border: 2px solid grey;
width: 1050px;
height: 550px;
}
.axis path, .axis line {
fill: none;
stroke: black;
shape-rendering: crispEdges;
}
.axis text {
font-family: sans-serif;
font-size: 11px;
}
.dot {
stroke: #000;
}
</style>
</head>
<body>
<div id="div1" class="div_style1">
</div>
<div id="div2" class="div_style2"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
<script>
var diameter = 500, //max size of the bubbles
color = d3.scale.category20b(); //color category
var bubble = d3.layout.pack()
.sort(null)
.size([diameter, diameter])
.padding(1.5);
var svg = d3.select("body")
.append("svg")
.attr("width", diameter)
.attr("height", diameter)
.attr("class", "bubble");
d3.tsv("https://gist.githubusercontent.com/sjhavanur/d335d1ea06102c47d653/raw/a333373c394f9032f6ddb74cea271b7c012c1719/medicareavg.tsv", function(error, data){
//convert numerical values from strings to numbers
data = data.map(function(d){ d.value = +d["average_submitted_chrg_amt"]; return d; });
//bubbles needs very specific format, convert data to this.
var nodes = bubble.nodes({children:data}).filter(function(d) { return !d.children; });
//setup the chart
var bubbles = svg.append("g")
.attr("transform", "translate(0,0)")
.selectAll(".bubble")
.data(nodes)
.enter();
//create the bubbles
bubbles.append("circle")
.attr("r", function(d){ return d.r; })
.attr("cx", function(d){ return d.x; })
.attr("cy", function(d){ return d.y; })
.style("fill", function(d) { return color(d.value); });
//format the text for each bubble
bubbles.append("text")
.attr("x", function(d){ return d.x; })
.attr("y", function(d){ return d.y + 5; })
.attr("text-anchor", "middle")
.text(function(d){ return d["nppes_provider_state"]; })
.style({
"fill":"white",
"font-family":"Helvetica Neue, Helvetica, Arial, san-serif",
"font-size": "12px"
});
})
</script>
https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js