Published
Edited
Mar 25, 2019
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
margin_line = ({top: 20, right: 20, bottom: 30, left: 30})
Insert cell
Insert cell
Insert cell
xAxis_line = g => g
.attr("transform", `translate(0,${height_line - margin_line.bottom})`)
.call(d3.axisBottom(x_line).ticks(width / 80).tickSizeOuter(0))
.call(g => g.select(".tick:last-of-type text").clone()
.attr("x",-30)
.attr("y",-10)
.attr("text-anchor", "start")
.attr("font-weight", "bold")
.text(line_data.x))
Insert cell
yAxis_line = g => g
.attr("transform", `translate(${margin_line.left},0)`)
.call(d3.axisLeft(y_line))
.call(g => g.select(".domain").remove())
.call(g => g.select(".tick:last-of-type text").clone()
.attr("x", 3)
.attr("text-anchor", "start")
.attr("font-weight", "bold")
.text(line_data.y))
Insert cell
line = d3.line()
.defined(d => !isNaN(d))
.x((d, i) => x_line(line_data.dates[i]))
.y(d => y_line(d))
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
month_data = {
var to_return = [];
if (slider1 != null){
var idx = ["Jan","Feb","Mar","Apr","May","Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"].indexOf(slider1);
var i;
for(i = 0; i < incident.length; i++){
to_return.push({
name: incident[i],
value: transformed_data[idx][incident[i]]
});
}
}

return to_return;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
width = 975
Insert cell
height = width
Insert cell
innerRadius = 180
Insert cell
outerRadius = Math.min(width, height) / 2
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
d3 = require("d3@5")
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more