Published
Edited
Apr 19, 2020
5 forks
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// code here
Insert cell
Insert cell
// code here
Insert cell
Insert cell
// code here
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
d3 = require("d3@5")
Insert cell
Insert cell
Insert cell
simpleContainer = {
const container = d3.select(DOM.svg(1000, 100));
container
.insert('rect')
.attr('width', 30)
.attr('height', 30)
.attr('x', 10)
.attr('y', 10)
.attr('fill', 'purple')
.attr('stroke', 'pink')
.attr('stroke-width', 4);
return container.node();
}
Insert cell
Insert cell
Insert cell
colorGroupsContainer = {
const container = d3.select(DOM.svg(1000, 100));
const pinkGroup = container
.append("g")
.attr("id", "pinkGroup")
const greenGroup = container
.append("g")
.attr("id", "greenGroup")
pinkGroup
.append('rect')
.attr('x', 10)
.attr('y', 10)
.attr('width', '50')
.attr('height', '10')
.attr('fill', '#ff96ca');
greenGroup
.append('rect')
.attr('x', 500)
.attr('y', 50)
.attr('width', '100')
.attr('height', '10')
.attr('fill', 'green');
return container.node();
}
Insert cell
Insert cell
Insert cell
Insert cell
createCirclesWithData = {
const container = d3.select(DOM.svg(1000, 100));
const arr = [ 20, 5, 10, 25, 15 ]
container.selectAll("circle")
.data(arr)
.enter().append("circle")
.attr("fill", "steelblue")
.attr("r", function(d) { return d; })
.attr("cx", function(d, i) { return (i+1)*50; })
.attr("cy", 50);
return container.node();
}
Insert cell
Insert cell
oneOddballCircle = {
const container = d3.select(DOM.svg(1000, 100));
const arr = [ 20, 5, 10, 25, 15 ]
container.append("circle")
.attr("fill", "steelblue")
.attr("cx", 50)
.attr("cy", 50)
.attr("r", 20);
container.selectAll("circle")
.data(arr)
.enter().append("circle")
.attr("r", function(d) { return d; })
.attr("cx", function(d, i) { return (i+1)*50; })
.attr("cy", 50)
;
return container.node();
}
Insert cell
Insert cell
Insert cell
circlesWithJoin = {
const container = d3.select(DOM.svg(1000, 100));
const arr = [ 20, 5, 10, 25, 15 ]
container.append("circle")
.attr("fill", "steelblue")
.attr("cx", 50)
.attr("cy", 50)
.attr("r", 20);
container.selectAll("circle")
.data(arr)
.join("circle")
.attr("r", function(d) { return d; })
.attr("cx", function(d, i) { return (i+1)*50; })
.attr("cy", 50);
return container.node();
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
FileAttachment("simple_bar_chart.png").image()
Insert cell
// This is your starter code
simpleBarCharts = {
const width = 1000;
const height = 100;
const barwidth = 40;
const container = d3.select(DOM.svg(width, height));
const arr = [ 20, 5, 10, 25, 15 ]

return container.node();
}
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