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

fix(tickformatter): add timeZone to tickFormatter #430

Merged
merged 3 commits into from
Oct 22, 2019

Conversation

markov00
Copy link
Member

Summary

to correctly handle a the tick formatting on time based series, we need to share the timeZone
parameter to the tickFormatter. When the tickFormatter is an external function, the user can
manually configure that parameter, but for the niceTimeFormatter we don't have that option already.
Instead of adding a breaking change I've added an optional parameter to the tickFormat props to
share the configured timeZone parameter

fix #427

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

to correctly handle a the tick formatting on time based series, we need to share the timeZone
parameter to the tickFormatter. When the tickFormatter is an external function, the user can
manually configure that parameter, but for the niceTimeFormatter we don't have that option already.
Instead of adding a breaking change I've added an optional parameter to the tickFormat props to
share the configured timeZone parameter

fix elastic#427
@codecov-io
Copy link

codecov-io commented Oct 21, 2019

Codecov Report

Merging #430 into master will decrease coverage by 0.08%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #430      +/-   ##
==========================================
- Coverage   97.85%   97.77%   -0.09%     
==========================================
  Files          39       40       +1     
  Lines        2896     2921      +25     
  Branches      701      706       +5     
==========================================
+ Hits         2834     2856      +22     
- Misses         55       58       +3     
  Partials        7        7
Impacted Files Coverage Δ
src/chart_types/xy_chart/utils/specs.ts 100% <ø> (ø) ⬆️
src/chart_types/xy_chart/tooltip/tooltip.ts 93.84% <100%> (+0.09%) ⬆️
src/utils/data/formatters.ts 86.36% <100%> (ø)
src/chart_types/xy_chart/utils/axis_utils.ts 100% <100%> (ø) ⬆️

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 8d43dbc...7cca9e8. Read the comment docs.

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, only a few suggestions.

src/utils/data/formatters.ts Outdated Show resolved Hide resolved
src/chart_types/xy_chart/utils/specs.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@rshen91 rshen91 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 clear to me - Is there a way for a user to break this with bad input? I see that timeZone is of type string for input like 'utc+3'. Doees moment.js just handle bad timezones like timeZone: 'blarg'?

@nickofthyme
Copy link
Collaborator

@rshen91 with the addition of moment, it appears to fail gracefully by falling back to the local/browser time zone.

image

@markov00
Copy link
Member Author

@rshen91 with the addition of moment, it appears to fail gracefully by falling back to the local/browser time zone.

image

@nickofthyme @rshen91 do we want to catch that moment exception and throw just a more "nicer" console.warn ?

@nickofthyme
Copy link
Collaborator

@nickofthyme @rshen91 do we want to catch that moment exception and throw just a more "nicer" console.warn ?

No I don't think that is needed. Wylie pointed out our lack of error catching, which he's right. I think it's a bigger issue to handle all bad inputs to chart "nicely" in both dev and production.

One thing we could add for this is an enum but that would limit the flexibility of kibana to just pass a string. I think moment.tz is resilient enough to handle most edge cases 💪 .

@markov00 markov00 merged commit 6256d4d into elastic:master Oct 22, 2019
@markov00 markov00 deleted the pass-timezone-to-formatters branch October 22, 2019 15:54
markov00 pushed a commit that referenced this pull request Oct 22, 2019
## [13.5.6](v13.5.5...v13.5.6) (2019-10-22)

### Bug Fixes

* **tickformatter:** add timeZone to tickFormatter ([#430](#430)) ([6256d4d](6256d4d)), closes [#427](#427)
@markov00
Copy link
Member Author

🎉 This PR is included in version 13.5.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

@markov00 markov00 added the released Issue released publicly label Oct 22, 2019
AMoo-Miki pushed a commit to AMoo-Miki/OpenSearch-Dashboards that referenced this pull request Feb 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released Issue released publicly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Not passing the timeZone on tickFormat
4 participants