Latest 0.1.1
Homepage https://github.com/neils4fun/NRSPieChart
License MIT
Platforms ios 8.0
Authors

CI Status
Version
License
Platform

Example

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

Requirements

Installation

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

pod "NRSPieChart"

Author

neils4fun, [email protected]

License

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

Features:

  • Supports major and minor slices
  • Select and highlight slices
  • Animates slice size and color changes
  • Configurable in interface builder (IBInspectable)

Usage

Basic chart:

@property (weak) IBOutlet NRSPieChartView          *pieChartView;

#pragma mark - PieChartViewDataSource

- (NSUInteger) numberOfMajorSlicesInPieChartView:(NRSPieChartView *)pieCharView {
return 10; // Total number of major slices
}

- (NSUInteger) numberOfMinorSlicesInPieChartView:(NRSPieChartView *)pieCharView forMajorSlice:(NSUInteger)majorSlice {
return 1; // Number of minor slices per major slice
}

- (CGColorRef) pieChartColorForSlice:(NRSPieChartView *)pieChartView sliceIndex:(NRSPieChartViewSliceIndex * _Nonnull)sliceIndex {

return [UIColor redColor] CGColor]; // Return the color for the given major.minor slice
}

- (NRSPieChartViewEndPoints *) pieChartEndPointsForSlice:(NRSPieChartView *)pieChartView sliceIndex:(NRSPieChartViewSliceIndex * _Nonnull)sliceIndex {
return [[NRSPieChartViewEndPoints alloc] initWithStart:(10 + 0.05)  end:(30 - 0.05)];j // Return an "End Point", based on 0...100 range. 0 corresponds to 12 o'clock position in chart
}

- (BOOL)pieChartShouldHighlightSlice:(NRSPieChartView *)pieChartView sliceIndex:(NRSPieChartViewSliceIndex *)sliceIndex {
return NO; // return if given slice should be highlighted. Highlighted slices are displayed with extend width
}

#pragma mark - PieChartViewDelegate

- (void)pieChartDidSingleTapSlice:(NRSPieChartView *)pieChartView sliceIndex:(NRSPieChartViewSliceIndex *)sliceIndex {
// called on single tap of chart. Example, can capture selection here and use that highlight the tapped slice. NOTE: remember to refresh pieChart in order to show the highlighted slice.
[pieChartView refreshSlices];
}

Latest podspec

{
    "name": "NRSPieChart",
    "version": "0.1.1",
    "summary": "A PieChart control that supports slice animations, and interactions.",
    "description": "NRSPieChart is a UIView subclass that presents a customizable PieChart graph. The class will render smooth animations of PieChart slices and colors when the data model changes and the PieChart is refreshed. The data model and delegate have similar semantics to that of a UITableView or UICollectionView. NRSPieChart attributes are IBInspectable, so they can easily be configured directly in Interface Builder.",
    "homepage": "https://github.com/neils4fun/NRSPieChart",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "neils4fun": "[email protected]"
    },
    "source": {
        "git": "https://github.com/neils4fun/NRSPieChart.git",
        "tag": "0.1.1"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "NRSPieChart/Classes/**/*",
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This