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

add tickComponent prop and use @vx/text for axis ticks #260

Merged
merged 1 commit into from
Mar 29, 2018

Conversation

sto3psl
Copy link
Contributor

@sto3psl sto3psl commented Mar 28, 2018

💥 Breaking Changes

None 🎉

🚀 Enhancements

Implements features mentioned in #259

  • use @vx/text for axis ticks and axis label
  • add tickComponent prop to all axis components

📝 Documentation

  1. By default <Axis /> components now use @vx/text to render tick labels. This enables multi line labels and scaling text to fit in a certain amount of space.

Example:

<Axis 
  {...axisProps}
  tickLabelProps = (tickValue, index) => ({
    textAnchor: 'middle',
    verticalAnchor: 'middle',
    width: 100,
    scaleToFit: true
  })
/>
  1. <Axis /> components got a new prop tickComponent to enable rendering of custom ticks. With this prop one can completely customize ticks without having to create a new custom <Axis /> component.

Example:

<Axis
  {...axisProps}
  tickComponent={({ x, y, formattedValue }) => (
    <g>
      <circle cx={x} cy={y} r={2} fill='rebeccapurple' />
      <text x={x + 4} y={y}>{formattedValue}</text>
    </g>
  )}
/>

tickComponent accepts a function and gets called with the following attribute:

tickComponent({ x, y, formattedValue, ...tickLabelPropsObj })

P.S.: I think currently it's quite hard to get started developing on vx. I don't really know how lerna works and if I maybe did something wrong, please let me know. A little Getting started developing vx section in the readme would be lovely.

@williaster
Copy link
Collaborator

this will be a great addition @sto3psl! 🚀

and good suggestion about the dev environment instructions, I just added a section to the readme about this.

@techniq
Copy link
Collaborator

techniq commented Mar 28, 2018 via email

@sto3psl
Copy link
Contributor Author

sto3psl commented Mar 29, 2018

Great I did almost everything correctly forking vx and getting started 😄. Thank you @williaster for the quick addition!

@hshoff
Copy link
Member

hshoff commented Mar 29, 2018

LGTM thanks for the contribution @sto3psl!

@hshoff hshoff added this to the v0.0.159 milestone Mar 29, 2018
@hshoff hshoff merged commit 48c34f9 into airbnb:master Mar 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants