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

feat(*): added scale radial #958

Merged
merged 1 commit into from
Dec 9, 2020

Conversation

sarathps93
Copy link
Contributor

@sarathps93 sarathps93 commented Dec 4, 2020

🚀 Enhancements

@sarathps93
Copy link
Contributor Author

Had to update the version of d3-scale and it's types package to get the scaleRadial and type from it

@sarathps93 sarathps93 force-pushed the feature/scale-radial branch 4 times, most recently from fde0109 to 7de8acc Compare December 4, 2020 18:23
@@ -11,6 +11,6 @@ export default function applyUnknown<
config: ScaleConfigWithoutType<Output, DiscreteInput, ThresholdInput>,
) {
if ('unknown' in scale && 'unknown' in config && typeof config.unknown !== 'undefined') {
scale.unknown(config.unknown);
(scale.unknown as any)(config.unknown);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The latest type definitions for d3-scales are causing issues at here and that's why I have including the type casting in here

Copy link
Collaborator

Choose a reason for hiding this comment

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

Would you mind sharing the specific issue?
Just want to help think if there is a workaround that is more type-safe than casting to any.

Copy link
Contributor Author

@sarathps93 sarathps93 Dec 4, 2020

Choose a reason for hiding this comment

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

 /**
     * Returns the current unknown value, which defaults to undefined.
     */
    unknown(): UnknownReturnType<Unknown, undefined>;
    /**
     * Sets the output value of the scale for undefined (or NaN) input values and returns this scale.
     *
     * @param value The output value of the scale for undefined (or NaN) input values.
     */
    unknown<NewUnknown>(value: NewUnknown): ScaleLinear<Range, Output, NewUnknown>;

Above is the latest type definition from @types/d3-scale. Somehow the scale.unknown is pointing to the function which accepts no arguments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kristw Please let me if any other workaround can be done to avoid this.

Copy link
Collaborator

@williaster williaster Dec 7, 2020

Choose a reason for hiding this comment

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

It looks like TS isn't correctly matching the second overload. is there any way to import NewUnknown and coerce to that?

scale.unknown(config.unknown as NewUnknown)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@williaster I have tried that option as well. They are not exposing the NewUnknown for us to import

Copy link
Collaborator

Choose a reason for hiding this comment

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

@kristw any other thoughts? else we can probably merge this as is

@coveralls
Copy link

coveralls commented Dec 4, 2020

Pull Request Test Coverage Report for Build 401423712

  • 3 of 3 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.01%) to 61.522%

Totals Coverage Status
Change from base Build 401376407: 0.01%
Covered Lines: 1720
Relevant Lines: 2633

💛 - Coveralls

Copy link
Collaborator

@williaster williaster left a comment

Choose a reason for hiding this comment

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

This looks great to me with one minor comment on the RadialScaleConfig.

Also cc-ing @kristw in case he notices anything else since he's very familiar with the scale package.

'radial',
ContinuousDomain,
Output[],
'clamp' | 'nice' | 'round' | 'zero' | 'unknown'
Copy link
Collaborator

Choose a reason for hiding this comment

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

should zero be omitted here since it's not applied in scales/radial.ts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah makes sense. Have done the changes

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1

Copy link
Collaborator

@williaster williaster left a comment

Choose a reason for hiding this comment

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

Spoke with @kristw offline, let's merge this! Thanks again for the contribution 🙏

@williaster williaster added this to the 1.3.0 milestone Dec 9, 2020
@williaster williaster merged commit 1657342 into airbnb:master Dec 9, 2020
@coveralls
Copy link

coveralls commented Nov 24, 2024

Pull Request Test Coverage Report for Build 401423712

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 3 of 3 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.01%) to 61.522%

Totals Coverage Status
Change from base Build 401376407: 0.01%
Covered Lines: 1720
Relevant Lines: 2633

💛 - Coveralls

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.

4 participants