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 can I don't draw lines when data absent at some point? #2968

Closed
willard1218 opened this issue Nov 8, 2017 · 6 comments
Closed

How can I don't draw lines when data absent at some point? #2968

willard1218 opened this issue Nov 8, 2017 · 6 comments

Comments

@willard1218
Copy link

willard1218 commented Nov 8, 2017

If I have frequently data, but sometimes data absent at some point.
For example:

2017-11-08 10 34 11

The interval of the dataset are same, in this case is 1.
So the data absent at x = 5, 6.

How can I don't draw line between x = 4 and x = 7 ?
Just like this:

2017-11-08 10 34 11

@willard1218 willard1218 changed the title How can I don't draw lines when data not existed? How can I don't draw lines when data absent at some point? Nov 8, 2017
@liuxuan30
Copy link
Member

create two data sets for each line segment.

@willard1218
Copy link
Author

If I have data at these point:
x = 0, 1, 2
x = 4, 5
x = 8, 9

So the data absent at x = 3, 7

then I have to create three data sets?

@liuxuan30
Copy link
Member

I'm afraid so. one set for one line segment. I used to add this feature, however it's kind of buggy when thinking about filling beneath line area, so the workaround is use multiple data sets so far.

if you don't need filling, that's easier you can just override drawLinear to add those break points. warning: you have to fully understand how it works and then you know how to break the lines.

@willard1218
Copy link
Author

Finally, I modify the LineChartRenderer.swift,
here is the change

I define data not existed if y == -999,
So, when y = -999, I just move(to: pt) instead of addLine(to: pt).

Here is result
2017-11-15 10 04 43

The dataSet of Heartbeat are [80,90,-999,80,68,-999,-999,95]

@liuxuan30
Copy link
Member

liuxuan30 commented Nov 15, 2017

you can use NSNotFound instead of -999. have you tested both positive values and negative values together? As I said, evil in the filling part.
but if it's always positive values like bpm, it should be fine for your case.

@willard1218
Copy link
Author

willard1218 commented Nov 15, 2017

Yes, i will use NSNotFound instead of -999, and my dataset are always positive values.
As you said, when I fill the chart.
2017-11-15 10 04 43
the green area has fill color, but I don't want this.
So this is a problem...

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