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

Lag during scroll #3395

Closed
Dbigshooter opened this issue Apr 12, 2018 · 1 comment
Closed

Lag during scroll #3395

Dbigshooter opened this issue Apr 12, 2018 · 1 comment

Comments

@Dbigshooter
Copy link

I've just implemented the library in a tableview, but I experience pretty heavy lagging during scrolling, when my charts hold a lot of data.

I have a method inside the ChartTableViewCell where I draw the chart based on the data I pass and call from my viewcontroller.

func updateCell() {
        let dataSet = LineChartDataSet(values: entries, label: chartLabel)
        dataSet.drawCirclesEnabled = false
        dataSet.lineWidth = 2
        dataSet.mode = .cubicBezier
        dataSet.drawValuesEnabled = false
        
        let lineChartData = LineChartData(dataSets: [dataSet])
        
        // SET DATA AND RELOAD
        chartView.data = lineChartData
        chartView.fitScreen()
    }

In my tableViewController I call the function after parsing the data:

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        
        let meta = chartMetas[indexPath.row]
        let cell = tableView.dequeueReusableCell(withIdentifier: "chartCell", for: indexPath) as! ChartTableViewCell
        cell.readings = currentReadings
        cell.updateCell()
        
        return cell
    }
    

What did I miss? Since the view is lagging so hard when scrolling.

@jjatie
Copy link
Collaborator

jjatie commented Apr 15, 2018

Charts aren't designed to work well in reusable views. My recommendation would be to render all of your Charts off screen, and grab images of them to place in your table view cell.

Please note that for how-to's, ask on Stack Overflow. If you would like to file an issue or feature request, please fill out the form provided.

@jjatie jjatie closed this as completed Apr 15, 2018
@ChartsOrg ChartsOrg locked as resolved and limited conversation to collaborators Apr 15, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants