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

refactor: remove default small multiples value #977

Merged
merged 14 commits into from
Jan 19, 2021

Conversation

nickofthyme
Copy link
Collaborator

@nickofthyme nickofthyme commented Jan 14, 2021

Summary

Currently, the only way to determine if the value of the small multiple exists is to compare it to the DEFAULT_SINGLE_PANEL_SM_VALUE string which is not exported from the library. This pr removes this default value in place of null.

Checklist

  • Any consumer-facing exports were added to src/index.ts (and stories only import from ../src except for test data & storybook)
  • Proper documentation or storybook story was added for features that require explanation or tutorials
  • Unit tests were updated or added to match the most common scenarios

@nickofthyme nickofthyme added the API Changes the external API types label Jan 14, 2021
@nickofthyme nickofthyme requested a review from markov00 January 14, 2021 18:25
@codecov-io
Copy link

codecov-io commented Jan 14, 2021

Codecov Report

Merging #977 (07ed367) into master (6c4dafd) will increase coverage by 0.07%.
The diff coverage is 69.23%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #977      +/-   ##
==========================================
+ Coverage   70.87%   70.95%   +0.07%     
==========================================
  Files         344      360      +16     
  Lines       10971    10597     -374     
  Branches     2309     2168     -141     
==========================================
- Hits         7776     7519     -257     
+ Misses       3181     2989     -192     
- Partials       14       89      +75     
Flag Coverage Δ
unittests ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
..._types/xy_chart/state/selectors/get_cursor_band.ts 90.00% <ø> (-3.03%) ⬇️
...s/xy_chart/state/selectors/get_tooltip_position.ts 75.00% <0.00%> (ø)
src/mocks/series/series_identifiers.ts 100.00% <ø> (ø)
src/specs/small_multiples.ts 100.00% <ø> (ø)
src/chart_types/xy_chart/utils/series.ts 93.08% <60.00%> (-3.10%) ⬇️
...t/state/selectors/compute_small_multiple_scales.ts 86.95% <100.00%> (-8.70%) ⬇️
...chart_types/xy_chart/utils/indexed_geometry_map.ts 94.44% <100.00%> (-0.30%) ⬇️
src/state/selectors/get_legend_items_labels.ts 50.00% <0.00%> (-50.00%) ⬇️
src/utils/dimensions.ts 71.42% <0.00%> (-28.58%) ⬇️
src/components/no_results.tsx 50.00% <0.00%> (-25.00%) ⬇️
... and 207 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6c4dafd...07ed367. Read the comment docs.

@markov00
Copy link
Member

I see this as a simplified version of the real solution.
What if we can define these values as optional? I know that this will require much more work, but it looks much cleaner than checking if the value is equal to a brutal string we are using, what do you think @nickofthyme ?

@nickofthyme
Copy link
Collaborator Author

Yeah I think that could be nicer. You are saying like set the value to undefined or null?

@nickofthyme nickofthyme changed the title chore: export default sm type to know if sm is used refactor: replace default small multiples value with null Jan 14, 2021
@nickofthyme nickofthyme added the :small multiples Small multiples/trellising related issues label Jan 14, 2021
@nickofthyme
Copy link
Collaborator Author

@markov00 Let me know what you think about these changes

@@ -68,6 +64,6 @@ export const computeSmallMultipleScalesSelector = createCachedSelector(

function getScale(domain: Domain, maxRange: number, padding = DEFAULT_SM_PANEL_PADDING) {
const singlePanelSmallMultiple = domain.length <= 1;
const defaultDomain = domain.length === 0 ? [DEFAULT_SINGLE_PANEL_SM_VALUE] : domain;
const defaultDomain = domain.length === 0 ? [null] : domain;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@markov00 I'm not sure of the implications of doing this. It seems to work fine.

I thought of just returning a null but that would require a lot of type guards elsewhere.

Copy link
Member

Choose a reason for hiding this comment

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

In the series identifier the smHorizontalAccessorValue is already an optional param, can we just use undefined instead of null?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Member

@markov00 markov00 left a comment

Choose a reason for hiding this comment

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

All looks good, thanks for taking the time for that change.

src/chart_types/xy_chart/utils/series.ts Outdated Show resolved Hide resolved
@nickofthyme nickofthyme removed the API Changes the external API types label Jan 19, 2021
@nickofthyme nickofthyme changed the title refactor: replace default small multiples value with null refactor: remove default small multiples value Jan 19, 2021
@nickofthyme nickofthyme merged commit f06a57a into elastic:master Jan 19, 2021
@nickofthyme nickofthyme deleted the export-sm-type branch January 19, 2021 21:02
@markov00
Copy link
Member

🎉 This PR is included in version 24.5.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@markov00 markov00 added the released Issue released publicly label Jan 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore released Issue released publicly :small multiples Small multiples/trellising related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants