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

chore: tighter partition types #560

Merged
merged 8 commits into from
Mar 2, 2020

Conversation

monfera
Copy link
Contributor

@monfera monfera commented Feb 20, 2020

Summary

Tightens up partitioning chart types, as several was, in effect, any. See point 3 in #518 (comment)

It's a breaking change as it may need that client libraries update types, even though there's no runtime change.

BREAKING CHANGES:
The valueFormatter prop function now receive only a number instead of any.
In the layers props:

  • the nodeLabel is now typed as (d: PrimitiveValue) => String(d), where PrimitiveValue is string | number | null.
  • the fillColor of a shape has a tighter type: (d: ShapeTreeNode, index: number, array: HierarchyOfArrays) => string;

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

  • Any consumer-facing exports were added to src/index.ts (and stories only import from ../src except for test data & storybook)
  • This was checked for cross-browser compatibility, including a check against IE11
  • 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
  • Each commit follows the convention

@monfera monfera added the chore label Feb 20, 2020
@monfera monfera requested a review from markov00 February 20, 2020 11:45
@monfera monfera self-assigned this Feb 20, 2020
@codecov-io
Copy link

codecov-io commented Feb 20, 2020

Codecov Report

Merging #560 into master will increase coverage by 0.19%.
The diff coverage is 64.7%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #560      +/-   ##
==========================================
+ Coverage   71.83%   72.02%   +0.19%     
==========================================
  Files         201      212      +11     
  Lines        6042     6187     +145     
  Branches     1170     1188      +18     
==========================================
+ Hits         4340     4456     +116     
- Misses       1684     1712      +28     
- Partials       18       19       +1
Impacted Files Coverage Δ
src/mocks/series/series.ts 81.66% <ø> (ø)
src/chart_types/xy_chart/utils/specs.ts 100% <ø> (ø) ⬆️
src/mocks/specs/specs.ts 76.19% <ø> (ø)
src/mocks/series/series_identifiers.ts 94.11% <ø> (ø)
src/index.ts 100% <100%> (ø) ⬆️
src/chart_types/xy_chart/domains/y_domain.ts 99.07% <100%> (-0.01%) ⬇️
src/chart_types/specs.ts 100% <100%> (ø) ⬆️
src/chart_types/xy_chart/specs/line_annotation.tsx 42.85% <14.28%> (-4.52%) ⬇️
... and 10 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 9abbc25...e58c787. Read the comment docs.

@markov00 markov00 force-pushed the tighter-partition-types branch from f9f2b99 to 8c32e44 Compare February 27, 2020 17:17
Copy link
Collaborator

@nickofthyme nickofthyme left a comment

Choose a reason for hiding this comment

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

LGTM, Are we going to do the ValueAccessor changes we discussed another time?

like allowing an object with fieldName.

Comment on lines 669 to 689
expect(datum!.y1).toBe(1);
expect(datum!.y0).toBe(2);
datum = cleanDatum([0, '1', 2], 0, 1, 2);
expect(datum.y1).toBe(1);
expect(datum.y0).toBe(2);
expect(datum).toBeDefined();
expect(datum!.y1).toBe(1);
expect(datum!.y0).toBe(2);

datum = cleanDatum([0, '1', '2'], 0, 1, 2);
expect(datum.y1).toBe(1);
expect(datum.y0).toBe(2);
expect(datum).toBeDefined();
expect(datum!.y1).toBe(1);
expect(datum!.y0).toBe(2);

datum = cleanDatum([0, 1, '2'], 0, 1, 2);
expect(datum.y1).toBe(1);
expect(datum.y0).toBe(2);
expect(datum).toBeDefined();
expect(datum!.y1).toBe(1);
expect(datum!.y0).toBe(2);

datum = cleanDatum([0, 'invalid', 'invalid'], 0, 1, 2);
expect(datum.y1).toBe(null);
expect(datum.y0).toBe(null);
expect(datum).toBeDefined();
expect(datum!.y1).toBe(null);
expect(datum!.y0).toBe(null);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Using a ? would be the same here. I don't like !

expect(datum?.y1).toBe(1);

Copy link
Member

Choose a reason for hiding this comment

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

Sure, let me change that

Copy link
Member

Choose a reason for hiding this comment

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

done here e58c787

@markov00 markov00 requested a review from nickofthyme February 28, 2020 15:08
@markov00 markov00 merged commit d670350 into elastic:master Mar 2, 2020
markov00 added a commit that referenced this pull request Mar 2, 2020
Tightens up partitioning chart types.

BREAKING CHANGES: The `valueFormatter` prop function now receive only a `number` instead of `any`.
In the layers props the `nodeLabel` is now typed as `(d: PrimitiveValue) => String(d)` where `PrimitiveValue` is `string | number | null`.
The `fillColor` of a `shape` has a tighter type: `(d: ShapeTreeNode, index: number, array: HierarchyOfArrays) => string`

Co-authored-by: Marco Vettorello <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants