Skip to content

for placing text on interval rect bars, is there an easy option to align text center to center of the bar? e.g. offset to half width of the interval rect bar? #611

Answered by Fil
tx0c asked this question in Q&A
Discussion options

You must be logged in to vote

Plot.textY doesn't have the interval transform (#597), but you might want to do one of:

add 14 days:

x: d => +d3.utcMonth.floor(d["date_of_birth"]) + 14 * 24 * 3600 * 1000

compute the middle of the month:

x: d => (+d3.utcMonth.floor(d["date_of_birth"]) + +d3.utcMonth.ceil(1 + +d["date_of_birth"])) / 2

see https://observablehq.com/@fil/plot-center-text-on-an-interval

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by tx0c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants