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
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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more