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: expose Specs types and clean up annotation types #554

Merged
merged 4 commits into from
Feb 28, 2020

Conversation

markov00
Copy link
Member

@markov00 markov00 commented Feb 18, 2020

Summary

This PR fix some wrongly configured annotation TS types and expose the Specs types as requested by #547
It also expose some more types that can be used by consumers that where buried inside our chart library.
This commit removes also the getSpecId, getAnnotationId, getGroupId, getAxisId getters in favour of just using a string

BREAKING CHANGE: The getSpecId, getGroupId, getAxisId and getAnnotationId are no more available, you can use directly a string for those ids.

close #547

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

@markov00 markov00 added the wip work in progress label Feb 18, 2020
@codecov-io
Copy link

codecov-io commented Feb 18, 2020

Codecov Report

Merging #554 into master will increase coverage by 0.3%.
The diff coverage is 94.5%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #554     +/-   ##
=========================================
+ Coverage   71.68%   71.98%   +0.3%     
=========================================
  Files         200      212     +12     
  Lines        6032     6186    +154     
  Branches     1167     1185     +18     
=========================================
+ Hits         4324     4453    +129     
- Misses       1690     1714     +24     
- Partials       18       19      +1
Impacted Files Coverage Δ
...t_types/xy_chart/state/selectors/compute_legend.ts 100% <ø> (ø) ⬆️
...art_types/xy_chart/annotations/annotation_utils.ts 100% <ø> (ø) ⬆️
...chart_types/xy_chart/renderer/canvas/axes/index.ts 25% <ø> (ø) ⬆️
src/utils/geometry.ts 100% <ø> (ø) ⬆️
src/specs/settings.tsx 100% <100%> (ø) ⬆️
src/chart_types/xy_chart/rendering/rendering.ts 97.39% <100%> (ø) ⬆️
src/state/selectors/get_legend_items_values.ts 80% <100%> (ø) ⬆️
src/chart_types/xy_chart/state/utils.ts 96.38% <100%> (ø) ⬆️
src/state/selectors/get_legend_items.ts 80% <100%> (ø) ⬆️
src/components/legend/legend.tsx 88.73% <100%> (ø) ⬆️
... and 39 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 4f67ab9...45c1b42. Read the comment docs.

@markov00 markov00 added chore and removed wip work in progress labels Feb 27, 2020
@markov00 markov00 marked this pull request as ready for review February 27, 2020 15:30
@markov00 markov00 force-pushed the 2012_02_18-fix_annotation_types branch from 2c0d538 to fee5e2c Compare February 27, 2020 15:32
@markov00 markov00 changed the title fix: annotation typings feat: expose Specs types and clean up annotation types Feb 27, 2020
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, Does this solve the issue Wylie mentioned about the spec types?

src/index.ts Outdated
export { Chart } from './components/chart';
export { ChartSize, ChartSizeArray, ChartSizeObject } from './utils/chart_size';

// DEPRECATED: we will remove these types soon
export { SpecId, GroupId, AxisId, AnnotationId, getAxisId, getGroupId, getSpecId, getAnnotationId } from './utils/ids';
Copy link
Collaborator

@nickofthyme nickofthyme Feb 27, 2020

Choose a reason for hiding this comment

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

I think you mean remove from export but I saw something in kibana that I started doing in the color picker PR which is for mapped types, and others that make sense, using SeriesId rather than string. It makes no difference to the output or consumer facing types, so we wouldn't need to export them. Something like...

// Good
type SeriesCollection = Map<SeriesId, SeriesIdentifier>;

// Bad
type SeriesCollection = Map<string, SeriesIdentifier>;

Any thoughts on this?

Copy link
Member Author

Choose a reason for hiding this comment

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

You are right, let's keep these

src/index.ts Show resolved Hide resolved
export { DARK_THEME } from './utils/themes/dark_theme';

// utilities
export { RecursivePartial } from './utils/commons';
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe we could have a utils/index for all the utils we want to export.

Copy link
Member Author

Choose a reason for hiding this comment

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

