Published
Edited
Aug 5, 2021
3 stars
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
data.filter(d => d.Class === 'Mammalia').filter(d => d['Adult weight (g)'] !== '').sort((a,b) => +a['Adult weight (g)'] - +b['Adult weight (g)'])
Insert cell
sortedData = data.filter(d => d['Maximum longevity (yrs)'] !== '').sort((a,b) => +b['Maximum longevity (yrs)'] - +a['Maximum longevity (yrs)'])
Insert cell
Insert cell
data = FileAttachment("anage_data@2.txt").csv();
Insert cell
html`<style>
.notes {
font-size: 12px;
}
svg {
background-color: #fff;
}
svg text {
font-size: 13px;
}
svg .chrt-axis text {
}
svg .labels text {
fill: #fff;
}
svg .mammals-labels text,
svg .with-stroke text {
stroke: #fff;
stroke-width: 2;
paint-order: stroke fill;
}
</style>`
Insert cell
formatWeight = (weight) => {
if (weight < 1000) {
return `${weight} g`;
}
if(weight < 1000 * 1000) {
return `${weight / 1000} kg`;
}
if(weight < 1000 * 1000 * 1000) {
return `${weight / 1000 / 1000} ton`;
}
}
Insert cell
Insert cell
chrt.version
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