Public
Edited
Oct 24, 2023
Fork of d3.bisect
2 forks
18 stars
Insert cell
Insert cell
Insert cell
start = 0
Insert cell
stop = 10
Insert cell
count = 100
Insert cell
ticks = d3.ticks(start, stop, count)
Insert cell
visualize(ticks)
Insert cell
Insert cell
d3.ticks(-10, 10, 4)
Insert cell
d3.ticks(0, 10, 3)
Insert cell
d3.ticks(0, 1, 5)
Insert cell
d3.ticks(0, 1000, 20)
Insert cell
Insert cell
Insert cell
ticks_reversed = d3.ticks(8.5, 0.65, 100)
Insert cell
visualize(ticks_reversed)
Insert cell
Insert cell
d3.tickIncrement(0, 10, 10)
Insert cell
d3.tickIncrement(0, 10, 100000)
Insert cell
Insert cell
d3.tickStep(0, 10, 100000)
Insert cell
Insert cell
d3 = require("d3-array@3")
Insert cell
function visualize(ticks) {
return svg`<svg width=${width} height=30 style="font:12px sans-serif; text-anchor:middle">

${ticks.map(
d =>
svg`<line y2=${d == (d | 0) ? 10 : 6} transform="translate(${10 +
(d * (width - 20)) / 10},0)" stroke="black" />`
)}

${ticks
.filter(d => d == (d | 0))
.map(
d =>
svg`<text y=28 transform="translate(${10 +
(d * (width - 20)) / 10},0)" fill="black">${d}</text>`
)}

</svg>`;
}
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