Skip to content
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

Axis tick text transforms #149

Closed
sa-mm opened this issue Sep 14, 2017 · 5 comments
Closed

Axis tick text transforms #149

sa-mm opened this issue Sep 14, 2017 · 5 comments

Comments

@sa-mm
Copy link

sa-mm commented Sep 14, 2017

Are we able to perform transforms on the axis tick text? Also, is this the best spot for these sorts of questions or should I take it to stack overflow?

@sa-mm sa-mm changed the title Axis label transforms Axis tick text transforms Sep 14, 2017
@sa-mm
Copy link
Author

sa-mm commented Sep 14, 2017

After looking at this example, I put something together:

            tickLabelProps={(value, index) => {
              return {
                transform: 'rotate(90 ' + xScale(value) + ',0)',
              }
            }}

I thought that with d3, you only had to pass in .attr("transform", "rotate(90)"), so this was a little different.

Is there a better way to accomplish this?

@hshoff
Copy link
Member

hshoff commented Sep 14, 2017

You could also write it like so:

transform: `rotate(90 ${xScale(value) 0})`,

but yes that's the best way for now.

To match d3 behavior we'll need to move the x/y position of the tick labels to a translate transform on the <g> surrounding the tick line and the tick label. Then it will rotate around the correct point without having to pass the optional x,y args to rotate()

@hshoff
Copy link
Member

hshoff commented Sep 14, 2017

@williaster any thoughts here?

@williaster
Copy link
Collaborator

sorry for the delay, was on vacation 🌴 last week.

I agree that having to specify the x,y args to rotate() isn't ideal. I think the solution you proposed to move the x,y position from the tick label <line> +<text> elements to their parent <g> should work well, and then you can simplify the textLabelProps logic a bit. Will require a bit of refactoring but shouldn't be too difficult 👍.

@hshoff
Copy link
Member

hshoff commented Oct 5, 2017

closing in favor of #165

@hshoff hshoff closed this as completed Oct 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants