Skip to content

Instantly share code, notes, and snippets.

@cliff145
Created September 20, 2015 11:07
Show Gist options
  • Select an option

  • Save cliff145/fb6a1771a4fef7150c5f to your computer and use it in GitHub Desktop.

Select an option

Save cliff145/fb6a1771a4fef7150c5f to your computer and use it in GitHub Desktop.
Module 5 - Scatterplot
Facility BeginDate EndDate County ControlType HoursType Cost ProductiveHoursPatient
Penn 1/1/2013 8/31/2013 Sacramento Investor Daily Cost Centers 143043 12.25
Cooper 1/1/2013 8/31/2013 Sacramento Investor Management & Supervision 116488 10.6
Jefferson 1/1/2013 10/30/2013 Alameda Non-Profit Daily Cost Centers 224760 9.08
Aria 1/1/2013 10/8/2013 Los Angeles Investor Daily Cost Centers 91751 8.94
Wills Eye 1/1/2013 10/30/2013 Alameda Non-Profit Registered Nurse 234420 8.49
LA Medical 1/1/2013 7/15/2013 Los Angeles Non-Profit Ancillary Cost Centers 144211 7.99
Rothman Institute 1/1/2013 7/15/2013 Los Angeles Non-Profit Daily Cost Centers 133839 7.25
St. Joe's Hospital 1/1/2013 10/30/2013 Alameda Non-Profit Technician & Specialist 72535 6.76
Mayo Clinic 1/1/2013 10/30/2013 Alameda Non-Profit General Services Cost Centers 236735 6.67
Johns Hopkins 1/1/2013 10/30/2013 Alameda Non-Profit Ancillary Cost Centers 236683 6.2
MA General 1/1/2013 7/15/2013 Los Angeles Non-Profit Registered Nurse 70141 6.12
UCSF Medical 1/1/2013 7/15/2013 Los Angeles Non-Profit Technician & Specialist 102213 5.29
Northwestern 1/1/2013 10/8/2013 Los Angeles Investor Clerical & Other Administrative 229242 4.83
NY Presbeterian 1/1/2013 10/30/2013 Alameda Non-Profit Ambulatory Cost Centers 96205 4.3
San Leandro Hospital 1/1/2013 10/30/2013 Alameda Non-Profit Contracted Other 86634 4.29
Yale-New Haven 1/1/2013 7/15/2013 Los Angeles Non-Profit Aides & Orderlies 141266 4.28
Brigham Hospital 1/1/2013 8/31/2013 Sacramento Investor Ancillary Cost Centers 157999 4.14
Cedars 1/1/2013 10/8/2013 Los Angeles Investor Technician & Specialist 236944 4.08
Sainai 1/1/2013 10/30/2013 Alameda Non-Profit Clerical & Other Administrative 65909 3.99
Barnes 1/1/2013 8/31/2013 Sacramento Investor Technician & Specialist 213072 3.99
UCLA 1/1/2013 10/8/2013 Los Angeles Investor Registered Nurse 176588 3.73
Scripps 1/1/2013 10/8/2013 Los Angeles Investor Management & Supervision 142322 3.67
Stanford 1/1/2013 7/15/2013 Los Angeles Non-Profit Clerical & Other Administrative 74482 3.58
Beaumont 1/1/2013 8/31/2013 Sacramento Investor Administrative Services Cost Centers 183666 3.51
Emory 1/1/2013 10/8/2013 Los Angeles Investor Ancillary Cost Centers 208604 3.35
Baylor 1/1/2013 10/8/2013 Los Angeles Investor Administrative Services Cost Centers 224150 3.28
Duke 1/1/2013 8/31/2013 Sacramento Investor General Services Cost Centers 131439 3.25
John Muir 1/1/2013 10/8/2013 Los Angeles Investor General Services Cost Centers 244501 2.96
Houston Methodist 1/1/2013 10/8/2013 Los Angeles Investor Contracted Other 126924 2.61
Langone 1/1/2013 8/31/2013 Sacramento Investor Environmental & Food Services 180401 2.59
Christiana 1/1/2013 10/30/2013 Alameda Non-Profit Administrative Services Cost Centers 183207 2.33
UF Shands 1/1/2013 8/31/2013 Sacramento Investor Aides & Orderlies 77112 2.31
Colorado Hospital 1/1/2013 10/30/2013 Alameda Non-Profit Fiscal Services Cost Centers 91455 2.23
Washington Medical 1/1/2013 10/30/2013 Alameda Non-Profit Environmental & Food Services 85190 2.2
IU Health 1/1/2013 7/15/2013 Los Angeles Non-Profit General Services Cost Centers 53759 2.18
Vanderbilt Health 1/1/2013 8/31/2013 Sacramento Investor Licensed Vocational Nurse 216549 2.04
Froedert 1/1/2013 10/30/2013 Alameda Non-Profit Aides & Orderlies 201968 2.02
UM Health 1/1/2013 10/8/2013 Los Angeles Investor Fiscal Services Cost Centers 141768 1.97
Beth Israel 1/1/2013 7/15/2013 Los Angeles Non-Profit Fiscal Services Cost Centers 229382 1.7
Baystate 1/1/2013 7/15/2013 Los Angeles Non-Profit Management & Supervision 233204 1.5
Banner Good 1/1/2013 7/15/2013 Los Angeles Non-Profit Administrative Services Cost Centers 144846 1.49
Aurora 1/1/2013 7/15/2013 Los Angeles Non-Profit Ambulatory Cost Centers 175730 1.42
Lancaster 1/1/2013 10/8/2013 Los Angeles Investor Ambulatory Cost Centers 60756 1.35
Lankenau 1/1/2013 10/30/2013 Alameda Non-Profit Contracted Registry Nursing 186356 1.12
Hillcrest 1/1/2013 10/30/2013 Alameda Non-Profit Management & Supervision 127943 1
Kiaser Permanente 1/1/2013 10/8/2013 Los Angeles Investor Education Cost Centers 161830 1
Munson 1/1/2013 10/8/2013 Los Angeles Investor Other 232526 0.97
Abbot 1/1/2013 10/8/2013 Los Angeles Investor Licensed Vocational Nurse 101367 0.96
Abington 1/1/2013 10/30/2013 Alameda Non-Profit Licensed Vocational Nurse 75112 0.95
Adena 1/1/2013 8/31/2013 Sacramento Investor Clerical & Other Administrative 57147 0.89
Adventist 1/1/2013 8/31/2013 Sacramento Investor Other 199616 0.78
Trinity Medical 1/1/2013 10/8/2013 Los Angeles Investor Contracted Registry Nursing 116044 0.77
Aiken Regional 1/1/2013 10/8/2013 Los Angeles Investor Aides & Orderlies 208353 0.76
Verdugo Hills Hospital 1/1/2013 7/15/2013 Los Angeles Non-Profit Licensed Vocational Nurse 59430 0.75
Pacific Hospital Of Long Beach 1/1/2013 10/8/2013 Los Angeles Investor Environmental & Food Services 130334 0.48
Almance 1/1/2013 7/15/2013 Los Angeles Non-Profit Other 84243 0.42
Kindred Hospital 1/1/2013 8/31/2013 Sacramento Investor Fiscal Services Cost Centers 113976 0.33
Albany Medical 1/1/2013 8/31/2013 Sacramento Investor Contracted Registry Nursing 217307 0.22
Alexian 1/1/2013 7/15/2013 Los Angeles Non-Profit Contracted Registry Nursing 88030 0.07
Alta Bates 1/1/2013 8/31/2013 Sacramento Investor Registered Nurse 157314 0.04
Allegiance Medical 1/1/2013 7/15/2013 Los Angeles Non-Profit Contracted Other 72960 0.02
Anaheim 1/1/2013 8/31/2013 Sacramento Investor Contracted Other 167932 0
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Loading CSV Data with D3</title>
<script type="text/javascript" src="http://d3js.org/d3.v3.js"></script>
<style type="text/css">
body {
background-color: white;
font-family: Arial;
font-size: 12px;
text-align: center;
}
h1 {
font-size: 32px;
text-align: left;
}
p {
font-size: 18px;
text-align: left;
}
svg {
background-color: white;
fill: gray;
}
.axis path,
.axis line {
fill: none;
stroke: black;
stroke-width: 2px;
shape-rendering: crispEdges;
}
.axis text {
fill: black;
font-family: sans-serif;
font-size: 10px;
}
circle:hover {
fill: #79007F;
}
g.bar text {
fill: black;
font-size: 10px;
text-anchor: end;
}
</style>
</head>
<body>
<h1>Hospitals' Productive Hours per Patient compared to Cost, CA 2013 (fake data)</h1>
<p>Source: <a href="http://www.healthdata.gov/dataset/hospital-staffing-2009-2013">HealthData.gov</a>, 2013 </p>
<script type="text/javascript">
var w = 500;
var h = 800;
var padding = [ 20, 10, 30, 100 ] //top, right, bottom, left
var xScale = d3.scale.linear()
.range([ padding[3], w - padding[1] ]);
var yScale = d3.scale.linear()
.range([ padding[0], h - padding[2] ]);
var colorScale = d3.scale.ordinal()
.domain(["Sacramento", "Alameda", "Los Angeles"])
.range(["#e1c8a2", "#e1a2a2", "gray"]);
var xAxis = d3.svg.axis()
.scale(xScale)
.orient("bottom")
.ticks(5);
var yAxis = d3.svg.axis()
.scale(yScale)
.orient("left");
var svg = d3.select("body")
.append("svg")
.attr("width", w)
.attr("height", h);
d3.csv("hospitalStaffingMod5.csv", function(data) {
data.sort(function(a, b) {
return d3.descending(+a.ProductiveHoursPatient, +b.ProductiveHoursPatient);
});
xScale.domain([
d3.min(data, function(d) {
return +d.ProductiveHoursPatient - 1;
}),
d3.max(data, function(d) {
return +d.ProductiveHoursPatient + 1;
})
]);
yScale.domain([
d3.max(data, function(d) {
return +d.Cost + 20000;
}),
d3.min(data, function(d) {
return +d.Cost - 20000;
})
]);
var circles = svg.selectAll("circle")
.data(data)
.enter()
.append("circle");
circles.attr("cx", function(d) {
return xScale(d.ProductiveHoursPatient);
})
.attr("cy", function(d) {
return yScale(d.Cost);
})
.attr("r", .1)
.attr("fill", function(d) {
return colorScale(d.County);
})
.append("title")
.text(function(d) {
return d.Facility + "'s Productive Hours per Patient is: " + d.ProductiveHoursPatient + ", and their cost is: " + d.Cost;
});
circles.sort(function(a, b) {
return d3.ascending(+a.ProductiveHoursPatient, +b.ProductiveHoursPatient);
})
.transition()
.delay(function(d, i) {
return i * 40;
})
.duration(2000)
.attr("r", 6);
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + (h - padding[2]) + ")")
.call(xAxis);
svg.append("g")
.attr("class", "y axis")
.attr("transform", "translate(" + padding[3] + ",0)")
.call(yAxis);
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment