Latest 0.1.0
Homepage https://github.com/dadalar/DDSpiderChart
License MIT
Platforms ios 8.0
Authors

CI Status
Version
License
Platform

Easy to use Spider (Radar) Chart library for iOS written in Swift.

Requirements

  • iOS 8.0+ / macOS 10.10+ / tvOS 9.0+ / watchOS 2.0+
  • Xcode 8.x
  • Swift 3.x

Installation

CocoaPods

DDSpiderChart is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "DDSpiderChart"

Usage

Styling in Interface Builder

You can use DDSpiderChartView within Interface Builder. Just drag & drop a UIView and set its class to DDSpiderChartView. The library supports IBDesignable protocol, so you will see your customized chart in Xcode.

Programmatically

To create a new instance of the chart:

let spiderChartView = DDSpiderChartView(frame: .zero) // Replace with some frame or add constraints
spiderChartView.axes = ["Axis 1", "Axis 2", "Axis 3", "Axis 4"] // Set axes by giving their labels
spiderChartView.addDataSet(values: [1.0, 0.5, 0.75, 0.6], color: .red) // Add first data set
spiderChartView.addDataSet(values: [0.9, 0.7, 0.75, 0.7], color: .blue) // Add second data set

To remove a data set from chart:

let dataSet1 = spiderChartView.addDataSet(values: [0.9, 0.7, 0.75, 0.7], color: .blue) // Add second data set
// Later
spiderChartView.removeDataSetView(dataSet!)

Customization:

spiderChartView.color = .white // This will change the color of the circles
spiderChartView.circleCount = 20 // How many circles there will be
spiderChartView.circleGap = 5 // The distance between circles
// circleCount * circleGap would be the radius of the chart itself

Text Styling: (It just works by passing an array of NSAttributedString’s as axes. You have a lot flexibility this way.)

// Custom font with custom size & color example
func attributedAxisLabel(_ label: String) -> NSAttributedString {
  let attributedString = NSMutableAttributedString()
  attributedString.append(NSAttributedString(string: label, attributes: [NSForegroundColorAttributeName: UIColor.black, NSFontAttributeName: UIFont(name: "AvenirNextCondensed-Bold", size: 16)!]))
  return attributedString
}

override func viewDidLoad() {
  super.viewDidLoad()
  spiderChartView.axes = ["PAS", "DRI", "SPD", "DEF", "PHY", "SHT"].map { attributedAxisLabel($0) }
}

Author

Deniz Adalar, [email protected]

License

DDSpiderChart is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "DDSpiderChart",
    "version": "0.1.0",
    "summary": "Easy to use Spider (Radar) Chart library for iOS written in Swift.",
    "homepage": "https://github.com/dadalar/DDSpiderChart",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Deniz Adalar": "[email protected]"
    },
    "source": {
        "git": "https://github.com/dadalar/DDSpiderChart.git",
        "tag": "0.1.0"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "DDSpiderChart/Classes/**/*",
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This