曲线图

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//
//  ViewController.m
//  AAChartKitDemo
//
//  Created by bairui on 2023/6/28.
//
 
#import "ViewController.h"
#import <AAChartKit/AAChartKit.h>
 
@interface ViewController ()
 
@property(nonatomic,strong)AAChartView *sleepView;
@property(nonatomic,strong)UIButton *changeBtn;
 
@end
 
@implementation ViewController
 
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
     
    CGFloat chartViewWidth  = self.view.frame.size.width;
    CGFloat chartViewHeight = self.view.frame.size.height - 250;
    self.sleepView = [[AAChartView alloc]init];
    self.sleepView.frame = CGRectMake(0, 60, chartViewWidth, chartViewHeight);
    ////禁用 AAChartView 滚动效果(默认不禁用)
    //self.aaChartView.scrollEnabled = NO;
    [self.view addSubview:self.sleepView];
     
    AAChartModel *aaChartModel = AAChartModel.new
        .chartTypeSet(AAChartTypeLine)//设置图表的类型(这里以设置的为折线面积图为例)
        .titleSet(@"ECG Paper Style Chart")//设置图表标题
        .colorsThemeSet(@[@"#fe117c"])//设置主题颜色数组
        .yAxisLabelsEnabledSet(false)
        .xAxisLabelsEnabledSet(false)
        .legendEnabledSet(false)
        .subtitleSet(@"虚拟数据 虚拟数据  虚拟数据  虚拟数据")//设置图表副标题
//        .categoriesSet(@[@"00:00",@"3",@"5",@"7", @"9",@"11",@"13",@"15",@"17"])//图表x轴的内容
//        .xAxisTickIntervalSet(@3) //设置 X轴坐标点的间隔数,默认是1
        .seriesSet(@[
            AASeriesElement.new
                .nameSet(@"2017")
                .dataSet(@[@7.0, @6.9, @9.5, @14.5, @18.2, @21.5, @25.2, @26.5, @23.3, @18.3, @13.9, @9.6]),
             
        ]);
    [self.sleepView aa_drawChartWithChartModel:aaChartModel];
     
    self.changeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    self.changeBtn.backgroundColor = [UIColor blueColor];
    [self.changeBtn setTitle:@"修改数据" forState:UIControlStateNormal];
    [self.view addSubview:self.changeBtn];
    self.changeBtn.frame = CGRectMake(20, chartViewHeight +80, self.view.frame.size.width-40, 40);
    [ self.changeBtn addTarget:self action:@selector(clickChangeDataBtn:) forControlEvents:UIControlEventTouchUpInside];
}
 
//刷新数据
-(void)clickChangeDataBtn:(UIButton *)btn{
    NSArray* aaChartModelSeriesArray = @[
        AASeriesElement.new
            .dataSet(@[@0.2, @0.8, @5.7, @11.3, @17.0, @22.0, @24.8, @24.1, @20.1, @14.1, @8.6, @2.5])
    ];
    if(!btn.selected){
        aaChartModelSeriesArray = @[
            AASeriesElement.new
                .dataSet(@[@7.0, @6.9, @9.5, @14.5, @18.2, @21.5, @25.2, @26.5, @23.3, @18.3, @13.9, @9.6])
        ];
    }
    btn.selected = !btn.selected;
    [self.sleepView aa_onlyRefreshTheChartDataWithChartModelSeries:aaChartModelSeriesArray];
}
 
 
@end

 

posted @   码锋窝  阅读(114)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
历史上的今天:
2016-07-03 git与svn的区别-小结一下
点击右上角即可分享
微信分享提示