Charts: Die Lochfarbe kann für Kreisdiagramm nicht auf Null gesetzt werden

Erstellt am 3. Jan. 2016  ·  6Kommentare  ·  Quelle: danielgindi/Charts

Für ein transparentes Loch wird empfohlen:

*Note: Use holeTransparent with holeColor = nil to make the hole transparent.*```

Die folgende Einrichtung führt jedoch zu einem Absturz:

pieChart.holeTransparent = true
pieChart.holeColor = nil

In Bezug auf die Implementierung wird die holeColor explizit entpackt, vermutlich aufgrund der Prüfung auf Null, die ihr vorausgeht. Das explizite Auspacken ist jedoch nicht Gegenstand der Prüfung:

if (holeColor !== nil && holeColor != UIColor.clearColor())
            {
                // draw the hole-circle
                CGContextSetFillColorWithColor(context, holeColor!.CGColor)
                CGContextFillEllipseInRect(context, CGRect(x: center.x - holeRadius, y: center.y - holeRadius, width: holeRadius * 2.0, height: holeRadius * 2.0))
            }

            // only draw the circle if it can be seen (not covered by the hole)
            if (transparentCircleRadiusPercent > holeRadiusPercent)
            {
                let alpha = holeAlpha * _animator.phaseX * _animator.phaseY
                let secondHoleRadius = radius * transparentCircleRadiusPercent

                // make transparent
                CGContextSetFillColorWithColor(context, holeColor!.colorWithAlphaComponent(alpha).CGColor)

                // draw the transparent-circle
                CGContextFillEllipseInRect(context, CGRect(x: center.x - secondHoleRadius, y: center.y - secondHoleRadius, width: secondHoleRadius * 2.0, height: secondHoleRadius * 2.0))
            }

Temporäre Problemumgehung:

pieChart.holeColor = UIColor.clearColor()

bug

Hilfreichster Kommentar

Das ist ein Syntaxfehler, sollte niedriger seinCase if ;-)

Alle 6 Kommentare

Du hast Recht :-)
Es gibt immer noch einige ! den frühen Tagen von Swift, als nicht klar war, wie unsicher das ! ...
Die meisten von ihnen sind jetzt weg, Gott sei Dank!

ich denke du meinst

If let god = god {
    thank(god)
}

Ich freue mich darauf, es auszuprobieren!

😂

Das ist ein Syntaxfehler, sollte niedriger seinCase if ;-)

Ich muss einen Farbschatten in das Kreisdiagramm einfügen (wie Holecolor), der einem bestimmten Slice entspricht. wie kann ich das machen?

So implementieren Sie die Beschriftung sofort, um ein Bild in einem Kreisdiagramm zu erstellen
schnell 4

War diese Seite hilfreich?
0 / 5 - 0 Bewertungen

Verwandte Themen

Aungbandlab picture Aungbandlab  ·  4Kommentare

valeIT picture valeIT  ·  3Kommentare

deepumukundan picture deepumukundan  ·  3Kommentare

coop44483 picture coop44483  ·  3Kommentare

anhltse03448 picture anhltse03448  ·  3Kommentare