-
-
Notifications
You must be signed in to change notification settings - Fork 6k
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
LineChartView with a line that goes backwards #3919
Comments
Hi, I get this error too, the error that is occurring is because your X values is not sorted on your dataset, Something like this: entries.sort(by: { $0.x < $1.x }) will fix the error |
Hi @lucasmpaim, and thank you for your feedback! Unfortunately I shouldn't sort the values, otherwise I'll get a wrong graph: Anyway I managed to achieve my goal by manually setting the proper "min" and "max" values in the BarLineScatterCandleBubbleRenderer.XBounds class: This is the resulting graph, representing the input values just as expected: I don't quite understand how the XBounds class calculates its "min" and "max" values, but if we enhance that we can support datasets that go backwards. Let me know if I can help! |
sees we can close now |
The bug is still there, but thank you anyway. |
What did you do?
I need to draw the FVC graph (flow-volume) for a macOS app.
The graph should represent the loop-curve which measures the amount (volume) and speed (flow) of the air that was exhaled and inhaled by a patient during a breathing test.
Example:
I managed to draw the exhalation phase correctly and effortlessly (in the example it starts from 0 and it goes forward and upward, reaching the Peak expiratory flow at 12 liters per seconds, then slowly decreases until it almost reaches the 6 liters maximum volume).
What did you expect to happen?
After the exhalation phase, the graph should draw a line that goes backwards and below the x-axis, for the inhalation phase (in the example it starts from almost 6 liters of volume, goes backwards, reaches the -7 liters per seconds flow, then reconnects at 0).
What happened instead?
During the inhalation phase the values go backwards. Sometimes one value is drawn properly, sometimes not, either way when a second value is passed the graph ceases to work, and it removes all drawn lines (I think it crashes).
I tried to simulate this behavior in the ChartsDemo-macOS app, by creating a simple LineChartView with these values:
The fourth value (x: 2, y: 6) isn't drawn at all.
The fifth value (x: 0, y: 8) makes the app crash:
Fatal error: Can't form Range with upperBound < lowerBound
Charts Environment
Charts version/Branch/Commit Number: 3.2.2 (branch: master, commit: 5d0b99a)
Xcode version: 10.1, 10.2
Swift version: 4.2
Platform(s) running Charts: macOS
macOS version running Xcode: 10.14.3 (18D109), 10.14.4 (18E226)
Demo Project
Demo project with the values described above:
ChartsDemo-macOS-linebug.zip
The text was updated successfully, but these errors were encountered: