ChartsOrg / Charts

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

RadarChartView the datas disappear when I enlarge or decrease the window #2207

Open thierryH91200 opened 7 years ago

thierryH91200 commented 7 years ago

In my program inspired by ios demo This is what happens

https://www.dropbox.com/s/r4bmn262esatiuf/screencast%202017-02-28%2010-31-41.mp4?dl=0

If in my program I put in comment the next line?

 yAxis.axisMaximum = 80.0

the problem is solved

  let yAxis = radarChartView.yAxis
    yAxis.labelFont = NSUIFont(name: "HelveticaNeue-Light", size: CGFloat(9.0))!
    yAxis.labelCount = 5
    yAxis.axisMinimum = 0.0
   //yAxis.axisMaximum = 80.0
    yAxis.drawLabelsEnabled = false

https://www.dropbox.com/s/n1vvg4e37m5psxv/screencast%202017-02-28%2010-33-20.mp4?dl=0

OK but why ??

liuxuan30 commented 7 years ago

eh... seems a bug.

liuxuan30 commented 7 years ago

I looked into it: When setting yAxis.axisMaximum, in open override func notifyDataSetChanged(), the input is

_yAxisRenderer?.computeAxis(min: _yAxis._axisMinimum, max: _yAxis._axisMaximum, inverted: _yAxis.isInverted)

however inside computeAxis() -> computeAxisValues() in YAxisRendererRadarChart, computeAxisValues() is changing axis.entries and updating _axisMaximum and _axisMinimum after getting new entires:

        axis._axisMinimum = axis.entries[0]
        axis._axisMaximum = axis.entries[n-1]
        axis.axisRange = abs(axis._axisMaximum - axis._axisMinimum)

And here come's the dead loop, axisMaximum is increasing forever if computeAxis() is called, causing the radar area disappearing.

I remember I modified the code here a long time ago in https://github.com/danielgindi/Charts/pull/207, however, I just add _yAxis.axisMinimum = _yAxis.entries[0], axis._axisMaximum = axis.entries[n-1] is there all the time. Looks like an old bug, but I'm not sure if Chart 2.x has the same issue or it happen for Chart 3.x

Not having a clean shot for how to fix it.

thierryH91200 commented 7 years ago

Thanks for the explanation I understand better now

        axis._axisMinimum = axis.entries[0]
        axis._axisMaximum = axis.entries[n-1]
        print ("axis._axisMaximum = ", axis._axisMaximum)
        axis.axisRange = abs(axis._axisMaximum - axis._axisMinimum)

Log View :

enlarge the window

axis._axisMaximum = 100.0 axis._axisMaximum = 120.0 axis._axisMaximum = 140.0 axis._axisMaximum = 150.0 axis._axisMaximum = 180.0 axis._axisMaximum = 200.0

decrease the window

axis._axisMaximum = 240.0 axis._axisMaximum = 250.0 axis._axisMaximum = 300.0 axis._axisMaximum = 400.0 axis._axisMaximum = 500.0 axis._axisMaximum = 600.0

liuxuan30 commented 7 years ago

yep, it just keeps increasing no matter you how you change the window. However I need @danielgindi to give some thoughts for chart 3.x, is it possible to remove it.