历史流量记录改版

This commit is contained in:
wbzhan
2019-09-11 10:51:36 +08:00
parent b871a24c4e
commit 672e8cf92f
11 changed files with 199 additions and 142 deletions
+138 -55
View File
@@ -10,11 +10,12 @@
#import "IfishHistroyVo.h"
#define Normal_heaterPh 499 //只有499才是正常流量
#define Rect_Width kSizeFrom750(568)
#define Origin_Left kSizeFrom750(72)
#define Rect_Height kSizeFrom750(185)
#define Rect_Width kSizeFrom750(599)
#define Origin_Left kSizeFrom750(59)
#define Rect_Height kSizeFrom750(420)
#define Zero_Y kSizeFrom750(526)
@interface IfishChatView()
@property(nonatomic,strong)NSMutableArray*line1;
@property(nonatomic,strong)NSMutableArray*line1;//水温
@property(nonatomic,strong)UIView *lablesView;
@property(nonatomic,strong)UILabel*numLable;
Strong NSMutableArray * heaterPhArray;//流量走势
@@ -39,73 +40,76 @@ Strong NSMutableArray * heaterPhArray;//流量走势
[_line1 removeAllObjects];
if (_datas.count) {
// CGFloat gapW= 357*scale*0.1;
for (int i=0; i<self.datas.count; i++) {
IfishHistroyVo*vo=self.datas[i];
CGFloat x=Origin_Left +([vo.heaterGatheringTime floatValue]/24)*Rect_Width;
CGFloat x=Origin_Left +([vo.heaterGatheringTime floatValue]/24.f)*Rect_Width;
if(vo.heaterWaterTemperature.integerValue>350){
vo.heaterWaterTemperature=@"350";
}else if(vo.heaterWaterTemperature.integerValue<250){
continue;
}
CGFloat y=Rect_Height*(1-((vo.heaterWaterTemperature.integerValue*0.1-25)/10))+kSizeFrom750(43);//*-1*+158;
CGFloat y=Rect_Height*(1-((vo.heaterWaterTemperature.integerValue*0.1-25)/10))+kSizeFrom750(105);//
CGPoint p1=CGPointMake(x, y);
// NSLog(@"%f-------%f--%f-",y,vo.heaterWaterTemperature.integerValue*0.1,x);
[_line1 addObject:NSStringFromCGPoint(p1)];
}
}
return _line1;
}
-(void)setDatas:(NSArray *)datas{
-(void)loadDatasWithArray:(NSArray *)dataArray{
NSSortDescriptor *ageSD = [NSSortDescriptor sortDescriptorWithKey:@"heaterGatheringTime_int" ascending:YES];
datas = [datas sortedArrayUsingDescriptors:@[ageSD]];
_datas=datas;
dataArray = [dataArray sortedArrayUsingDescriptors:@[ageSD]];
_datas=dataArray;
[self layoutIfNeeded];
}
-(NSMutableArray *)heaterPhArray{
if (!_heaterPhArray) {
_heaterPhArray = InitObject(NSMutableArray);
//添加流量
for (int i=0; i<23; i++) {
CGFloat x=(i*(Rect_Width/24)+Origin_Left);
CGFloat y=kSizeFrom750(236);
UIView *lineView = [[UIView alloc] initWithFrame:RECT(x, y, Rect_Width/24, 1)];
lineView.tag = i+100;
[self addSubview:lineView];
[_heaterPhArray addObject:lineView];
}
}
return _heaterPhArray;
}
//刷新流量状态
-(void)reloadHeater{
for (UIView *view in self.heaterPhArray) {
[view.layer removeAllAnimations];
}
for (int i=0; i<self.datas.count-1; i++) {
IfishHistroyVo*vo=self.datas[i];
IfishHistroyVo*nextVo=self.datas[i+1];
//如果有时间段的数据拿不到,则直接使用虚线
if ([nextVo.heaterGatheringTime integerValue]-[vo.heaterGatheringTime integerValue]>1) {
for (int i=[vo.heaterGatheringTime intValue]; i<[nextVo.heaterGatheringTime intValue]; i++) {
UIView *emptyView = [self viewWithTag:i+100];
[self drawDashLine:emptyView lineLength:2 lineSpacing:1 lineColor:[UIColor redColor]];
}
}else{
UIView *lineView = [self viewWithTag:[vo.heaterGatheringTime integerValue]+100];
if([vo.heaterPh integerValue]==Normal_heaterPh&&[nextVo.heaterPh integerValue]==Normal_heaterPh){//正常流量
lineView.layer.backgroundColor = [UIColor greenColor].CGColor;
}else{
[self drawDashLine:lineView lineLength:2 lineSpacing:1 lineColor:[UIColor redColor]];
}
}
}
}
//-(NSMutableArray *)heaterPhArray{
// if (!_heaterPhArray) {
// _heaterPhArray = InitObject(NSMutableArray);
// //添加流量
// for (int i=0; i<23; i++) {
// CGFloat x=(i*(Rect_Width/24)+Origin_Left);
// CGFloat y=kSizeFrom750(315);
// UIView *lineView = [[UIView alloc] initWithFrame:RECT(x, y, Rect_Width/24.f, 1)];
// lineView.tag = i+100;
// [self addSubview:lineView];
// [_heaterPhArray addObject:lineView];
// }
// }
// return _heaterPhArray;
//}
////刷新流量状态
//-(void)reloadHeater{
// for (UIView *view in self.heaterPhArray) {
// [view.layer removeAllAnimations];
// }
//
// for (int i=0; i<self.datas.count-1; i++) {
// IfishHistroyVo*vo=self.datas[i];
// IfishHistroyVo*nextVo=self.datas[i+1];
// //如果有时间段的数据拿不到,则直接使用虚线
// if ([nextVo.heaterGatheringTime integerValue]-[vo.heaterGatheringTime integerValue]>1) {
// for (int i=[vo.heaterGatheringTime intValue]; i<[nextVo.heaterGatheringTime intValue]; i++) {
// UIView *emptyView = [self viewWithTag:i+100];
// [self drawDashLine:emptyView lineLength:2 lineSpacing:1 lineColor:[UIColor redColor]];
// }
// }else{
// UIView *lineView = [self viewWithTag:[vo.heaterGatheringTime integerValue]+100];
// if([vo.heaterPh integerValue]==Normal_heaterPh&&[nextVo.heaterPh integerValue]==Normal_heaterPh){//正常流量
// lineView.layer.backgroundColor = [UIColor greenColor].CGColor;
//
// }else{
// [self drawDashLine:lineView lineLength:2 lineSpacing:1 lineColor:[UIColor redColor]];
// }
// }
// }
//}
-(void)drawLine{
if (self.datas==nil) {
return;
}
//1、水温线
UIColor *color = [UIColor redColor];
[color set]; //设置线条颜色
@@ -124,9 +128,88 @@ Strong NSMutableArray * heaterPhArray;//流量走势
[path addLineToPoint:CGPointFromString(p)];
}
// [path closePath];//第五条线通过调用closePath方法得到的
[path stroke];//Draws line 根据坐标点连线
//每个圆点大小
for (int i=0; i<self.line1.count; i++) {
NSString* p=self.line1[i];
CGPoint point=CGPointFromString(p);
UIBezierPath *path0 = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(point.x-kSizeFrom750(4), point.y-kSizeFrom750(4), kSizeFrom750(8), kSizeFrom750(8)) cornerRadius:kSizeFrom750(4)];
[path0 stroke];
[path0 fill];
}
//2、流量线(如果该时间点没有数据,则默认为无水)
UIColor *color1 = [UIColor blueColor];
[color1 set]; //设置线条颜色
UIBezierPath* path1 = [UIBezierPath bezierPath];
path1.lineWidth = 1.0;
path1.lineCapStyle = kCGLineCapRound; //线条拐角
path1.lineJoinStyle = kCGLineJoinRound; //终点处理
// Draw the lines
//两个时间点之间如果有空余时间点,则该点为缺失点,要添加上去
for (int i=0; i<self.datas.count; i++) {
IfishHistroyVo*vo=self.datas[i];
CGFloat x=Origin_Left +([vo.heaterGatheringTime floatValue]/24.f)*Rect_Width;
CGFloat y=kSizeFrom750(315);
if ([vo.heaterPh integerValue]!=Normal_heaterPh) {
y = Zero_Y;
}
//正常的点
CGPoint p2=CGPointMake(x, y);
if (i==0) {
[path1 moveToPoint:p2];//起点
}else{
[path1 addLineToPoint:p2];
}
if (i<self.datas.count-1) {
IfishHistroyVo * nextVo = self.datas[i+1];
NSInteger hour1 = [vo.heaterGatheringTime integerValue];
NSInteger hour2 = [nextVo.heaterGatheringTime integerValue];
if (hour2-hour1>1) {
for (int j=hour1+1; j<hour2; j++) {
CGPoint zeroPoint1 = CGPointMake(Origin_Left+j/24.f*Rect_Width, Zero_Y);//无流量的点连线
[path1 addLineToPoint:zeroPoint1];
}
}
}
}
[path1 stroke];//颜色填充
//添加流量点位
for (int i=0; i<self.datas.count; i++) {
IfishHistroyVo*vo=self.datas[i];
CGFloat x=Origin_Left +([vo.heaterGatheringTime floatValue]/24.f)*Rect_Width;
CGFloat y=kSizeFrom750(315);
if ([vo.heaterPh integerValue]!=Normal_heaterPh) {
y = Zero_Y;
}
CGPoint point=CGPointMake(x, y);
if (i<self.datas.count-1) {
IfishHistroyVo * nextVo = self.datas[i+1];
NSInteger hour1 = [vo.heaterGatheringTime integerValue];
NSInteger hour2 = [nextVo.heaterGatheringTime integerValue];
if (hour2-hour1>1) {
for (int j=hour1+1; j<hour2; j++) {
CGPoint zeroPoint1 = CGPointMake(Origin_Left+j/24.f*Rect_Width, Zero_Y);//无流量的点
UIBezierPath *pathzero = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(zeroPoint1.x-kSizeFrom750(4), zeroPoint1.y-kSizeFrom750(4), kSizeFrom750(8), kSizeFrom750(8)) cornerRadius:kSizeFrom750(4)];
[pathzero stroke];
[pathzero fill];
}
}
}
UIBezierPath *path01 = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(point.x-kSizeFrom750(4), point.y-kSizeFrom750(4), kSizeFrom750(8), kSizeFrom750(8)) cornerRadius:kSizeFrom750(4)];
[path01 stroke];
[path01 fill];
}
[path stroke];//Draws line 根据坐标点连线
}
/**