本文为ORCharts:曲线图、折线图 部分, 作详细说明git
Slider | Control |
---|---|
![]() |
![]() |
config |
---|
![]() |
pod 'ORCharts/Line'
复制代码
一、 在XIB
或Storyboard
拖拽一个 UIView
到你须要展现的位置 二、 修改Class
为 ORLineChartView
三、 设置 dataSource
和 delegate
github
@property (nonatomic, strong) ORLineChartView *lineChartView;
复制代码
_lineChartView = [[ORLineChartView alloc] initWithFrame:CGRectMake(0, 0, 375, 350)];
_lineChartView.dataSource = self;
_lineChartView.delegate = self;
[self.view addSubview:_lineChartView];
复制代码
在数据改变或是配置改变的时候reloadData
ruby
[_lineChartView reloadData];
复制代码
@required
必须实现方法,数据个数以及对应数据,相似tableView
- (NSInteger)numberOfHorizontalDataOfChartView:(ORLineChartView *)chartView;
- (CGFloat)chartView:(ORLineChartView *)chartView valueForHorizontalAtIndex:(NSInteger)index;
复制代码
@optional
垂直方向上的线条(左边label)条数,默认5 此处决定垂直区间(左边数据)的划分- (NSInteger)numberOfVerticalLinesOfChartView:(ORLineChartView *)chartView;
复制代码
底部对应数据的标题,默认近期日期:MM-dd
ide
- (NSString *)chartView:(ORLineChartView *)chartView titleForHorizontalAtIndex:(NSInteger)index;
复制代码
底部富文本属性设置post
- (NSDictionary<NSAttributedStringKey,id> *)labelAttrbutesForHorizontalOfChartView:(ORLineChartView *)chartView;
复制代码
左侧富文本属性设置动画
- (NSAttributedString *)chartView:(ORLineChartView *)chartView attributedStringForIndicaterAtIndex:(NSInteger)index;
复制代码
指示器对应数据的富文本,默认为当前数据ui
- (NSString *)chartView:(ORLineChartView *)chartView titleForHorizontalAtIndex:(NSInteger)index;
复制代码
@optional
style == ORLineChartStyleControl
点击按钮触发- (void)chartView:(ORLineChartView *)chartView didSelectValueAtIndex:(NSInteger)index;
复制代码
style == ORLineChartStyleSlider
指示器值发生变化的时候触发atom
- (void)chartView:(ORLineChartView *)chartView indicatorDidChangeValueAtIndex:(NSInteger)index;
复制代码
如下是配置中部分属性图解 spa
配置修改方式3d
_lineChart.config.style = ORLineChartStyleSlider;
_lineChart.config.isBreakLine = YES;
_lineChart.config.chartLineWidth = 2;
_lineChart.config.animateDuration = 1;
[_lineChart reloadData];
复制代码
如下为配置具体说明
chartLine
,shadowLine
宽度,默认3chartLine
颜色,默认orangeshadowLine
颜色,默认lightGray alpha 0.5
lightGray alpha 0.5
red alpha 0.3
和 blue alpha 0.3
ScrollView ContentInset
),默认10shadowLine
,默认YESchartLine
、shadowLine
是否为折线,默认NOORLineChartStyleControl
下的按钮大小,默认13chartLineColor
chartLineColor
ORLineChartStyleControl
下按钮图片,默认nilORLineChartStyleControl
下按钮选中图片,默认nil有任何问题,可在本文下方评论,或是GitHub上提出issue 若有可取之处, 记得 star