ChartsOrg / Charts

Beautiful charts for iOS/tvOS/OSX! The Apple side of the crossplatform MPAndroidChart.
Apache License 2.0
27.55k stars 5.99k forks source link

setVisibleXRange conflicts with granularity #2260

Open acegreen opened 7 years ago

acegreen commented 7 years ago

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.

acegreen commented 7 years ago

@liuxuan30 any thoughts on how to tackle this? seems like an issue with limitTransAndScale() when its fullyZoomedOut

liuxuan30 commented 7 years ago

maybe a bug, but I don't have time to look into it