ChartsOrg / ChartsOrg/Charts

Y-Axis missing labels when all plotted values are equal

Open
#4,374 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
28k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

✔️ I've read, understood, and done my best to follow the [*CONTRIBUTING guidelines](https://github.com/jjatie/Charts/blob/master/CONTRIBUTING.md).

## What did you do?

I've created a line chart, plotting (say) weight data, averaged by month. This can result in a graph where the average is the same for each month plotted.

The chart has the y-axes configured as follows…

```
rightAxis.setLabelCount(3, force: true)
rightAxis.drawLabelsEnabled = true

leftAxis.drawLabelsEnabled = false
leftAxis.drawGridLinesEnabled = false
leftAxis.spaceBottom = .zero
leftAxis.spaceTop = .zero
```

## What did you expect to happen?

Even when all values are the same I'd expect to see labels on the right axis.
## What happened instead?

When all values are the same, the right axis doesn't show any labels. If I swap the configuration of the axes, the left axis shows labels as expected.

### Right axis (no labels ❌)
![right axis BAD](https://user-images.githubusercontent.com/58423839/82546840-aff55000-9b50-11ea-9db1-88927f5c312f.PNG)

### Left axis (shows labels ✅)
![left axis GOOD](https://user-images.githubusercontent.com/58423839/82546823-a9ff6f00-9b50-11ea-9e57-ea3145f6f0af.PNG)

## Charts Environment

**Charts version/Branch/Commit Number:** 3.4.0
**Xcode version:** 11.4.1
**Swift version:** 5.2
**Platform(s) running Charts:** iOS 13.4.1
**macOS version running Xcode:** 10.15.4

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue in Charts 3.4.0 with a line chart whose plotted values are all equal, using the reported right- and left-axis settings. Start by tracing how axis labels are calculated and rendered for equal ranges; done means the right axis displays labels consistently with the left axis.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.