Charts: Issue with YAxis max and min in the RadarChart

Created on 5 Oct 2016  ·  8Comments  ·  Source: danielgindi/Charts

Hi there,

I'm facing an issue with the maximum value of the yAxis on the Radar Chart :
I want it to be from 0 to 4 so here's what i did :

radarChartView.yAxis.axisMaximum = 4
radarChartView.yAxis.axisMinimum = 0

but when i run the program here's what i get :
screen shot 2016-10-05 at 11 37 16

May someone explain to me how to achieve what i want please ? :)

Most helpful comment

@paul-pinto92 great! it helped me a lot!
the only one thing...

radarChartView.yAxis.forceLabelsEnabled = true
radarChartView.yAxis.labelCount = 5

these lines should be swapped since setter sets the option to false

open var labelCount: Int
    {
        get
        {
            return _labelCount
        }
        set
        {
            _labelCount = newValue

            if _labelCount > 25
            {
                _labelCount = 25
            }
            if _labelCount < 2
            {
                _labelCount = 2
            }

            forceLabelsEnabled = false
        }
    }

All 8 comments

Hi @paul-pinto92 , I think it's a workaround, but still. Try to set axisMaximum=3

Hi @PeterBurenkov,

That's close but not quite it :

screen shot 2016-10-05 at 13 18 12

as if the Radar Chart has to have 6 values on the axis. I'm surely missing something.

Thank you for your reply though.

maxValue = 4, axisMaximum = maxValue * 2/3 works for me :)
there is an option yAxis.labelCount try to set it equals 3

Thanks man ! That's one way to do it.
Then I dove into the source code and found why, in the YAxisRendererRadarChart, i had 6 labels and why yAxis.labelCount = 4 does not work.

You need to enable force labels like so :
radarChartView.yAxis.forceLabelsEnabled = true
then you put the amount of labels you want :
radarChartView.yAxis.labelCount = 5
and finally you ask for a maximum :
radarChartView.yAxis.axisMaximum = 4

so this code
radarChartView.yAxis.forceLabelsEnabled = true
radarChartView.yAxis.labelCount = 5
radarChartView.yAxis.axisMaximum = 4
radarChartView.yAxis.axisMinimum = 0

gives you this :
screen shot 2016-10-05 at 13 59 32

Thank you again for your help 👍

@paul-pinto92 great! it helped me a lot!
the only one thing...

radarChartView.yAxis.forceLabelsEnabled = true
radarChartView.yAxis.labelCount = 5

these lines should be swapped since setter sets the option to false

open var labelCount: Int
    {
        get
        {
            return _labelCount
        }
        set
        {
            _labelCount = newValue

            if _labelCount > 25
            {
                _labelCount = 25
            }
            if _labelCount < 2
            {
                _labelCount = 2
            }

            forceLabelsEnabled = false
        }
    }

Hey nice catch ! Thanks !

I don't believe this is fixed although it says that it is in the Changelog?

@PeterBurenkov and @paul-pinto92 's solution worked for me.
I have 5 labels & my max y-axis is required to be 5. So i set :
yAxis.labelCount = 6 yAxis.forceLabelsEnabled = true yAxis.axisMinimum = 0 yAxis.axisMaximum = 5

Worked for me.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

guanyanlin picture guanyanlin  ·  3Comments

Shunshine07 picture Shunshine07  ·  3Comments

BrandonShega picture BrandonShega  ·  4Comments

guoyutaog picture guoyutaog  ·  3Comments

brytnvmg picture brytnvmg  ·  4Comments