Skip to content

Instantly share code, notes, and snippets.

@johardi
Last active August 29, 2015 14:05
Show Gist options
  • Save johardi/8ca1805036cbe969b9f3 to your computer and use it in GitHub Desktop.
Save johardi/8ca1805036cbe969b9f3 to your computer and use it in GitHub Desktop.
Hubungan Jumlah Personil dengan Rataan Lama Operasi Penyelamatan

Dengan menggabungkan data personil Pemkar dan data rekaman penanggulangan bencana dan kebakaran tahun 2013 didapat grafik hubungan antara jumlah personil dengan waktu operasi penyelamatan per kecamatan.

Sumber data: Data Kejadian Bencana DKI Jakarta (periode 2013)

kecamatan jumlah_insiden waktu_respon waktu_operasi jumlah_pos total_personil total_kendaraan
Cakung 10 6 176 2 20 9
Menteng 4 7 324 1 7 4
Ciracas 2 13 81 2 8 3
Kebayoran Baru 12 36 104 3 18 6
Kebayoran Lama 16 7 141 2 10 4
Penjaringan 36 16 470 2 12 3
Kemayoran 5 8 425 3 31 12
Setiabudi 1 11 105 1 6 1
Pademangan 11 28 201 2 13 4
Grogol Petamburan 14 6 392 2 37 21
Cipayung 4 7 132 1 4 6
Duren Sawit 10 8 382 2 12 7
Jatinegara 13 7 269 1 9 4
Jagakarsa 10 6 110 3 16 7
Johar Baru 1 10 210 1 8 4
Matraman 6 7 133 2 21 11
Cilincing 12 8 123 2 36 14
Pancoran 10 12 385 1 6 2
Tanjung Priok 9 8 114 1 7 1
Makasar 8 8 238 1 8 4
Cilandak 10 6 125 1 5 1
Kalideres 17 6 125 3 18 5
Cempaka Putih 2 5 108 2 14 6
Kelapa Gading 9 7 247 2 10 3
Tanah Abang 8 5 472 4 18 8
Gambir 5 54 299 5 54 26
Cengkareng 18 6 137 3 20 7
Kramat Jati 17 6 233 2 17 8
Sawah Besar 9 6 240 3 23 8
Pesanggrahan 13 6 158 1 5 1
Kembangan 12 5 112 3 16 5
Koja 3 8 226 1 28 6
Tambora 12 6 164 3 18 8
Pasar Minggu 10 7 215 3 21 8
Mampang Prapatan 4 7 129 1 6 1
Bekasi 8 31 1556 0 0 0
Senen 8 6 134 0 0 0
Pulogadung 18 8 143 0 0 0
Kep. Seribu Selatan 1 5 389 0 0 0
Palmerah 8 6 329 0 0 0
Pasar Rebo 2 13 78 0 0 0
Kebun Jeruk 13 12 160 0 0 0
Depok 3 28 268 0 0 0
Tebet 9 11 246 0 0 0
Tangerang 11 7 139 0 0 0
Tamansari 12 7 262 0 0 0
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<style>
body {
font: 11px sans-serif;
}
.axis path,
.axis line {
fill: none;
stroke: #000;
shape-rendering: crispEdges;
}
.dot {
stroke: #000;
}
.tooltip {
background-color: white;
position: absolute;
width: 160px;
height: 28px;
pointer-events: none;
}
</style>
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script>
var margin = {top: 20, right: 20, bottom: 30, left: 40},
width = 700 - margin.left - margin.right,
height = 450 - margin.top - margin.bottom;
var x = d3.scale.linear().range([0, width]),
y = d3.scale.linear().range([height, 0]),
r = d3.scale.linear().range([3, 20]);
var xAxis = d3.svg.axis().scale(x).tickFormat(d3.format('.0f')).orient("bottom"),
yAxis = d3.svg.axis().scale(y).orient("left");
var plot = d3.select("body").append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
var tooltip = d3.select("body").append("div")
.attr("class", "tooltip")
.style("opacity", 0);
d3.csv("data.csv", function(error, data) {
data.forEach(function(d) {
d["jumlah_pos"] = +d["jumlah_pos"]; // convert to number
d["jumlah_insiden"] = +d["jumlah_insiden"];
d["waktu_respon"] = +d["waktu_respon"];
d["total_personil"] = +d["total_personil"];
d["total_kendaraan"] = +d["total_kendaraan"];
d["waktu_operasi"] = +d["waktu_operasi"];
});
data = data.filter(function(d) {
if(d["jumlah_pos"] == 0 || d["total_personil"] == 0) {
return false;
}
return true;
});
x.domain([d3.min(data, function(d) { return d["total_personil"]; })-1, d3.max(data, function(d) { return d["total_personil"]; })+1]);
y.domain([d3.min(data, function(d) { return d["waktu_operasi"]; })-1, d3.max(data, function(d) { return d["waktu_operasi"]; })+1]);
plot.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0, " + height + ")")
.call(xAxis)
.append("text")
.attr("class", "label")
.attr("x", width)
.attr("y", -6)
.style("text-anchor", "end")
.text("Jumlah personil");
plot.append("g")
.attr("class", "y axis")
.call(yAxis)
.append("text")
.attr("class", "label")
.attr("transform", "rotate(-90)")
.attr("y", 6)
.attr("dy", ".71em")
.style("text-anchor", "end")
.text("Rataan lama operasi (menit)");
// draw dots
plot.selectAll(".dot")
.data(data)
.enter().append("circle")
.attr("class", "dot")
.attr("r", 3.5)
.attr("cx", function(d) { return x(d["total_personil"]); })
.attr("cy", function(d) { return y(d["waktu_operasi"]); })
.style("fill", "black")
.on("mouseover", function(d) {
tooltip.transition()
.duration(200)
.style("opacity", .9);
tooltip.html("<b>" + d["kecamatan"] + "</b><br/>" +
d["total_personil"] + " personil<br />" +
"Rata-rata operasi: " + d["waktu_operasi"] + " menit")
.style("left", (d3.event.pageX + 10) + "px")
.style("top", (d3.event.pageY - 28) + "px");
})
.on("mouseout", function(d) {
tooltip.transition()
.duration(500)
.style("opacity", 0);
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment