Skip to content

support dx, dy on all marks #488

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

Merged
merged 2 commits into from
Sep 7, 2021
Merged

support dx, dy on all marks #488

merged 2 commits into from
Sep 7, 2021

Conversation

Fil
Copy link
Contributor

@Fil Fil commented Aug 7, 2021

On all marks except text, dx, dy are rendered as a transform(translate) or (x,y) property, possibly with the 0.5px offset on high-density screens. On text marks, the dx and dy properties are used.

closes #379

build : https://observablehq.com/@fil/plot-dx-dy-488 ; also available in https://observablehq.com/@fil/plot-early-bird

@Fil Fil requested a review from mbostock August 7, 2021 12:49
@mbostock
Copy link
Member

mbostock commented Aug 7, 2021

What’s the use case? Feels a bit niche.

@Fil
Copy link
Contributor Author

Fil commented Aug 7, 2021

I often find I want to translate a mark by a few pixels, and bummed that only Plot.text offers this feature. This would be convenient to add a rule at the side of a bar, make shades, annotations / overlays (manual legends), separation lines between categories, etc.

return create("svg:g")
.call(applyIndirectStyles, this)
.call(applyTransform, null, Y && y, 0, 0.5)
.call(applyTransform, null, Y && y, dx, offset + dy)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe in cases like this it would be preferable to initialize {dx = 0, dy = offset}, rather than adding offset to dy?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's a separate concern. If you want a shape to be 1px to the left of another, they should both be moved by .5px if that helps make them sharper.

@mbostock mbostock added the question Further information is needed label Aug 11, 2021
@ryoqun
Copy link

ryoqun commented Aug 12, 2021

oh, cool. I want this also very. :). to tell the truth, I'm hacking my example by using strokeDasharray: ["0", "0", "5", "100"] to get similar outcome of slight shifting of tickX. you may notice that if you look at this closely:

image

if this becomes a channel like the new behavior of storokeWidth, it would be really cool as well.

@Fil
Copy link
Contributor Author

Fil commented Aug 12, 2021

if this becomes a channel like the new behavior of strokeWidth, it would be really cool as well.

Ref.: #174

@ryoqun
Copy link

ryoqun commented Aug 18, 2021

#322 (comment):

wow! great example, I'd be curious to see it in action if you can share it! If you want to test this branch I've updated the build at https://observablehq.com/@fil/plot-strokewidth-322 (see also https://observablehq.com/@fil/plot-early-bird)

@Fil hi, I've finally made my plot application public. (not on observablehq.com because i wanted full screen..)

still, buggy, slow and ugly code. :)

I think you can click around even if you don't understand: https://codepen.io/ryoqun/full/JjNbeyE

fyi, we're using it like this: solana-labs/solana#18308 (comment)

lastly, so, I want to plot multiple circles or rects per y/z with dx/dy shift if possible. :)

@ryoqun
Copy link

ryoqun commented Aug 31, 2021

(I'm happy to see a progress on this. thanks for working!)

On all marks except text, dx and dy are rendered as a transform
(translate) property, possibly with the 0.5px offset on high-density
screens. On text marks, the dx and dy properties are used.
Copy link
Member

@mbostock mbostock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! 👍

@mbostock mbostock merged commit 07cf90b into main Sep 7, 2021
@mbostock mbostock deleted the fil/dx-dy branch September 7, 2021 02:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support dx, dy on all marks?
3 participants