// // NewStepChartCell.m // tongxin // // Created by Apple on 2020/4/10. // Copyright © 2020 xTT. All rights reserved. // #import "NewStepChartCell.h" #import "UILabel+BezierAnimation.h" #import "FBYLineGraphView.h" @interface NewStepChartCell() /// 折线图 @property (strong, nonatomic)FBYLineGraphView *LineGraphView; @end @implementation NewStepChartCell - (void)awakeFromNib { [super awakeFromNib]; self.selectionStyle = UITableViewCellSelectionStyleNone; self.todayTitleLabel.text = GJText(@"今日步数"); self.zTitleLable.text = GJText(@"最近一周记步数"); } - (void)setLineGraphView_DayWeekWithData:(NSArray*)dataList { if (_LineGraphView) { [_LineGraphView removeFromSuperview]; } // 初始化折线图 _LineGraphView = [[FBYLineGraphView alloc] initWithFrame:CGRectMake(0 , 0, _lineChartContentView.size.width, _lineChartContentView.size.height)]; [self.lineChartContentView addSubview:_LineGraphView]; // 设置折线图属性 // _LineGraphView.title = @"周统计图"; // 折线图名称 _LineGraphView.X_UnintTitle = GJText(@"时间(日)"); _LineGraphView.MainColor = KKMainColor; _LineGraphView.maxValue = 15000; // Y轴最大值 _LineGraphView.Ycount = 6; // Y轴分割个数(包含0在内的) _LineGraphView.XYAxisColor = [UIColor lightGrayColor]; NSMutableArray *tempDataList = [NSMutableArray array]; for (StepModel* item in dataList) { NSMutableDictionary *tempDic = [NSMutableDictionary dictionary]; NSDateFormatter*dateFormatter = [[NSDateFormatter alloc]init]; [dateFormatter setDateFormat:@"yyyy-MM-dd"]; // NSString *dayStr = [myHelper getDateFormatWithStr:@"yyyy-MM-dd" date:[NSDate dateWithTimeIntervalSince1970:item.timestamp.doubleValue]]; NSNumber *newTimeNumber = @([dateFormatter dateFromString:item.createTime].timeIntervalSince1970); [tempDic setValue:newTimeNumber forKey:@"timestamp"]; [tempDic setValue:@(item.walksNum) forKey:@"data"]; [tempDataList addObject:tempDic]; } [_LineGraphView setXMarkTitlesDayAndValues:tempDataList titleKey:@"timestamp" valueKey:@"data"]; // X轴刻度标签及相应的值 //LineGraphView.xScaleMarkLEN = 60; //设置完数据等属性后绘图折线图 [_LineGraphView mapping]; } /// 设置计步数组 绘制统计图 -(void)setStepDataList:(NSArray*)dataList WithTodayData:(NSInteger)todayData { [_todayLable animationFromnum:0 toNum:todayData duration:0.5 precision:@"%d"]; [self setLineGraphView_DayWeekWithData:dataList]; } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } @end