ivnsch / SwiftCharts

Easy to use and highly customizable charts library for iOS
Apache License 2.0
2.53k stars 410 forks source link

Programmatically change the color of ChartPointTextCircleView in generator #310

Closed av8ramit closed 6 years ago

av8ramit commented 6 years ago

I want to change the color of ChartPointTextCircleView programmatically based on which line they are attached to. The ChartPointsViewsLayer constructor takes in a circleViewGenerator but outside of creating multiple of these I'm not sure how I can programmatically pass in the color.

danieldesouzadev commented 6 years ago
     `let v = ChartPointTextCircleView(chartPoint: chartPoint, center: screenLoc, diameter: 16, cornerRadius: 8, borderWidth: 0, font: ChartDefault.fontWithSize( 8))

        if ( number <= 2) {
            v.layer.backgroundColor = UIColor.Black.cgColor
        } else {
            v.layer.backgroundColor = UIColor.White.cgColor
        }`

I do not know how to do it differently.

av8ramit commented 6 years ago

@danieldesouzadev good idea, I ended up declaring the generator in my for loop. Thanks!