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

typescript(vx-axis): re-write package in TypeScript #569

Merged
merged 13 commits into from
Dec 30, 2019
Merged

Conversation

williaster
Copy link
Collaborator

@williaster williaster commented Dec 29, 2019

🚀 Enhancements

This PR builds off #488 which introduces Typescript build config, and re-writes the @vx/axis package in TypeScript, closing #564.

The trickiest part of this (like @vx/legend) is supporting all d3 scale types. In #551 I tried using a union of actual d3-scale types, but as noted there this is challenging because the domain/range generics for different scales have different levels of strictness. So In this PR I tried writing a GenericScale<ScaleInput> type, where ScaleOutput must be coercible to a number (for plotting on an axis) and wrote tests to ensure it's compatible with each type of scale exported from @vx/scale.

Tests

  • CI
    • wrote a new set of tests for compatibility with each type of scale exported from @vx/scale
  • functional via /axis demos
  • generates .d.ts files

cc @hshoff @schillerk @kristw @Rudeg


const horizontal = orientation !== ORIENT.left && orientation !== ORIENT.right;
const isLeft = orientation === ORIENT.left;
const isTop = orientation === ORIENT.top;
const tickSign = isLeft || isTop ? -1 : 1;

const position = (scale.bandwidth ? center : identity)(scale.copy());
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

center handles scales without a bandwidth method

@williaster williaster merged commit 6c9d42c into master Dec 30, 2019
@williaster williaster deleted the chris--ts-axis branch December 30, 2019 01:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant