Latest 0.0.8
Homepage https://github.com/olderMonster/GBChartLineView
License MIT
Platforms ios 9.0
Authors

定义一个全局变量

@property (nonatomic , strong)GBChartsLineView *lineView;

实现getter方法

#pragma mark -- getters and setters
- (GBChartsLineView *)lineView{
    if (_lineView == nil) {
        _lineView = [[GBChartsLineView alloc] init];
        _lineView.backgroundColor = [UIColor whiteColor];
        _lineView.dataSource = self;
        _lineView.delegate = self;
    }
    return _lineView;
}

设置数据源,数据源中存放的是NSNumber类型的数据

#pragma mark -- GBChartsLineViewDataSource
- (NSArray <NSNumber *> *)datasForChartLineView:(GBChartsLineView *)chartLineView{
    return self.datasArray;
}

通过以上几行代码就可以绘制一个折线图了。还可以通过其他的代理方法来设置折线图的相关属性。

1.设置折线图是否显示数据点:

- (BOOL)showPointInChartLineView:(GBChartsLineView *)chartLineView

2.设置折线图显示X、Y轴

- (BOOL)showXAxis:(GBChartsLineView *)chartLineView
- (BOOL)showYAxis:(GBChartsLineView *)chartLineView

如果显示数轴,那么可以设置数轴的数据源:

- (NSString *)unitForXAxis:(GBChartsLineView *)chartLineView

3.以上只是部分属性设置,还有部分属性未展示,具体使用可以参考.h文件中的注释说明。
目前还没有添加点击显示等操作事件,后期会考虑添加一些其他的相关功能。

//以下是展示了数据点的折线图
GBChartLineView

Latest podspec

{
    "name": "GBChartLineView",
    "version": "0.0.8",
    "summary": "u7b80u5355u7684u6298u7ebfu56fe",
    "description": "u4e00u6b3eu5c01u88c5u7684u7b80u7ea6u6298u7ebfu56feuff0cu5177u4f53u67e5u770bu622au56feu4ee5u53cau4f7fu7528",
    "homepage": "https://github.com/olderMonster/GBChartLineView",
    "license": {
        "type": "MIT",
        "file": "FILE_LICENSE"
    },
    "authors": {
        "u5370u806a": "[email protected]"
    },
    "platforms": {
        "ios": "9.0"
    },
    "source": {
        "git": "https://github.com/olderMonster/GBChartLineView.git",
        "tag": "0.0.8"
    },
    "source_files": "GBChartLineView/GBChartsLineView/*.{h,m}"
}

Pin It on Pinterest

Share This