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

Default backgroundColor (nil) displays as black instead of clear. #2222

Closed
cpboyd opened this issue Mar 3, 2017 · 6 comments · Fixed by #2228
Closed

Default backgroundColor (nil) displays as black instead of clear. #2222

cpboyd opened this issue Mar 3, 2017 · 6 comments · Fixed by #2228

Comments

@cpboyd
Copy link

cpboyd commented Mar 3, 2017

As the title states, the default backgroundColor of a view is nil, which shows in the Storyboard as transparent.

It seems counter-intuitive that this would be UIColor.black rather than .clear

Obviously, it's easy to work-around with a simple chartView.backgroundColor = .clear.

However, it seems like the "default" should match other views, which use a clear color.

@liuxuan30 liuxuan30 added idea and removed idea labels Mar 7, 2017
@liuxuan30
Copy link
Member

Just saw

    public override init(frame: CGRect)
    {
        super.init(frame: frame)

		#if os(iOS)
			self.backgroundColor = NSUIColor.clear
		#endif
        initialize()
    }

when init, it will be clear

@cpboyd
Copy link
Author

cpboyd commented Mar 7, 2017

@liuxuan30
Hmm. It doesn't seem to do that when instantiated via a Storyboard.

Perhaps this is relevant?
http://stackoverflow.com/questions/8373176/how-is-view-initialized-when-loaded-via-a-storyboard

Maybe this should also be called from initWithCoder, e.g.:

required init?(coder: NSCoder) {
		super.init(coder: coder)
		#if os(iOS)
			self.backgroundColor = NSUIColor.clear
		#endif
}

liuxuan30 added a commit to liuxuan30/Charts that referenced this issue Mar 7, 2017
@liuxuan30 liuxuan30 reopened this Mar 7, 2017
@liuxuan30
Copy link
Member

I had a PR for this, move the color setter to initialize()

@liuxuan30
Copy link
Member

liuxuan30 commented Mar 7, 2017

@danielgindi please review this, I am not sure why it's just seen in initWithFrame() or we just missed the storyboard init

liuxuan30 added a commit to liuxuan30/Charts that referenced this issue Mar 10, 2017
liuxuan30 added a commit that referenced this issue Apr 24, 2017
fix #2222 move default backgroundColor to initialize()
Neral pushed a commit to Neral/Charts that referenced this issue Apr 24, 2017
…l/update_upstream

* commit '04c5820a6cca34b98cb48b8baab1dd44f44e857d': (61 commits)
  add switch for clearing `lastHighlighted` in clear() (ChartsOrg#2355)
  update schemes, move script to file like ChartsRealm
  use name instead of uuid, add run script for copying missing framework for ChartsTests
  1. use xcode 8.3 image 2. use Apple TV 1080p (10.2) and iPhone 7 (10.3) device id in Travis CI
  Fix Simple Bar Chart Demo, switch use of x and y values (ChartsOrg#2365)
  Converted swift 3.0 DBL_MIN leftover
  Removed leftover script from the combined Realm era
  Removed leftover scheme
  v3.0.2
  Removed unrequited script
  gitignore updates
  Added @discardableResult to silence warnings when it’s safe to ignore result
  Moved Realm stuff to https://github.com/danielgindi/ChartsRealm
  Remove line width minimum constraint
  Updated build-dependencies.sh
  loosen realm version requirement
  fix Xcode 8.3 compiler warnings
  fix ChartsOrg#2222 move default backgroundColor to initialize() as initWithCoder also needs it
  Updated to use Realm version 2.4.3
  Consider _yAxis.isDrawLimitLinesBehindDataEnabled for radar chart
  ...

# Conflicts:
#	Source/ChartsRealm/Data/RealmBarDataSet.swift
Neral pushed a commit to Neral/Charts that referenced this issue Apr 24, 2017
…l/update_upstream

* commit '04c5820a6cca34b98cb48b8baab1dd44f44e857d': (61 commits)
  add switch for clearing `lastHighlighted` in clear() (ChartsOrg#2355)
  update schemes, move script to file like ChartsRealm
  use name instead of uuid, add run script for copying missing framework for ChartsTests
  1. use xcode 8.3 image 2. use Apple TV 1080p (10.2) and iPhone 7 (10.3) device id in Travis CI
  Fix Simple Bar Chart Demo, switch use of x and y values (ChartsOrg#2365)
  Converted swift 3.0 DBL_MIN leftover
  Removed leftover script from the combined Realm era
  Removed leftover scheme
  v3.0.2
  Removed unrequited script
  gitignore updates
  Added @discardableResult to silence warnings when it’s safe to ignore result
  Moved Realm stuff to https://github.com/danielgindi/ChartsRealm
  Remove line width minimum constraint
  Updated build-dependencies.sh
  loosen realm version requirement
  fix Xcode 8.3 compiler warnings
  fix ChartsOrg#2222 move default backgroundColor to initialize() as initWithCoder also needs it
  Updated to use Realm version 2.4.3
  Consider _yAxis.isDrawLimitLinesBehindDataEnabled for radar chart
  ...

# Conflicts:
#	Source/ChartsRealm/Data/RealmBarDataSet.swift
@euri16
Copy link

euri16 commented Jun 15, 2017

I just updated to version 3.0.2 and still have a default black background behind my chart. I added a UIView in storyboard and set the class to LineChartView, modules Charts, what I have to do to remove that black background?

I also have tried doing this:

self.lineChart.backgroundColor = .clear

@liuxuan30
Copy link
Member

This change is not in 3.0.2. Pull from master

PeterSrost pushed a commit to sokol8/Charts that referenced this issue Oct 31, 2018
PeterSrost pushed a commit to sokol8/Charts that referenced this issue Oct 31, 2018
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

Successfully merging a pull request may close this issue.

3 participants