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(domain): set domain bounds dependent on negative/positive values #149

Merged
merged 1 commit into from
Apr 5, 2019

Conversation

emmacunningham
Copy link
Contributor

@emmacunningham emmacunningham commented Apr 5, 2019

Summary

close #135

This PR addresses the issues with the previous scaleToExtent logic assuming a domain with only positive values. Now, when scaleToExtent is false, we return a domain dependent on whether the domain has positive or negative values. Previously, a chart with only negative values would only see the values rendering if scaleToExtent was true; now even when scaleToExtent is false, the negative values will render. For mixed negative & positive values, we return the original domain.

scale_to_extent

Checklist

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

  • 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

@codecov-io
Copy link

Codecov Report

Merging #149 into master will increase coverage by 0.03%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #149      +/-   ##
==========================================
+ Coverage   94.03%   94.06%   +0.03%     
==========================================
  Files          34       34              
  Lines        1744     1753       +9     
  Branches      219      223       +4     
==========================================
+ Hits         1640     1649       +9     
  Misses         90       90              
  Partials       14       14
Impacted Files Coverage Δ
src/lib/utils/domain.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 77a352c...8021d33. Read the comment docs.

}

// if any of the values are null
return [0, 0];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

d3.extent() has the type signature [number, number] | [undefined, undefined], so there's a possibility that the computed range start and end could be undefined, though consumers of this function appear to operate under the assumption that this is always [number, number].

This seems like a case where if any value within the computed extent is undefined, we should handle it as an error and surface it to the user somehow (see #117). The other option is that we coerce the undefineds:

[ -start, undefined ] => [ -start, 0 ]
[ +start, undefined ] => [ 0, start ] ?
[ undefined, -end ] => [ end, 0 ] ?
[ undefined, +end ] => [ 0, end ]
[ undefined, undefined ] => [0, 0]

Copy link
Member

Choose a reason for hiding this comment

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

I agree

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!

@emmacunningham emmacunningham merged commit 5b16be6 into elastic:master Apr 5, 2019
markov00 pushed a commit that referenced this pull request Apr 5, 2019
## [3.7.1](v3.7.0...v3.7.1) (2019-04-05)

### Bug Fixes

* **domain:** set domain bounds dependent on negative/positive values ([#149](#149)) ([5b16be6](5b16be6))
@markov00
Copy link
Member

markov00 commented Apr 5, 2019

🎉 This PR is included in version 3.7.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@markov00 markov00 added the released Issue released publicly label Apr 5, 2019
@markov00 markov00 mentioned this pull request Apr 5, 2019
93 tasks
AMoo-Miki pushed a commit to AMoo-Miki/OpenSearch-Dashboards that referenced this pull request Feb 10, 2022
## [3.7.1](elastic/elastic-charts@v3.7.0...v3.7.1) (2019-04-05)

### Bug Fixes

* **domain:** set domain bounds dependent on negative/positive values ([opensearch-project#149](elastic/elastic-charts#149)) ([1e9d96d](elastic/elastic-charts@1e9d96d))
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.

The chart do not render negative values
3 participants