From 3e8437ae559487362fae3525beb79c534c213a51 Mon Sep 17 00:00:00 2001
From: 单军华
Date: Thu, 12 Jul 2018 13:44:34 +0800
Subject: [PATCH] bug修复和功能优化

---
 screendisplay/screendisplay/Classes/检测/Controller/DynamicViewController.m |  120 ++++++++++++++++++++++++++++++++---------------------------
 1 files changed, 65 insertions(+), 55 deletions(-)

diff --git "a/screendisplay/screendisplay/Classes/\346\243\200\346\265\213/Controller/DynamicViewController.m" "b/screendisplay/screendisplay/Classes/\346\243\200\346\265\213/Controller/DynamicViewController.m"
index 0615833..3e346cf 100644
--- "a/screendisplay/screendisplay/Classes/\346\243\200\346\265\213/Controller/DynamicViewController.m"
+++ "b/screendisplay/screendisplay/Classes/\346\243\200\346\265\213/Controller/DynamicViewController.m"
@@ -41,14 +41,14 @@
     
     self.view.backgroundColor = kUIColorFromRGB(0x0b2f76);
     
-    UIImageView * viewBackground = [[UIImageView alloc] initWithFrame:CGRectMake((SCREEN_WIDTH-AdaptedWidth(355))/2, NavBar_Height+AdaptedHeight(26), AdaptedWidth(355), AdaptedHeight(354+26+20+13+5+10+5))];
+    UIImageView * viewBackground = [[UIImageView alloc] initWithFrame:CGRectMake(AdaptedWidth(5), NavBar_Height+AdaptedHeight(26), SCREEN_WIDTH-AdaptedWidth(10), AdaptedHeight(354+26+30+13+5+10+5))];
     viewBackground.image = [UIImage imageNamed:@"dynamic_back"];
     [self.view addSubview:viewBackground];
     
     // 2, ���������������������
     CGSize aSize = CGSizeMake(kScreenWidth - 20, INFINITY);
-    
-    NSMutableAttributedString *attStrM0 = [[NSMutableAttributedString alloc] initWithString:@"PM2.5���������������" attributes:@{NSFontAttributeName : AdaptedFontSize(14), NSForegroundColorAttributeName : [UIColor whiteColor]}];
+   
+    NSMutableAttributedString *attStrM0 = [[NSMutableAttributedString alloc] initWithString: [NSString stringWithFormat:@"%@���������������",self.detailModel.name] attributes:@{NSFontAttributeName : AdaptedFontSize(14), NSForegroundColorAttributeName : [UIColor whiteColor]}];
     attStrM0.yy_lineSpacing = 10;
     YYTextLayout *layout = [YYTextLayout layoutWithContainerSize:aSize text:attStrM0];
     
@@ -58,11 +58,11 @@
     titelLabel.textLayout = layout;
     [self.view addSubview:titelLabel];
     
-    UIImageView * icon_circle = [[UIImageView alloc] initWithFrame:CGRectMake((SCREEN_WIDTH-layout.textBoundingSize.width)/2-10-10, NavBar_Height+AdaptedHeight(26+13+5), AdaptedWidth(10), AdaptedHeight(10))];
+    UIImageView * icon_circle = [[UIImageView alloc] initWithFrame:CGRectMake((SCREEN_WIDTH-layout.textBoundingSize.width)/2-10-10, NavBar_Height+AdaptedHeight(26+13+3), AdaptedWidth(10), AdaptedHeight(10))];
     icon_circle.image = [UIImage imageNamed:@"icon_circle"];
     [self.view addSubview:icon_circle];
 
-    UIImageView * icon_arrow = [[UIImageView alloc] initWithFrame:CGRectMake((SCREEN_WIDTH-layout.textBoundingSize.width)/2+layout.textBoundingSize.width+10, NavBar_Height+AdaptedHeight(26+13+5), AdaptedWidth(10), AdaptedHeight(10))];
+    UIImageView * icon_arrow = [[UIImageView alloc] initWithFrame:CGRectMake((SCREEN_WIDTH-layout.textBoundingSize.width)/2+layout.textBoundingSize.width+10, NavBar_Height+AdaptedHeight(26+13+3), AdaptedWidth(10), AdaptedHeight(10))];
     icon_arrow.image = [UIImage imageNamed:@"icon_arrow"];
     [self.view addSubview:icon_arrow];
     
