本文爲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