ORCharts: Ring charts, pie charts and fan charts are described in detail in this paper

Related links

  • GitHub
  • ORCharts
  • ORCharts

Results the preview






The installation


pod 'ORCharts/Ring'  
Copy the code


use


Use Interface Builder

1. Drag and drop a UIView from the XIB or Storyboard to the location where you want to display it

code

@property (nonatomic.strong) ORRingChartView *ringChartView;
Copy the code
_ringChartView = [[ORRingChartView alloc] initWithFrame:CGRectMake(0.0.375.375)];
_ringChartView.dataSource = self;
[self.view addSubview:_ringChartView];
Copy the code

ReloadData when data changes or configuration changes

[_ringChartView reloadData];
Copy the code


style


ORRingChartStyleRing: ring chart (default) ORRingChartStylePie: pie chart ORRingChartStyleFan: fan chart

    _ringChart.style = ORRingChartStylePie;
Copy the code


Agent for the relevant


ORRingChartViewDatasource

  • @requiredYou have to implement the method, the number of data and the corresponding data, and so ontableView
- (NSInteger)numberOfRingsOfChartView:(ORRingChartView *)chartView;
- (CGFloat)chartView:(ORRingChartView *)chartView valueAtRingIndex:(NSInteger)index;
Copy the code
  • @optionalThe gradient corresponding to the Index data view, which defaults to a random color
- (NSArray <UIColor *> *)chartView:(ORRingChartView *)chartView graidentColorsAtRingIndex:(NSInteger)index;
Copy the code

The line color corresponding to the Index data view, white by default

- (UIColor *)chartView:(ORRingChartView *)chartView lineColorForRingAtRingIndex:(NSInteger)index;
Copy the code

The information line color corresponding to the Index data, which defaults to the first color of graidentColors

- (UIColor *)chartView:(ORRingChartView *)chartView lineColorForInfoLineAtRingIndex:(NSInteger)index;
Copy the code

The central view, nil by default, comes back and you have to set the view size

- (UIView *)viewForRingCenterOfChartView:(ORRingChartView *)chartView;
Copy the code

The top information view for Index data, nil by default, returns with the view size set

- (UIView *)chartView:(ORRingChartView *)chartView viewForTopInfoAtRingIndex:(NSInteger)index;
Copy the code

The bottom information view of the Index data, nil by default, returns with the view size set

- (UIView *)chartView:(ORRingChartView *)chartView viewForBottomInfoAtRingIndex:(NSInteger)index;
Copy the code


Configuration related


The following is a diagram of some of the properties in the configuration

Configuration Modification Mode

_ringChart.config.neatInfoLine = YES;
_ringChart.config.ringLineWidth = 2;
_ringChart.config.animateDuration = 1;
[_ringChart reloadData];
Copy the code

The following describes the configuration

  • Duration of animation, 0, NO animation, default 1 neatInfoLine alignment, equal width, default NO startAngle RingLineWidth: ringLine width, default 2 infoLineWidth: infoLine width, default 2

  • MinInfoInset: indicates the offset of the infoView. The larger the value is, the wider the infoView will be. The default value is 0. InfoLineBreakMargin: distance from infoLine to infoView. The default value is 10. InfoLineBreakMargin: distance from infoLine to infoView

  • Other pointWidth: infoline end dot width, default 5 ringWidth: circle graph, ringWidth, invalid if centerView is set, default 60

At the end of the article


Making portal

If you have any questions, please comment below this article or make an issue on GitHub