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

Can't set ChartViewBase's data property back to nil to clear out data #771

Closed
ospr opened this issue Feb 23, 2016 · 0 comments
Closed

Can't set ChartViewBase's data property back to nil to clear out data #771

ospr opened this issue Feb 23, 2016 · 0 comments

Comments

@ospr
Copy link
Contributor

ospr commented Feb 23, 2016

ChartViewBase's _data property is defined as an implicitly unwrapped optional when really it should be a plain optional. The value starts off as nil, but then once it has been set you can no longer set it back to nil to clear out the data in the graph. By making the _data property optional that will allow for clearing the chart data (which will allow the noDataText to be shown again) and will make use of _data safer because its not implicitly unwrapped (eg could cause a runtime error if the property is nil and is accessed).

Right now this code exists to prevent you from setting the _data property back to nil.

 if newValue == nil
 {
      print("Charts: data argument is nil on setData()", terminator: "\n")
      return
}

Note that if _data is changed from data! to data? that we'll need to handle all of the optional cases properly throughout the code base.

ospr added a commit to ospr/ios-charts that referenced this issue Feb 23, 2016
Changed ChartViewBase's _data property declaration from _data! to _data? to allow for setting the chart's data back to nil. Updated the code base to property handle _data as an optional value.
ospr added a commit to ospr/ios-charts that referenced this issue Feb 23, 2016
Changed ChartViewBase's _data property declaration from _data! to _data? to allow for setting the chart's data back to nil. Updated the code base to property handle _data as an optional value.
ospr added a commit to ospr/ios-charts that referenced this issue Feb 28, 2016
Added a "Toggle Data" option to each of the view controllers in the charts demo project. This option will either set the chart's data property to nil if toggled off or to the default data if toggled on.
danielgindi added a commit that referenced this issue Feb 28, 2016
Make ChartViewBase's _data optional. (Fixes #771)
danielgindi added a commit that referenced this issue Feb 28, 2016
Add "Toggle Data" option to demo charts. (#771 Support)
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

1 participant