Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

it will crash when i insert data on RadarChart #1833

Open
canyu9512 opened this issue Nov 15, 2016 · 8 comments
Open

it will crash when i insert data on RadarChart #1833

canyu9512 opened this issue Nov 15, 2016 · 8 comments
Labels

Comments

@canyu9512
Copy link

example:
RadarChartDataEntry *entry1 = [[RadarChartDataEntry alloc] initWithValue:[@"0.334" floatValue]]; RadarChartDataEntry *entry2 = [[RadarChartDataEntry alloc] initWithValue:[@"0.330" floatValue]]; RadarChartDataEntry *entry3 = [[RadarChartDataEntry alloc] initWithValue:[@"0.330" floatValue]]; [entries1 addObject:entry1]; [entries1 addObject:entry2]; [entries1 addObject:entry3];

sometime when i insert some data,it will crash at YAxisRendererRadarChart.swift line 137。
fatal error: Double value cannot be converted to Int because it is either infinite or NaN

@liuxuan30
Copy link
Member

first format your code as readable code.
What data you insert and causes the NaN? Can you reproduce it with ChartsDemo?

@canyu9512
Copy link
Author

canyu9512 commented Nov 18, 2016

NSMutableArray *entries1 = [[NSMutableArray alloc] init];
RadarChartDataEntry *entry1 = [[RadarChartDataEntry alloc] initWithValue:[@"0.334" floatValue]];
RadarChartDataEntry *entry2 = [[RadarChartDataEntry alloc] initWithValue:[@"0.330" floatValue]];
RadarChartDataEntry *entry3 = [[RadarChartDataEntry alloc] initWithValue:[@"0.330" floatValue]];
[entries1 addObject:entry1];
[entries1 addObject:entry2];
[entries1 addObject:entry3];
RadarChartDataSet *set1 = [[RadarChartDataSet alloc] initWithValues:entries1 label:@"Last Week"];
When i insert data such as [0.334, 0.330, 0.330] , this is just one of them, there are some other data can result in collapse, this will reappear in the ChartsDemo.
The code above is my test on ChartsDemo.

@liuxuan30
Copy link
Member

liuxuan30 commented Nov 18, 2016

You totally missed the point how it crashes, and how you insert the data.
I have no problem adding new entry into radar chart in ChartsDemo:

    double mult = 80;
    double min = 20;
    RadarChartDataEntry *entry1 = [[RadarChartDataEntry alloc] initWithValue:(arc4random_uniform(mult) + min)];
    [_chartView.data.dataSets.firstObject addEntry:entry1];
    [_chartView.data notifyDataChanged];
    [_chartView notifyDataSetChanged];

If it still crashes on your side, make sure you post a full code sample so I can paste into ChartsDemo and reproduce, then ropen this thread.

@mattgallivan
Copy link

mattgallivan commented Dec 6, 2016

The following causes a crash of the same type as the previous poster:

class ExampleRadarChartView: RadarChartView {

    public override init(frame: CGRect) {
        super.init(frame: frame)
        configure()
        let entries = [
            RadarChartDataEntry(value: 0.7),
            RadarChartDataEntry(value: 0.36),
            RadarChartDataEntry(value: 0.4),
            RadarChartDataEntry(value: 0.8),
            RadarChartDataEntry(value: 0.6),
            RadarChartDataEntry(value: 0.4),
        ]
        let dataSet = RadarChartDataSet(values: entries, label: nil)
        dataSet.drawFilledEnabled = true
        dataSet.drawValuesEnabled = false
        data = RadarChartData(dataSet: dataSet)
    }

    public required init(coder aDecoder: NSCoder) {
        fatalError("")
    }

    private func configure() {
        chartDescription = nil
        drawMarkers = false
        drawWeb = false
        isUserInteractionEnabled = false
        xAxis.drawAxisLineEnabled = false
        xAxis.drawLabelsEnabled = false
        xAxis.drawGridLinesEnabled = false
        yAxis.drawAxisLineEnabled = false
        yAxis.drawLabelsEnabled = false
        yAxis.drawGridLinesEnabled = false
    }
}

@mattgallivan
Copy link

mattgallivan commented Dec 6, 2016

It would appear that this is because interval is being set to 0. That seems to happen here:

if intervalSigDigit > 5
{
    // Use one order of magnitude higher, to avoid intervals like 0.9 or
    // 90
    interval = floor(10 * intervalMagnitude)
}

EDIT:

I believe this is a result of assuming that intervalMagnitude >= 0.1. When it is less than 0.1, the interval becomes zero which results in an incorrect log10 call at the point of error.

@liuxuan30
Copy link
Member

I need to know why interval is 0? Could you provide the data when it's calculated as 0?

@liuxuan30 liuxuan30 reopened this Dec 8, 2016
@mattgallivan
Copy link

I believe that the data in my example causes the crash.

@liuxuan30 liuxuan30 added the bug label Dec 20, 2016
@royherma
Copy link

App freezing when I put data into my radar view. Even testing out simple values causes issues. The self.radarChart.data is the problem, as when i comment it out, the graph displays fine, just with "no data label" displayed.

Any ideas?

let cde1 = ChartDataEntry(value: 10.0, xIndex: 0)
let cde2 = ChartDataEntry(value: 15.0, xIndex: 1)
self.radarChart.data = RadarChartData(xVals: ["a","b"], dataSet: RadarChartDataSet(yVals: [cde1,cde2]))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants