Public
Edited
Dec 8, 2023
1 fork
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
counter
Insert cell
Insert cell
Insert cell
function animatePathSequentially(links, duration, delayBetween) {
// Animate each link one after the other
links.each(function(d, i) {
d3.select(this)
.attr("stroke-dasharray", function() {
const length = this.getTotalLength();
return `${length} ${length}`;
})
.attr("stroke-dashoffset", function() {
return this.getTotalLength();
})
.transition()
.delay(i * (duration + delayBetween)) // Calculate delay based on index
.duration(duration)
.ease(d3.easeLinear)
// Adding an easing function for a smoother transition
.attr("stroke-dashoffset", 0)
.end()
.catch((error) => {
console.error("Animation failed to execute:", error);
});
});
}

Insert cell
test = FileAttachment("test.svg").image()
Insert cell
Insert cell
treePaths
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
pathForInstance = extractPathFromTable(instanceId, treePaths);
Insert cell
allPathElementsFound = path(d3.hierarchy(currentTreeData), pathForInstance)
Insert cell
Insert cell
Insert cell
pathForInstance[pathForInstance.length - 1]
Insert cell
nodes = d3.hierarchy(currentTreeData).descendants();
Insert cell
Insert cell
Insert cell
Insert cell
function startAnimationSequence(linksArray) {
const totalLinks = linksArray.length;

const animateNextLink = (index) => {
const linkData = linksArray[index];
animateLink(linkData, index, totalLinks, animateNextLink);
};

animateNextLink(0); // Start from the first link
}


Insert cell
Insert cell
function initializePathCount(node) {
if (!node.data.pathCount) {
node.data.pathCount = 0; // Initialize pathCount if it doesn't exist
}
if (node.children) {
node.children.forEach(initializePathCount);
}
}
Insert cell
train_df.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
test_1 = FileAttachment("test_1.json").json()
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