You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On a Line Chart with zero entries, I called setVisibleXRangeMaximum(10)
What did you expect to happen?
I expect it to display an empty chart.
What happened instead?
The next time the line chart is drawn, it crashes with this message:
Fatal error: Double value cannot be converted to Int because it is either infinite or NaN.
At AxisRendererBase::computeAxisValues - line 120.
Charts Environment
Charts version/Branch/Commit Number: 3.3.0 Xcode version: 10.3 Swift version: 5 Platform(s) running Charts: iPhone macOS version running Xcode: 10.14.5
Demo Project
Initialize a chart like normal but don't add any entries to it.
Call setVisibleXRangeMaximum(10) - number doesn't matter.
Next time it draws the graph, the crash occurs.
As mentioned among some other issues, it's a bad idea to create a chart with empty data.
In my app, I'm slowly adding data to the chart over time, so it's only natural for it to start out empty.
This crash can also occur if you remove entries from a line chart to make it have zero entries.
I'm not sure if the same crash happens on other types of charts.
In my project, I'll make sure that this function doesn't get called before any data is added.
I wanted to add this issue for visibility in case someone else runs into this issue, and if I have time I'll create a PR to stop the crash from occurring or to provide a better explanation when the crash happens.
I have to hold this as, when you know it's empty, you shouldn't call set visible range.
There has been arguing that who should take care of these exceptions, and currently I think the user of this library should take actions before us.
What did you do?
On a Line Chart with zero entries, I called setVisibleXRangeMaximum(10)
What did you expect to happen?
I expect it to display an empty chart.
What happened instead?
The next time the line chart is drawn, it crashes with this message:
At AxisRendererBase::computeAxisValues - line 120.
Charts Environment
Charts version/Branch/Commit Number: 3.3.0
Xcode version: 10.3
Swift version: 5
Platform(s) running Charts: iPhone
macOS version running Xcode: 10.14.5
Demo Project
Initialize a chart like normal but don't add any entries to it.
Call setVisibleXRangeMaximum(10) - number doesn't matter.
Next time it draws the graph, the crash occurs.
As mentioned among some other issues, it's a bad idea to create a chart with empty data.
In my app, I'm slowly adding data to the chart over time, so it's only natural for it to start out empty.
This crash can also occur if you remove entries from a line chart to make it have zero entries.
I'm not sure if the same crash happens on other types of charts.
In my project, I'll make sure that this function doesn't get called before any data is added.
I wanted to add this issue for visibility in case someone else runs into this issue, and if I have time I'll create a PR to stop the crash from occurring or to provide a better explanation when the crash happens.
Related: #2888 #1945 #3352 #2845 #1491
https://stackoverflow.com/questions/45496912/how-to-clear-a-chart-and-then-add-data-to-it-in-swift-3-using-chartview-clear
The text was updated successfully, but these errors were encountered: