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

how to change LineChartDataSet without strange redraw issues? #3525

Closed
dcsim0n opened this issue Jun 21, 2018 · 1 comment
Closed

how to change LineChartDataSet without strange redraw issues? #3525

dcsim0n opened this issue Jun 21, 2018 · 1 comment

Comments

@dcsim0n
Copy link

dcsim0n commented Jun 21, 2018

My code is used to fetch data from a radio scanner about noise levels, the data comes in 8bit integers over a tcp stream in small bits as the scanner moves across the radio spectrum.
I start with a DataSet of all zeros so that the proper frequency range is displayed from the start.

simulator screen shot - iphone se - 2018-03-29 at 22 56 17

The first scan loop works as expected, but when the scanning loop repeats I begin to see strange results.

simulator screen shot - iphone se - 2018-03-31 at 23 22 25

The function that is responsible for parsing and inserting data into the graph.
BlockGraph is a custom class which contains information about frequency boundaries and a ChartDataEntry set

func parseAndAppend(graphToUpdate graph: BlockGraph ,rawData: ScanPacket){
print("adding Data at (rawData.offset)")
let lowerBlockBound = graph.block.bounds.0 - 10
let offset = Int(rawData.offset)
for i in 0..<rawData.bytes.count{
let freq = lowerBlockBound + (offset + i)
let byteToGraph = rawData.bytes[i]
let dataPoint = ChartDataEntry(x: Double(freq), y: Double(byteToGraph))
if offset > graph.graphData.count{
graph.graphData.append(dataPoint)
}else{
graph.graphData.insert(dataPoint, at: (offset+i))
}
}

Charts Environment

**Charts version/Branch/Commit Number: 3.1.0
**Xcode version: 9.2
**Swift version: 4.0
**Platform(s) running Charts: ios11
**macOS version running Xcode: 10.13

@liuxuan30
Copy link
Member

please ask on stack overflow. It seems your issue while scanning. Please also search old issues about dynamic update especially those tagged with GoodExample

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

No branches or pull requests

2 participants