Published
Edited
May 13, 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
sevis_plot = {
const svg = d3.select(DOM.svg(width, height));
svg.append("g")
.selectAll("path")
.data(sevis_series)
.join("path")
.attr("fill", d => sevis_color(d.key))
.attr("d", d => sevis_area(d))
.attr("id", d => "path-"+d.key.toLowerCase().replace("\'", "").replace(" ", "-"))
.on("mouseover", sevisMouseover)
.on("mouseout", sevisMouseout);
svg.append("g")
.call(sevisDateAxis);
svg.append("g")
.call(sevisYAxis);

svg.append("g")
.call(sevis_legend);
return svg.node();
}
Insert cell
Insert cell
Insert cell
sevisMouseover = function(elemData) {
console.log(elemData);
var key = elemData.key.toLowerCase().replace("\'", "").replace(" ", "-")
d3.select("#path-" + key)
.transition()
.style("stroke", "#e7eeef")
.style("stroke-width", "5px");
d3.select("#legend-" + key)
.transition()
.style("stroke", "#e7eeef")
.style("stroke-width", "3px");
}
Insert cell
sevisMouseout = function(elemData) {
console.log(elemData);
var key = elemData.key.toLowerCase().replace("\'", "").replace(" ", "-")
d3.select("#path-"+key)
.transition()
.style("stroke", "none");
d3.select("#legend-"+key)
.transition()
.style("stroke", "none");
}
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
dateScale = d3.scaleTime()
.domain(dateDomain)
.range([margin.left, width-margin.right]);
Insert cell
Insert cell
Insert cell
Insert cell
nivDateAxis = g => g
.attr("transform", `translate(0,${height - margin.bottom})`)
.call(d3.axisBottom(d3.scaleTime()
.domain(d3.extent(niv_final_data, d=>d.Date))
.range([margin.left, dateScale(d3.max(niv_final_data, d=>d.Date))])
).ticks(width / 100).tickSizeOuter(0))
Insert cell
sevisDateAxis = g => g
.attr("transform", `translate(0,${height - margin.bottom})`)
.call(d3.axisBottom(d3.scaleTime()
.domain(d3.extent(sevis_final_data, d=>d.Date))
.range([dateScale(d3.min(sevis_final_data, d=>d.Date)), width-margin.right])
).ticks(width / 100).tickSizeOuter(0))
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
sevis_color_scheme = ({
// Try 1: Too Dark
// 'DOCTORATE': "#122337",
// 'MASTER\'S': "#1D3857",
// 'BACHELOR\'S': "#274C77",
// 'ASSOCIATE': "#617C9C",
// 'LANGUAGE TRAINING': "#9CADC1",
'DOCTORATE': "#203F62",
'MASTER\'S': "#274C77",
'BACHELOR\'S': "#4E6C8F",
'ASSOCIATE': "#899DB4",
'LANGUAGE TRAINING': "#C4CED9",
'VOCATIONAL': niv_color_scheme['M_1']
});
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