-
Notifications
You must be signed in to change notification settings - Fork 120
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
refactor(axes): replace integersOnly
with maximumFractionDigits
#2305
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nickofthyme
added
enhancement
New feature or request
kibana cross issue
Has a Kibana issue counterpart
:axis
Axis related issue
:xy
Bar/Line/Area chart related
:Lens
Kibana Lens related issue
labels
Jan 17, 2024
nickofthyme
added
ci:skip
Skip all build checks
and removed
ci:skip
Skip all build checks
labels
Jan 23, 2024
buildkite update screenshots |
markov00
reviewed
Jan 24, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
markov00
approved these changes
Jan 26, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's merge this and fix the other issue in a subsequent PR, thanks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
:axis
Axis related issue
enhancement
New feature or request
kibana cross issue
Has a Kibana issue counterpart
:Lens
Kibana Lens related issue
:xy
Bar/Line/Area chart related
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Adds a way to round axes tick values prior to formatting the numerical values into a string.
Axis.integersOnly
prop is now deprecated and replace withmaximumFractionDigits
Usages
Below shows, toggling
maximumFractionDigits
between0
(integers only) and1
(single decimal or tenths only)Below shows, toggling
maximumFractionDigits
between0
(integers only),1
(single decimal or tenths only) and2
(double decimal or hundredths only)Details
The original logic to add the
integersOnly
only allowed rounding of the numerical tick value in the case of an integer. This PR expands on that by allowing the chart consumer to set the max number of fractional digits (aka decimals) in a numerical value. This is different than formatting in order to show a value to a max fractional digits, as this can render deceptive ticks and their respective placements, see linked issue.Drawbacks
This is not an active assignment of ticks given the rounded constraint but rather a passive removal of ticks that do not abide by the constraint. Currently
d3-scale
does not support asking for ticks in this manner. Thus there are drawbacks to this approach, namely those listed below:maximumFractionDigits
value with result in one or both of the end ticks being removed. See the second gif above as an example of this.maximumFractionDigits
to1
and out data domain is between0
and1
. Then let's say we desire~10
ticks, that would be a tick every0.1
unit. Here we would keep all the ticks as it would maintain all0.X
values. But what if we specify~4
ticks, d3 would likely give us ticks at every0.25
unit, in this case all ticks but the0
and1
would be removed as then are0.XX
not0.X
. I don't see a way to fix this without iterating a few times, or with custom tick logic.Issues
Closes #2220
Checklist
:xy
,:partition
):interactions
,:axis
)closes #123
,fixes #123
)packages/charts/src/index.ts
light
anddark
themes