[iOS]RBChart - LineChart

发布时间:2019-06-02 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了[iOS]RBChart - LineChart脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

RBChart - 实现一种通过配置来自定义的图表控件

    RBLineChart *chart = [[RBLineChart alloc] inITWithFrame:CGRectMake(0, 40, CGRectGetWidth([UIScreen mainScreen].bounds), 94)];
    chart.backgroundColor = [UIColor clearColor];

    RBLineData *data = [RBLineData new];
    data.values = @[@10, @80, @90, @78, @98, @79, @87];
    RBLineDecorator *lineDecorator = [[RBLineDecorator alloc] initWithHandler:^(RBLineDecorator *decorator) {
        decorator.lineColor = [UIColor colorWithred:0.095 green:0.744 blue:0.911 alpha:1.000];
        decorator.pointWidth = 5;
        decorator.lineWidth = 2.;
        decorator.lineNode = [[RBLineSolidNode alloc] initWithHandler:^(RBLineSolidNode *node) {
            node.fillColor = [UIColor colorWithred:0.095 green:0.744 blue:0.911 alpha:1.000];
            node.strokeColor = [UIColor colorWithRed:0.095 green:0.744 blue:0.911 alpha:1.000];
        }];
    }];
    data.lineDecorator = lineDecorator;

    RBLineData *data2 = [RBLineData new];
    data2.values = @[@20, @60, @40, @98, @70, @65, @30];
    RBLineDecorator *lineDecorator2 = [[RBLineDecorator alloc] initWithHandler:^(RBLineDecorator *decorator) {
        decorator.lineColor = [UIColor colorWithRed:0.911 green:0.902 blue:0.169 alpha:1.000];
        decorator.pointWidth = 5;
        decorator.lineWidth = 2.;
        decorator.lineNode = [[RBLineHollowNode alloc] initWithHandler:^(RBLineHollowNode *node) {
            node.lineWidth = 2;
            node.strokeColor = [UIColor colorWithRed:0.911 green:0.902 blue:0.169 alpha:1.000];
        }];
    }];
    data2.lineDecorator = lineDecorator2;

    [chart setDatas:@[data, data2] titles:@[@"摄入", @"消耗"]];

    chart.chartDecorator = [[RBLineChartDecorator alloc] initWithHandler:^(RBLineChartDecorator *decorator) {
        decorator.backgroundColor = [UIColor blackColor];
        decorator.leading = 20;
    }];

    chart.maxValue = 120;

    [chart handlerTouch:^(NSInteger index, NSArray *values) {
        NSLOG(@"index %li values: %@", (long)index, values);
    }];
    [self.view addSubview:chart];
    [chart draw];

RBLineChart: 线形图表
RBLineData: 线的数据(数值与修饰器)
RBLineDecorator: 修饰一条线(颜色、粗细、节点)
RBLineNode: 节点(实现RBLineNodePRotocol)
RBLineChartDecorator: 图表的修饰器(背景、Leading)

[iOS]RBChart - LineChart

脚本宝典总结

以上是脚本宝典为你收集整理的[iOS]RBChart - LineChart全部内容,希望文章能够帮你解决[iOS]RBChart - LineChart所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。