ChartsOrg / ChartsOrg/Charts

Graph is not smooth when viewing the controller. But switching to another controller and back, for that duration the graph is smooth

Open
#4,007 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
28k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

## What did you do?

ℹ Implemented the graph for the first time in an app.

## What did you expect to happen?

ℹ Expected the graph (LineChart) to be smooth

## What happened instead?

ℹ When I am on the controller that is displaying the chart, the graph is choppy. But when I switch to another tab, stay there for a while (10 seconds), return to the chart display screen - the 10 seconds piece of chart is smooth. I am receiving data from a bluetooth device and I am using notifications to post the points from one class to the controller.

## Charts Environment

**Charts version/Branch/Commit Number:** 3.2
**Xcode version:** 10.2
**Swift version:** 4
**Platform(s) running Charts:** iOS
**macOS version running Xcode:** 10.14.4

## Demo Project

ℹ I can't really upload the code since you would need a bluetooth device to reproduce the issue.

Has anybody seen an issue like this before? Does having the view controller show the graph go in background change the way it plots the graph?

Not sure if it helps but here is the code for it.

`func setChart(timeStamp: Double, frequency: Double) {
if (self.dataEntries.count > kMaxPointsOnScreen) {
self.dataEntries.remove(at: 0)
}
self.dataEntries.append(ChartDataEntry(x: Double(timeStamp), y: Double(frequency)))
let lineChartDataSet = LineChartDataSet(values: dataEntries, label: "")
lineChartDataSet.circleRadius = 0
lineChartDataSet.circleHoleRadius = CGFloat(0)
lineChartDataSet.label = ""
lineChartDataSet.drawCirclesEnabled = false
lineChartDataSet.drawCircleHoleEnabled = false
lineChartDataSet.drawValuesEnabled = false
lineChartDataSet.mode = .cubicBezier
let lineChartData = LineChartData(dataSet: lineChartDataSet)
lineChartView.data = lineChartData
}`

`func setupChart() {
self.lineChartView.noDataText = "Connect a bluetooth device."
self.lineChartView.drawGridBackgroundEnabled = false
self.lineChartView.borderLineWidth = 0
self.lineChartView.drawBordersEnabled = false
self.lineChartView.borderColor = UIColor.clear
self.lineChartView.leftAxis.enabled = false
self.lineChartView.leftAxis.drawLabelsEnabled = false
self.lineChartView.rightAxis.drawLabelsEnabled = false
self.lineChartView.xAxis.drawLabelsEnabled = false
self.lineChartView.rightAxis.enabled = false
self.lineChartView.xAxis.enabled = false
self.lineChartView.leftAxis.gridLineWidth = 0
self.lineChartView.rightAxis.gridLineWidth = 0
self.lineChartView.xAxis.gridLineWidth = 0
}`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.