-
Notifications
You must be signed in to change notification settings - Fork 187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
extend interval to dot and text marks #627
Conversation
Thanks for incorporating my suggested changes. I’d love to have a better motivating example of how this should be used. In the case of plotting athletes by birthday month, I think I would probably recommend this instead: Plot.plot({
marginLeft: 60,
y: {
reverse: true
},
marks: [
Plot.rectX(athletes, Plot.binY({x: "count"}, {y: d => d.date_of_birth, thresholds: d3.utcMonth})),
Plot.text(athletes, Plot.binY({x: "count", text: "count"}, {y: d => d.date_of_birth, thresholds: d3.utcMonth, dx: 4, textAnchor: "start"})),
Plot.ruleX([0])
]
}) Alternatively, if I wanted an ordinal y-scale using the group transform: Plot.plot({
y: {
tickFormat: Plot.formatMonth()
},
marks: [
Plot.barX(athletes, Plot.groupY({x: "count"}, {y: d => d.date_of_birth.getUTCMonth()})),
Plot.text(athletes, Plot.groupY({x: "count", text: "count"}, {y: d => d.date_of_birth.getUTCMonth(), dx: 4, textAnchor: "start"})),
Plot.ruleX([0])
]
}) I can reduce your example to this, which produces identical output to the first: Plot.plot({
marginLeft: 60,
y: {
reverse: true
},
marks: [
Plot.rectX(athletes, Plot.groupY({x: "count"}, {y: d => d3.utcMonth.floor(d.date_of_birth), interval: d3.utcMonth})),
Plot.textX(athletes, Plot.groupY({x: "count", text: "count"}, {y: d => d3.utcMonth.floor(d.date_of_birth), interval: d3.utcMonth, dx: 4, textAnchor: "start"}))
]
}) But, it still seems more complicated since you need to apply the month interval twice, whereas with the bin transform, you only need to specify it once, and the bin transform already computes the midpoint. Though… I guess that alone is a reason for the interval transform to do the same, for symmetry. |
Also, and apologies for not realizing this sooner, we should find a way to reuse the existing Lines 277 to 292 in 72b2adb
|
This came up again here: https://talk.observablehq.com/t/text-marks-for-the-sum-of-last-n-days-when-using-plot-windowy/6627/2 |
8462f14
to
b1b2d67
Compare
closes #611
(not related to #597 which requires a very different kind of interval)