CHRadarGraph 0.3.0

CHRadarGraph 0.3.0

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Dec 2023
SPMSupports SPM

Maintained by Christopher Harris.



  • By
  • Christopher Harris

CHRadarGraph

Version License Platform

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

  • iOS 9+
  • Swift 3+

Coming shortly...

  • More control over label offsets
  • Shadows / Patterns within Sectors

Example

alt text

Installation

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

pod "CHRadarGraph", "~> 0.2.1"

Changelog

  • v0.2.1: Convert to Swift 3.0
  • v0.1.5: Convert to Swift 2.3
  • v0.1.4: Added more Unit tests
  • v0.1.3: Added Unit tests
  • v0.1.1: Removed dataSource methods positionOfGraph and sizeOfGraph

Documentation

Delegate methods (Swift 3.x):

Invoked before graph rendering

func willDisplayGraph(graphView: CHRadarGraphView)

Invoked after graph rendering

func didDisplayGraph(graphView: CHRadarGraphView)

Invoked before each ring rendering

func willDisplayRing(graphView: CHRadarGraphView, index: Int)

Invoked after each ring rendering

func didDisplayRing(graphView: CHRadarGraphView, index: Int)

Invoked before each sector rendering

func willDisplaySector(graphView: CHRadarGraphView, sector: CHSectorCell, index: Int)

Invoked after each sector rendering

func didDisplaySector(graphView: CHRadarGraphView, sector: CHSectorCell, index: Int)

###DataSource methods (Swift 3.x):

Position and size of graph are automatically determined by center point and radius

func centerOfGraph(graphView: CHRadarGraphView) -> CGPoint
func radiusOfGraph(graphView: CHRadarGraphView) -> CGFloat

Height for largest sector cell. This would be the largest Y-value on on a classic bar chart.

func largestHeightForSectorCell(graphView: CHRadarGraphView) -> CGFloat

The total number of data points that CAN be shown on the graph.

func numberOfSectors(graphView: CHRadarGraphView) -> Int

The total number of data points that WILL be shown on the graph. For a graph that shows data around the entire 360 degress, this number should be equal to: func numberOfSectors(graphView: CHRadarGraphView) -> Int

func numberOfDataSectors(graphView: CHRadarGraphView) -> Int

The number of Y points on the graph. For example, if your largest Y-point is 10, there should be at least 10 rings shown.

func numberOfRings(graphView: CHRadarGraphView) -> Int

The angle on the graph where the first data point is rendered. Defaults to 0.

func startingAngleInDegrees(graphView: CHRadarGraphView) -> CGFloat

Similar to tableView#cellForRowAtIndexPath, the callback to render data on graph at specific positions.

Stroke colors and line widths:

func sectorCellForPositionAtIndex(graph: CHRadarGraphView, index: Int) -> CHSectorCell?
func backgroundColorOfGraph(graphView: CHRadarGraphView) -> UIColor
func strokeColorOfRings(graphView: CHRadarGraphView) -> UIColor
func strokeWidthOfRings(graphView: CHRadarGraphView) -> CGFloat
func strokeColorOfSectorLines(graphView: CHRadarGraphView) -> UIColor
func strokeWidthOfSectorLines(graphView: CHRadarGraphView) -> CGFloat

alt text

Author

Christopher Harris, [email protected]

License

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