Published unlisted
Edited
Aug 19, 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
Insert cell
Insert cell
south_asia_department_energy_safeguards_chart = {
const svg = d3.select(DOM.svg(width, height));
svg.append("g")
.attr("fill", "steelblue")
.selectAll("rect").data(chart_data).enter().append("rect")
.attr("x", d => x(d.name))
.attr("y", d => y(d.value))
.attr("height", d => y(0) - y(d.value))
.attr("width", x.bandwidth());
svg.append("g")
.call(xAxis);
svg.append("g")
.call(yAxis);
return svg.node();
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
south_asia_department_energy_safeguards_env_chart = {
const svg = d3.select(DOM.svg(width, height));
svg.append("g")
.attr("fill", "steelblue")
.selectAll("rect").data(chart_data_env).enter().append("rect")
.attr("x", a => x_env(a.name))
.attr("y", a => y_env(a.value))
.attr("height", a => y_env(0) - y_env(a.value))
.attr("width", x_env.bandwidth());
svg.append("g")
.call(xAxis_env);
svg.append("g")
.call(yAxis_env);
return svg.node();
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
south_asia_department_energy_safeguards_ip_chart = {
const svg = d3.select(DOM.svg(width, height));
svg.append("g")
.attr("fill", "steelblue")
.selectAll("rect").data(sard_safeguards_data_ip).enter().append("rect")
.attr("x", b => x_ip(b.name))
.attr("y", b => y_ip(b.value))
.attr("height", b => y_ip(0) - y_ip(b.value))
.attr("width", x_ip.bandwidth());
svg.append("g")
.call(xAxis_ip);
svg.append("g")
.call(yAxis_ip);
return svg.node();
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
south_asia_department_energy_safeguards_ir_chart = {
const svg = d3.select(DOM.svg(width, height));
svg.append("g")
.attr("fill", "steelblue")
.selectAll("rect").data(sard_safeguards_data_ir).enter().append("rect")
.attr("x", c => x_ir(c.name))
.attr("y", c => y_ir(c.value))
.attr("height", c => y_ir(0) - y_ir(c.value))
.attr("width", x_ir.bandwidth());
svg.append("g")
.call(xAxis_ir);
svg.append("g")
.call(yAxis_ir);
return svg.node();
}
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
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
Insert cell
Insert cell
Insert cell
x = d3.scaleBand()
.domain(chart_data.map(d => d.name))
.range([margin.left, width - margin.right])
.padding(0.1)
Insert cell
x_env = d3.scaleBand()
.domain(chart_data_env.map(d => d.name))
.range([margin.left, width - margin.right])
.padding(0.1)
Insert cell
x_ir = d3.scaleBand()
.domain(sard_safeguards_data_ir.map(d => d.name))
.range([margin.left, width - margin.right])
.padding(0.1)
Insert cell
x_ip = d3.scaleBand()
.domain(sard_safeguards_data_ip.map(d => d.name))
.range([margin.left, width - margin.right])
.padding(0.1)
Insert cell
y = d3.scaleLinear()
.domain([0, d3.max(chart_data, d => d.value)]).nice()
.range([height - margin.bottom, margin.top])
Insert cell
y_env = d3.scaleLinear()
.domain([0, d3.max(chart_data_env, d => d.value)]).nice()
.range([height - margin.bottom, margin.top])
Insert cell
y_ir = d3.scaleLinear()
.domain([0, d3.max(sard_safeguards_data_ir, d => d.value)]).nice()
.range([height - margin.bottom, margin.top])
Insert cell
y_ip = d3.scaleLinear()
.domain([0, d3.max(sard_safeguards_data_ip, d => d.value)]).nice()
.range([height - margin.bottom, margin.top])
Insert cell
xAxis = g => g
.attr("transform", `translate(0,${height - margin.bottom})`)
.call(d3.axisBottom(x)
.tickSizeOuter(0))
Insert cell
xAxis_env = g => g
.attr("transform", `translate(0,${height - margin.bottom})`)
.call(d3.axisBottom(x_env)
.tickSizeOuter(0))
Insert cell
xAxis_ir = g => g
.attr("transform", `translate(0,${height - margin.bottom})`)
.call(d3.axisBottom(x_ir)
.tickSizeOuter(0))
Insert cell
xAxis_ip = g => g
.attr("transform", `translate(0,${height - margin.bottom})`)
.call(d3.axisBottom(x_ip)
.tickSizeOuter(0))
Insert cell
yAxis = g => g
.attr("transform", `translate(${margin.left},0)`)
.call(d3.axisLeft(y))
.call(g => g.select(".domain").remove())
Insert cell
yAxis_env = g => g
.attr("transform", `translate(${margin.left},0)`)
.call(d3.axisLeft(y))
.call(g => g.select(".domain").remove())
Insert cell
yAxis_ir = g => g
.attr("transform", `translate(${margin.left},0)`)
.call(d3.axisLeft(y))
.call(g => g.select(".domain").remove())
Insert cell
yAxis_ip = g => g
.attr("transform", `translate(${margin.left},0)`)
.call(d3.axisLeft(y))
.call(g => g.select(".domain").remove())
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
safeguard_distribution_region_color = d3.scaleOrdinal()
.domain(sard_regional_distribution_data.map(d => d.name))
.range(d3.quantize(t => d3.interpolateSpectral(t * 0.8 + 0.1), sard_regional_distribution_data.length).reverse())
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