@@ -131,7 +131,7 @@
 -(void)drawHistoryRecordLine
 {
     /*     Create object        */
-    _historyRecordLineChart = [[JHLineChart alloc] initWithFrame:CGRectMake(AdaptedWidth(10), NavBar_Height+AdaptedHeight(39+50), SCREEN_WIDTH-AdaptedWidth(20), AdaptedHeight(354)) andLineChartType:JHChartLineEveryValueForEveryX];
+    _historyRecordLineChart = [[JHLineChart alloc] initWithFrame:CGRectMake(AdaptedWidth(15), NavBar_Height+AdaptedHeight(39+50), SCREEN_WIDTH-AdaptedWidth(20), AdaptedHeight(354)) andLineChartType:JHChartLineEveryValueForEveryX];
     
     /* The scale value of the X axis can be passed into the NSString or NSNumber type and the data structure changes with the change of the line chart type. The details look at the document or other quadrant X axis data source sample.*/
     
@@ -141,7 +141,7 @@
     
     _historyRecordLineChart.lineChartQuadrantType = JHLineChartQuadrantTypeFirstQuardrant;
     
-    _historyRecordLineChart.lineWidth = 3.0;
+    _historyRecordLineChart.lineWidth = 2.0;
     _historyRecordLineChart.valueArr = [NSMutableArray array];
     NSMutableArray * valueTeampArr = [[NSMutableArray alloc] init];
     for (int i = 0; i < self.dynamicService.dynamicViewModels.count; i++)
@@ -162,42 +162,53 @@
     _historyRecordLineChart.showValueLeadingLine = NO;
     //_historyRecordLineChart.showYLine = NO;
 
-    if( [StringUtil isPureInt:self.detailModel.upper] || [StringUtil��isPureFloat:self.detailModel.upper])
+    if( [StringUtil isPureInt:self.detailModel.upper] || [StringUtil isPureFloat:self.detailModel.upper])
     {
-        _historyRecordLineChart.yLineDataArr  = [NSMutableArray array];
-        float fMaxValue = [self.detailModel.upper floatValue];
-        float fMinValue = 0;//[self.detailModel.lower floatValue];
-        float fOffSetValue = fMaxValue - fMinValue;
-        float fAvgValue = fOffSetValue / 9;
-        int fCurrentValue = fAvgValue;
-        for (int index = 0; index < 10; index++)
+        if([self.detailModel.upper intValue] <= 1)
         {
-            if (index == 0)
-            {
-                fCurrentValue = fAvgValue;
-            }
-            else if(index == 9)
-            {
-                fCurrentValue = fMaxValue;
-            }
-            else
-            {
-                fCurrentValue = fCurrentValue+fAvgValue;
-            }
-            
-            NSString * currentStr = @"";
-            if(fCurrentValue < 0)
-            {
-                currentStr = [NSString stringWithFormat:@"-%d",fCurrentValue];
-            }
-            else
-            {
-                currentStr = [NSString stringWithFormat:@"%d",fCurrentValue];
-            }
-            
-            [_historyRecordLineChart.yLineDataArr addObject:currentStr];
+            _historyRecordLineChart.yLineDataArr  = @[@"0.1",@"0.2",@"0.3",@"0.4",@"0.5",@"0.6",@"0.7",@"0.8",@"0.9",@"1"];
         }
-        
+        else
+        {
+            _historyRecordLineChart.yLineDataArr  = [NSMutableArray array];
+            float fMaxValue = [self.detailModel.upper floatValue];
+            if( fMaxValue < [self.detailModel.value floatValue])
+            {
+                fMaxValue = [self.detailModel.value floatValue];
+            }
+            
+            float fMinValue = 0;//[self.detailModel.lower floatValue];
+            float fOffSetValue = fMaxValue - fMinValue;
+            float fAvgValue = fOffSetValue / 9;
+            int fCurrentValue = fAvgValue;
+            for (int index = 0; index < 10; index++)
+            {
+                if (index == 0)
+                {
+                    fCurrentValue = fAvgValue;
+                }
+                else if(index == 9)
+                {
+                    fCurrentValue = fMaxValue;
+                }
+                else
+                {
+                    fCurrentValue = fCurrentValue+fAvgValue;
+                }
+                
+                NSString * currentStr = @"";
+                if(fCurrentValue < 0)
+                {
+                    currentStr = [NSString stringWithFormat:@"-%d",fCurrentValue];
+                }
+                else
+                {
+                    currentStr = [NSString stringWithFormat:@"%d",fCurrentValue];
+                }
+                
+                [_historyRecordLineChart.yLineDataArr addObject:currentStr];
+            }
+        }
     }
    else
    {
@@ -206,11 +217,12 @@
 
     // ������������
     /* Line Chart colors ������������ */
-    _historyRecordLineChart.valueLineColorArr =@[RgbColor(143, 246, 218)];
+    _historyRecordLineChart.valueLineColorArr =@[RgbColor(255, 255, 255)];
     /* Colors for every line chart ������������������*/
     _historyRecordLineChart.pointColorArr = @[RgbColor(36, 209, 215)];
     
-    
+    _historyRecordLineChart.xyFontSize = AdaptedWidth(7);
+    _historyRecordLineChart.numberFontSize = AdaptedWidth(10);
     /* color for XY axis XY������������������*/
     _historyRecordLineChart.xAndYLineColor = kUIColorFromRGB(0x00fcff);
     /* XY axis scale color XY������������������������*/
@@ -218,7 +230,7 @@
     /* Dotted line color of the coordinate point */
     _historyRecordLineChart.positionLineColorArr = @[RgbColor(255, 255, 255)];
     /*  ������������������������*/
-    _historyRecordLineChart.pointNumberColorArr = @[[UIColor orangeColor]];
+    _historyRecordLineChart.pointNumberColorArr = @[RgbColor(255, 255, 255)];
     /*        Set whether to fill the content, the default is False   ������������������������������      */
     _historyRecordLineChart.contentFill = NO;
     /*        Set whether the curve path         */
@@ -241,7 +253,7 @@
 
 -(void)updateDynamicData
 {
-    [self GetDynamicDataList:1];
+    //[self GetDynamicDataList:1];
 }
 
 -(void)GetDynamicDataList:(int)pageSize
@@ -257,23 +269,21 @@
         {
             if( pageSize > 1)
             {
-                [self drawHistoryRecordLine];
+                [weakself drawHistoryRecordLine];
             }
             else if(pageSize == 1)
             {
-                NSMutableArray * historyRecordArr = [weakself.historyRecordLineChart.valueArr objectAtIndex:0];
-                for (NSInteger i = 0; i < self.dynamicService.dynamicViewModels.count-1; i++)
+                NSMutableArray * valueTeampArr = [[NSMutableArray alloc] init];
+                for (int i = 0; i < self.dynamicService.dynamicViewModels.count; i++)
                 {
-                    [historyRecordArr replaceObjectAtIndex:i withObject:[historyRecordArr objectAtIndex:(i+1)]];
-                }                
+                    DynamicModel * model = [self.dynamicService.dynamicViewModels objectAtIndex:i];
+                    
+                    [valueTeampArr addObject:model.value];
+                }
                 
-                [historyRecordArr replaceObjectAtIndex:self.dynamicService.dynamicViewModels.count-1 withObject: self.dynamicService.dynamicViewModel.value];
-                
+                [weakself.historyRecordLineChart.valueArr removeAllObjects];
+                [weakself.historyRecordLineChart.valueArr addObject:valueTeampArr];
                 [weakself.historyRecordLineChart clearLine];
-                
-//                [weakself.historyRecordLineChart.xLineDataArr removeAllObjects];
-//                [weakself.historyRecordLineChart.xLineDataArr addObjectsFromArray:self.dynamicService.dynamicViewModels];
-//                [weakself.historyRecordLineChart clearLine];
             }
         }
         else

--
Gitblit v1.8.0