Skip to content

Instantly share code, notes, and snippets.

@hartzis
Created April 21, 2014 19:57
Show Gist options
  • Save hartzis/11154514 to your computer and use it in GitHub Desktop.
Save hartzis/11154514 to your computer and use it in GitHub Desktop.
hove pie example -
specialty payments
Internal Medicine 195128.97999999998
Optometry 47320.29
Interventional Pain Management 75131.96
Clinical Psychologist 8566.87
Occupational therapist 16264.46
Physical Therapist 155039.89999999997
Mass Immunization Roster Biller 27733.28
Emergency Medicine 13628.17
Family Practice 207513.41
Nephrology 332823.44
Ophthalmology 170976.02
Otolaryngology 77590.5
Nurse Practitioner 19071.27
Chiropractic 12909.73
Pathology 13280.58
General Practice 252393.31
Obstetrics/Gynecology 3574.4800000000005
Physician Assistant 13308.41
{"description":"hove pie example - ","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"arvadaPayments.csv":{"default":true,"vim":false,"emacs":false,"fontSize":12},"main.css":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"main.js":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":true,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"pingpong","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"ajax-caching":true,"thumbnail":"http://i.imgur.com/3gvMepr.gif"}
var arvadaData = tributary.arvadaPayments
var sumPayments = d3.sum(arvadaData, function(d) {return +d.payments;});
var svg = d3.select("svg");
var width = 527,
height = 562,
radius = Math.min(width, height) / 2;
var outerRadius = width/2;
var colorScale = d3.scale.category20(); //built in range of 20 colors
var arc = d3.svg.arc() //creates <path> elements using arc data
.outerRadius(width / 2)
.innerRadius(100);
var pie = d3.layout.pie()
.sort(null)
.value(function(d){ return +d.payments });
var g = svg.selectAll("g.arc")
.data(pie(arvadaData))
.enter()
.append("g")
.attr("class", "arc")
.attr("transform", "translate(" + width/2 + "," + height/2 + ")");
svg.selectAll(".title")
.data([sumPayments])
.enter()
.append("text")
.attr({ x: 52,
y: 44})
.text("Arvada Medicare Payments by Specialty");
g.append("path")
.attr("fill", function(d){return colorScale(d.data.payments);})
.attr("d", arc)
g
.append("text")
.attr("transform", function(d){ return "translate(" + arc.centroid(0) +")"; })
.attr("text-anchor", "middle")
.text(function(d){ return d.data.specialty; })
.attr('class', 'text-title');
.text-title {
display: none;
font-size: 12px;
}
.title{
margin 0 auto
height 50px
width 300px
font-size 40px
}
$(".title").text("Aravada Medicare Payment by Specialty");
$("g").on("hover", function(){
$(this).find(".text-title").toggle();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment