Public
Edited
Oct 24, 2023
3 stars
Insert cell
Insert cell
d3.mode([1, 2, 2, 2, 3, 3]) // 2
Insert cell
Insert cell
d3.mode(["5", 5, "5", "5", 5, 4, 4, 4, 4]) // 4
Insert cell
Insert cell
d3.mode(["5", 5, "5", "5", 5, 4, 4, 4, 4], Number) // 5
Insert cell
Insert cell
d3.mode(penguins, d => d.island)
Insert cell
Insert cell
{
let args; // the arguments to the last call of the accessor below: datum, index, data
d3.mode(penguins, (d, i, e) => { args = [d, i, e]; return d.species; });
return args;
}
Insert cell
Insert cell
d3.groupSort(penguins, v => v.length, d => d.island).pop()
Insert cell
Insert cell
d3.mode([1, undefined, undefined, NaN, NaN, NaN, null, null]) // 1
Insert cell
Insert cell
d3.groupSort([1, undefined, undefined, NaN, NaN, NaN, null, null], v => v.length, d => d).pop() // NaN
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