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

Finding the RadarChartView center position in a view #1677

Closed
paul-pinto92 opened this issue Oct 18, 2016 · 1 comment
Closed

Finding the RadarChartView center position in a view #1677

paul-pinto92 opened this issue Oct 18, 2016 · 1 comment

Comments

@paul-pinto92
Copy link

Hello everyone,

I'm having an issue in finding the center position of the RadarChartView.

I understand that it is suppose to be with the attribute radarChartView.centerOffsets but when I try to draw a square in the center like that :
let x = radarChartView.centerOffsets.x
let y = radarChartView.centerOffsets.y

let pixel = Draw(frame: CGRect(
origin: CGPoint(x: x, y: y),
size: CGSize(width: 4, height: 4)))
pixel.layer.borderWidth = CGFloat(4)
pixel.layer.borderColor = UIColor.cyan.cgColor

self.view.addSubview(pixel)

here's what I get as a result :
screen shot 2016-10-18 at 15 46 54

you can see that my square is off the center of the Chart, what's up with that ?
Can you give me an another way to reach the center of the Chart, please ?

Paul

@danielgindi
Copy link
Collaborator

Yes, that is the correct way to fetch the center position - but it may change, after calculating legend size before rendering.
So you might want to call notifyDataSetChanged, or wait until after you set the data property (which calls notifyDataSetChanged, and recalculates legend).

Also note that XIB width/height of a view is not final. In viewDidLoad the size may not be the final size, as later it fetches the size of the screen and resizes the views according to constraints.

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