I am customising ios charts as per my need and showing them in a tabel view. For the first time they look different and after scrolling and reloading they look better.
I have taken a view inside a cell and adding chart as a subview.
Here is my code :
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let heartRateCell = tableView.dequeueReusableCell(withIdentifier: "HeartRateCell", for: indexPath) as! HeartRateCell
heartRateCell.backgroundColor = UIColor.clear
print(stackedChartData)
while let subview = heartRateCell.heartRateChartView.subviews.last {
subview.removeFromSuperview()
}
let chartview = CustomLineChart(frame : heartRateCell.heartRateChartView.frame)
print(heartRateCell.heartRateChartView.frame)
//chartview.frame = heartRateCell.heartRateChartView.frame
chartview.setupLineChart(data: heartRateData)
heartRateCell.heartRateChartView.addSubview(chartview)
heartRateCell.heartRateChartView.bringSubview(toFront: chartview)
heartRateCell.heartRateChartView.layoutIfNeeded()
return heartRateCell
}
Here are images before and after scrolling (or reloading ).
Any Idea why it is behaving like this ? thanks.