I will address this in a different PR. Currently the Utils directory has more than utilities (also some types, the theme....it's a little mess there, I will try to move things around)

This commit removes the getSpecId, getAnnotationId, getGroupId, getAxisId getters in favour of
directly using a string field

BREAKING CHANGE: The `getSpecId`, `getGroupId`, `getAxisId` and `getAnnotationId` are no more
available, you can use directly a `string` for those ids
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.

Crazy this is finally officially a thing of the past.

@markov00 markov00 merged commit 124c458 into elastic:master Feb 28, 2020
@markov00 markov00 deleted the 2012_02_18-fix_annotation_types branch February 28, 2020 14:15
markov00 added a commit that referenced this pull request Mar 2, 2020
This commit fix some wrongly configured annotation TS types and expose the Specs types as requested by #547. It also expose some more types that can be used by consumers that where buried inside our chart library. Finally it removes the `getSpecId`, `getAnnotationId`, `getGroupId`, `getAxisId` getters in favour of just using a string.

BREAKING CHANGE: The `getSpecId`, `getGroupId`, `getAxisId` and `getAnnotationId` are no longer available. Use a simple `string` instead.

close #547
markov00 pushed a commit that referenced this pull request Mar 17, 2020
# [18.0.0](v17.1.1...v18.0.0) (2020-03-17)

### Code Refactoring

* clean up TS types ([#554](#554)) ([22f7635](22f7635)), closes [#547](#547) [#547](#547)
* decouple tooltip from XY chart ([#553](#553)) ([e70792e](e70792e)), closes [#246](#246)

### Features

* cleaner color API on SeriesSpec ([#571](#571)) ([f769f7c](f769f7c))
* **legend:** allow color picker component render prop ([#545](#545)) ([90f4b95](90f4b95))
* **partition:** add element click, over and out events ([#578](#578)) ([103df02](103df02))
* **partition:** add tooltip ([#544](#544)) ([6bf9a69](6bf9a69)), closes [#246](#246)
* percentage display in partitioning charts ([#558](#558)) ([d6aa8d7](d6aa8d7))
* specify series name with a function on SeriesSpec ([#539](#539)) ([358455a](358455a))
* xAccessor can be a function accessor ([#574](#574)) ([bcc3d63](bcc3d63))

### BREAKING CHANGES

* The `getSpecId`, `getGroupId`, `getAxisId` and `getAnnotationId` are no longer available. Use a simple `string` instead.
* `customSeriesColors` prop on `SeriesSpec` is now `color`. The `CustomSeriesColors` type is  replaced with `SeriesColorAccessor`.
* Remove `customSubSeriesName` prop on series specs in favor of cleaner api using just the `name` prop on `SeriesSpec`. The types `SeriesStringPredicate`, `SubSeriesStringPredicate` have been removed.
* the `SeriesIdentifier` type is generalized into a simplified object with two values in common: `specId` and `key`. A specialized `XYChartSeriesIdentifier` extends now the base `SeriesIdentifier`. The `SettingsSpec` prop `showLegendDisplayValue` is renamed to `showLegendExtra` and its default value is now `false` hiding the current/last value on the legend by default.
AMoo-Miki pushed a commit to AMoo-Miki/OpenSearch-Dashboards that referenced this pull request Feb 10, 2022
# [18.0.0](elastic/elastic-charts@v17.1.1...v18.0.0) (2020-03-17)

### Code Refactoring

* clean up TS types ([opensearch-project#554](elastic/elastic-charts#554)) ([6ce56fa](elastic/elastic-charts@6ce56fa)), closes [opensearch-project#547](elastic/elastic-charts#547) [opensearch-project#547](elastic/elastic-charts#547)
* decouple tooltip from XY chart ([opensearch-project#553](elastic/elastic-charts#553)) ([cb02cd0](elastic/elastic-charts@cb02cd0)), closes [opensearch-project#246](elastic/elastic-charts#246)

### Features

* cleaner color API on SeriesSpec ([opensearch-project#571](elastic/elastic-charts#571)) ([6a78c4e](elastic/elastic-charts@6a78c4e))
* **legend:** allow color picker component render prop ([opensearch-project#545](elastic/elastic-charts#545)) ([22ef1e6](elastic/elastic-charts@22ef1e6))
* **partition:** add element click, over and out events ([opensearch-project#578](elastic/elastic-charts#578)) ([4189573](elastic/elastic-charts@4189573))
* **partition:** add tooltip ([opensearch-project#544](elastic/elastic-charts#544)) ([0cffed4](elastic/elastic-charts@0cffed4)), closes [opensearch-project#246](elastic/elastic-charts#246)
* percentage display in partitioning charts ([opensearch-project#558](elastic/elastic-charts#558)) ([993a448](elastic/elastic-charts@993a448))
* specify series name with a function on SeriesSpec ([opensearch-project#539](elastic/elastic-charts#539)) ([fc6430b](elastic/elastic-charts@fc6430b))
* xAccessor can be a function accessor ([opensearch-project#574](elastic/elastic-charts#574)) ([f702e2c](elastic/elastic-charts@f702e2c))

### BREAKING CHANGES

* The `getSpecId`, `getGroupId`, `getAxisId` and `getAnnotationId` are no longer available. Use a simple `string` instead.
* `customSeriesColors` prop on `SeriesSpec` is now `color`. The `CustomSeriesColors` type is  replaced with `SeriesColorAccessor`.
* Remove `customSubSeriesName` prop on series specs in favor of cleaner api using just the `name` prop on `SeriesSpec`. The types `SeriesStringPredicate`, `SubSeriesStringPredicate` have been removed.
* the `SeriesIdentifier` type is generalized into a simplified object with two values in common: `specId` and `key`. A specialized `XYChartSeriesIdentifier` extends now the base `SeriesIdentifier`. The `SettingsSpec` prop `showLegendDisplayValue` is renamed to `showLegendExtra` and its default value is now `false` hiding the current/last value on the legend by default.
nickofthyme added a commit to nickofthyme/kibana that referenced this pull request Mar 28, 2024
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.

Export Typescript definition for what a Spec is
3 participants