Real time chart issue
- Dominant language
- Swift
- Stars
- 28k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
I know this issue discussed many times but I could not find a solution for my case.
I created this class
import Foundation
import Charts
class SignalChart : LineChartView, ChartViewDelegate
{
@IBInspectable var signalName:String = ""
required init?(coder: NSCoder)
{
super.init(coder: coder)
self.gridBackgroundColor = NSUIColor.white
self.xAxis.drawGridLinesEnabled = false;
self.xAxis.labelPosition = XAxis.LabelPosition.bottom
}
func update(data: [ChartDataEntry])
{
let chartData = LineChartData()
let dataset = LineChartDataSet(values: data, label: signalName)
dataset.drawCirclesEnabled = false
dataset.colors = [NSUIColor.red]
dataset.mode = .cubicBezier
chartData.addDataSet(dataset)
self.clear()
self.clearValues()
self.data = chartData
self.data?.removeEntry(data.first!, dataSetIndex: 0)
self.notifyDataSetChanged()
}
}
So actually this is working. When my dataset is big enough, it starts to feel like a signal reader which I am trying to achieve. My problem is the below. At one point, which is not fixed(sometimes it happens in a second or it happens after 5 seconds, but it happens). So i do not think it is because of the sample size since it does sometimes when it is full or after a while it is full, or not full at all.
This is when it is working properly.

And this what happens after a while

Any ideas?
Contributor guide
Research direction
Start with the SignalChart.update(data:) entry point and its LineChartView, LineChartData, and LineChartDataSet usage. Reproduce the transition between the two linked chart states while varying dataset size and update timing; done means the triggering conditions and expected chart behavior are documented, with no repository file or test named in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- data-visualization, mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100