ChartsOrg / ChartsOrg/Charts

setVisibleXRange conflicts with granularity

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

Description

I have a dynamic chart and during setup I do:

```
lineChartView.xAxis.granularityEnabled = true
lineChartView.xAxis.granularity = 25
lineChartView.xAxis.forceLabelsEnabled = true
lineChartView.xAxis.labelCount = 20
```

when checking my xAxis label formatter for values, I get the expected 0, 25, 75, 100 etc

When I set my xRange though to:

`lineChartView.setVisibleXRange(minXRange: 25, maxXRange: 500)`

the xAxis label values are incremented by 30

```
0.0
30.0
60.0
90.0
120.0
150.0
180.0
210.0
240.0
270.0
300.0
330.0
360.0
390.0
420.0
450.0
480.0
510.0
540.0
```

EDIT: just a note that as soon as I zoom in a tiny bit, the scale reverts back to the 0, 25, 75 etc.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the setup with xAxis granularity, forceLabelsEnabled, labelCount, and setVisibleXRange(minXRange:maxXRange:), then inspect those axis and range entry points. Compare labels before and after a slight zoom; done means setting the visible range preserves the configured granularity instead of changing increments until zooming.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.