Published
Edited
Sep 18, 2020
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
function drawDrivers(points) {
points
.append('pattern')
.attr('id', d => (d.img = DOM.uid('image')).id)
.attr('class', 'svg-image')
.attr('x', 0)
.attr('y', 0)
.attr('height', 1)
.attr('width', 1)
.append('image')
.attr(
'x',
d =>
(d.image && d.image.offset && d.image.offset.x * radius) || 0 - radius
)
.attr(
'y',
d =>
(d.image && d.image.offset && d.image.offset.y * radius) ||
0 - radius / 4
)
.attr(
'height',
d => (d.image && d.image.size && d.image.size.h * radius) || 4 * radius
)
.attr(
'width',
d => (d.image && d.image.size && d.image.size.w * radius) || 4 * radius
)
.attr("xlink:href", d => d.image.url);

points
.append('circle')
.attr('cx', d => d.x)
.attr('cy', d => d.y)
.attr('r', radius)
.attr('fill', d => d.img)
.attr('stroke', d => d.colour);
}
Insert cell
Insert cell
function drawMoves(edges) {
function getPath(d) {
// console.log(start);
let path = d3.path();
path.moveTo(d.source.x, d.source.y);
path.lineTo(d.target.x, d.target.y);
return path;
}

const gradient = edges
.append("linearGradient")
.attr("id", d => (d.uid = DOM.uid("link")).id)
.attr("gradientUnits", "userSpaceOnUse")
.attr("x1", d => d.source.x)
.attr("x2", d => d.target.x)
.attr('y1', d => d.source.y)
.attr('y2', d => d.target.y);

gradient
.append("stop")
.attr("offset", "0%")
.attr("stop-color", d => d.source.colour);

gradient
.append("stop")
.attr("offset", "100%")
.attr("stop-color", d => d.target.colour);


edges
.append('path')
.attr('d', d => getPath(d))
.attr('stroke', d => d.uid)
.attr('stroke-width', 6);
}
Insert cell
width
Insert cell
y.step()
Insert cell
y.range()
Insert cell
q = ``
Insert cell
md` # Dull Stuff`
Insert cell
Insert cell
Insert cell
Insert cell
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