 
 // MARK: Drawing methods
 extension DDSpiderChartView {
-
+    
     override open func draw(_ rect: CGRect) {
         let center = CGPoint(x: rect.width/2, y: rect.height/2)
         // Draw circles
-        for i in 1...circleCount {
+        let circlesToDraw = endLineCircles ? circleCount : circleCount + 1
+        for i in 1...circlesToDraw {
             let radius = CGFloat(i) * circleGap
             let circlePath = UIBezierPath(arcCenter: center, radius: radius, startAngle: 0, endAngle: CGFloat(2 * Float.pi), clockwise: true)
-            let color = (i % 2 == 0) ? self.color : self.color.withAlphaComponent(0.5)
+            let color = (i % 2 == 0 || i == circlesToDraw) ? self.color : self.color.withAlphaComponent(0.5)
             color.set()
             circlePath.stroke()
         }
-
+        
         // Draw each data set
         for (index, axis) in axes.enumerated() {
             // Draw line

            let y = center.y + (circleRadius + circleGap) * sin(angle)
            linePath.addLine(to: CGPoint(x: x, y: y))
            linePath.stroke()

            // Draw circle at the end the line
            let circleCenter = CGPoint(x: center.x + (circleRadius + circleGap * 3/2) * cos(angle), y: center.y + (circleRadius + circleGap * 3/2) * sin(angle))
            let circlePath = UIBezierPath(arcCenter: circleCenter, radius: circleGap/2, startAngle: 0, endAngle: CGFloat(2 * Float.pi), clockwise: true)
            circlePath.stroke()

            // Draw axes label
            let isOnTop = sin(angle) < 0 // we should draw text on top of the circle when circle is on the upper half. (and vice versa)

            let categoryStringSize = axis.size()
            let categoryStringPadding = circleGap/2 + 5
            let categoryStringOrigin = CGPoint(x: circleCenter.x-categoryStringSize.width/2, y: circleCenter.y+(isOnTop ? (-(categoryStringSize.height+categoryStringPadding)) : (categoryStringPadding)))
            axis.drawDrawable(with: .init(origin: categoryStringOrigin, size: categoryStringSize))
        }

    }
}

// MARK: Computational properties & helper methods
extension DDSpiderChartView {

    fileprivate var circleRadius: CGFloat {
        return CGFloat(circleCount) * circleGap
    }

    override open var intrinsicContentSize: CGSize {
        let len = 2 * circleRadius + 100 // +100 for text
        return .init(width: len, height: len)
    }

    override open func prepareForInterfaceBuilder() {
        super.prepareForInterfaceBuilder()
        axes = ["Axis 1", "Axis 2", "Axis 3", "Axis 4", "Axis 5"]
        _ = addDataSet(values: [0.7, 0.5, 0.6, 0.9, 1.0], color: .white)
    }

}


import UIKit

@IBDesignable open class DDSpiderChartView: UIView {
    
    public var axes: [DrawableString] = [] {
        didSet {
            // When categories change, data sets should be cleaned
