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: adjust domain & range for single value histogram #265

Merged
merged 4 commits into from
Jul 17, 2019

Conversation

emmacunningham
Copy link
Contributor

@emmacunningham emmacunningham commented Jul 15, 2019

Summary

fix #262

Previously, a line annotation within a single value histogram's domain range would not appear correctly, rendering the line at the domain start position. For example with a single value histogram with domain 3 to 4, an annotation line at 3.5 would be rendered at 3. This PR adds handling for computing the x scale for a single value histogram such that the line now correctly renders in the right position:

image

The issue was that the annotations rely on the xScale for the x-axis position but with a single value domain, calling xScale.scale would return 0 for all values because the domain and range passed into the scale constructor created a scale that could not compute the right values because the domain would be single value ([3, 3] for our example) and the range would also be single value ([0, 0] in the example here).

To address this, we now do a check in computeXScale such that if the enableHistogramMode flag is true and the domain is a single value domain, we adjust the domain and range values passed into the constructor so that the returned scale's domain and range have been adjusted to account for histogram mode (the domain is extended by the minInterval, which will default to 1 unless the user passes in a custom minInterval for xDomain).

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

@emmacunningham emmacunningham added bug Something isn't working wip work in progress :axis Axis related issue labels Jul 15, 2019
@codecov-io
Copy link

codecov-io commented Jul 15, 2019

Codecov Report

Merging #265 into master will increase coverage by 0.07%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #265      +/-   ##
==========================================
+ Coverage   98.12%   98.19%   +0.07%     
==========================================
  Files          36       37       +1     
  Lines        2662     3319     +657     
  Branches      607      821     +214     
==========================================
+ Hits         2612     3259     +647     
- Misses         45       50       +5     
- Partials        5       10       +5
Impacted Files Coverage Δ
src/state/chart_state.ts 97.95% <ø> (+0.5%) ⬆️
src/state/utils.ts 97.03% <100%> (+0.43%) ⬆️
src/lib/axes/axis_utils.ts 100% <100%> (ø) ⬆️
src/lib/series/scales.ts 100% <100%> (ø) ⬆️
src/state/crosshair_utils.ts 90.8% <0%> (-0.87%) ⬇️
src/lib/series/rendering.ts 98.45% <0%> (-0.83%) ⬇️
src/lib/utils/scales/scale_continuous.ts 93.38% <0%> (-0.73%) ⬇️
src/lib/series/specs.ts 100% <0%> (ø) ⬆️
src/state/annotation_utils.ts 100% <0%> (ø) ⬆️
src/lib/series/series.ts 100% <0%> (ø) ⬆️
... and 11 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 a8f99b1...fbc2463. Read the comment docs.

@emmacunningham emmacunningham removed the wip work in progress label Jul 16, 2019
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.

Code LGTM just added a minor comment. Tested locally.

src/lib/series/scales.ts Show resolved Hide resolved
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.

LGTM!

@emmacunningham emmacunningham merged commit 3f1358e into elastic:master Jul 17, 2019
markov00 pushed a commit that referenced this pull request Jul 17, 2019
## [8.0.2](v8.0.1...v8.0.2) (2019-07-17)

### Bug Fixes

* adjust domain & range for single value histogram ([#265](#265)) ([3f1358e](3f1358e))
@markov00
Copy link
Member

🎉 This PR is included in version 8.0.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@markov00 markov00 added the released Issue released publicly label Jul 17, 2019
AMoo-Miki pushed a commit to AMoo-Miki/OpenSearch-Dashboards that referenced this pull request Feb 10, 2022
## [8.0.2](elastic/elastic-charts@v8.0.1...v8.0.2) (2019-07-17)

### Bug Fixes

* adjust domain & range for single value histogram ([opensearch-project#265](elastic/elastic-charts#265)) ([98c2a9f](elastic/elastic-charts@98c2a9f))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:axis Axis related issue bug Something isn't working released Issue released publicly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Line annotations on single value scale not appearing in correct position in histogram mode
3 participants