ChartsOrg / Charts

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

Bar Chart Displaying Wrong Y Values JUST rightAxis,but leftAxis is OK!!! #5189

Closed AbnerPei closed 1 month ago

AbnerPei commented 1 month ago

I found the same issue: #4896

What did you do?

            /// It's OK
            let yAxis = barChartView.leftAxis
            yAxis.axisMinimum = 0
            yAxis.axisMaximum = 5
            yAxis.granularity = 1
            yAxis.labelCount = 6
            yAxis.forceLabelsEnabled = true
image
            /// It's wrong
            let yAxis = barChartView.rightAxis
            yAxis.axisMinimum = 0
            yAxis.axisMaximum = 5
            yAxis.granularity = 1
            yAxis.labelCount = 6
            yAxis.forceLabelsEnabled = true
image

What did you expect to happen?

I expect leftAxis or rightAxis has the same。

What happened instead?

ℹ Please replace this with of what happened instead.

DGCharts Environment

DGCharts version/Branch/Commit Number: Xcode version: 15.3 Swift version: 5.10 Platform(s) running DGCharts: 5.1.0 macOS version running Xcode: Sonoma 14.3.1

Demo Project

ℹ Please link to or upload a project we can download that reproduces the issue.

AbnerPei commented 1 month ago

You do this, you can do it again,as shown below

image
Viktor-by commented 1 month ago

Hi @AbnerPei ,

Please try setting axisDependency of your data set to .right. By default, the chart is plotted against the left axis.

Another workaround is to configure left and right axis with the same parameters (axisMinimum, axisMaximum etc.), then disable the left axis.

AbnerPei commented 1 month ago

Hi @AbnerPei ,

Please try setting axisDependency of your data set to .right. By default, the chart is plotted against the left axis.

Another workaround is to configure left and right axis with the same parameters (axisMinimum, axisMaximum etc.), then disable the left axis.

Thank you for your reply. It was very helpful. I just set axisDependency to .right!!!