Skip to content

Improve axis ticks deduplication #1417

@nickofthyme

Description

@nickofthyme

Describe the bug
When using tickFormat to round to a given decimal value, the tick placements may be different than the presented label.

To Reproduce
Steps to reproduce the behavior:

  1. Go to any story
  2. Set the tick values to round value to nearest integer.
  3. Disable integersOnly option.
  4. See misleading ticks

Or go to https://codesandbox.io/s/sad-flower-o05ps?file=/src/App.tsx

Expected behaviour
Tick placement is accurate

Screenshots

Image 2021-10-04 at 9 15 46 AM

Notice the left side without a tickFormatter applied, shows the correct value of 2.5 while to right rounds the value to 3 without changing its tick placement.

Version (please complete the following information):

  • Elastic Charts: latest

Additional context
The temporary solution is an iterative reduction of ticks until there are only unique tick labels. This is not perfect but will reduce the number of cases that show bad value. If the labels are identical with two ticks, expand the domain but limit this step to 5 or some value to prevent an Infinite loop.

Kibana Cross Issues
elastic/kibana#97100

Checklist

  • every related Kibana issue is listed under Kibana Cross Issues list
  • kibana cross issue tag is associated to the issue if any kibana cross issue is present

Metadata

Metadata

Assignees

Labels

:LensKibana Lens related issue:axisAxis related issue:xyBar/Line/Area chart relatedImpact:MediumbugSomething isn't workingkibana cross issueHas a Kibana issue counterpart

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions