-
Notifications
You must be signed in to change notification settings - Fork 176
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
interval for rect #550
interval for rect #550
Conversation
I guess this should probably set default insets, too, like e.g. bin does? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we expose this in some way, so that custom marks could have access to this new transform?
I'm sending a few suggestions in another PR
|
||
function maybeInset(inset, inset1, inset2) { | ||
return inset === undefined && inset1 === undefined && inset2 === undefined | ||
? (offset ? [1, 0] : [0.5, 0.5]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(This is not new) The default inset makes the marks vanish if they are too narrow. For example in aapl-volume-rect, if you take the whole dataset instead of just a slice, the resulting chart is blank.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refs. #422 and d3/d3-scale#243
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m aware of this problem but not going to fix it here. 👍
I don’t think we should expose the interval (or inset) transform yet, out of conservatism, but we can always chose to do so in the future if we think it’s useful. |
I think I want to add the interval transform to bar and rule, too. |
56d3da8
to
cb26d3f
Compare
Added. Works nicely! |
Adds an interval option for rects which transforms x to x1 and x2 using interval.floor and interval.offset. This provides a suitable replacement for bars when an axis is temporal rather than ordinal. Related #513, and perhaps this could be considered a fix.
I’d further love to be able to specify a named interval such as “day” or “hour”, but this requires knowing the time zone (or for now, whether the associated scale is “utc” or local “time”). That’s not easily accessible when evaluating a transform since this happens before scales are constructed. Although I suspect that with a top-level timeZone option #531 we could find some way of passing this down to the transform. At any rate, convenience shorthand can be added in the future.