// // StatisticsDataAnalysisDetailVC.m // IBOSS-HJ // // Created by 关宏厚 on 2020/12/30. // Copyright © 2020 elongtian. All rights reserved. // #import "StatisticsDataAnalysisDetailVC.h" #import "Util.h" #import "IntAxisValueFormatter.h" @interface StatisticsDataAnalysisDetailVC () { UIScrollView *scroll; UIView *content; UIView *detailContent; UILabel *lblDepartment; UILabel *lblTotalAmount; NSMutableArray *feeItemArray; NSMutableArray *yArray; CustomBorderView *detailBorderV; } @end @implementation StatisticsDataAnalysisDetailVC - (void)viewDidLoad { [super viewDidLoad]; feeItemArray=[[NSMutableArray alloc]init]; yArray=[[NSMutableArray alloc]init]; [self loadNavStyle]; [self initUI]; [self loadFeesDetailData]; } /** 导航按钮样式 */ -(void)loadNavStyle { self.navigationItem.title=@"费用情况明细"; //返回 UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; [button setBackgroundImage:[UIImage imageNamed:@"icon_back"] forState:UIControlStateNormal]; [button addTarget:self action:@selector(goBack) forControlEvents:UIControlEventTouchUpInside]; button.frame = CGRectMake(0, 0, 15, 18); UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button]; self.navigationItem.leftBarButtonItem = menuButton; } -(void)initUI { int rowHeight=50; content=[UIView new]; content.frame=CGRectMake(0, 0,Screen_Width,0); detailContent=[UIView new]; detailContent.frame=CGRectMake(10, 10,Screen_Width,0); detailContent.backgroundColor=[UIColor whiteColor]; scroll=[[UIScrollView alloc]init]; scroll.frame=CGRectMake(0,0, Screen_Width, Screen_Height); [self.view addSubview:scroll]; [scroll addSubview:content]; [content addSubview:detailContent]; UIView *detailTitleView = [[UIView alloc]init]; detailTitleView.frame = CGRectMake(0,0 ,Screen_Width, 45); UIView *detailImgView=[UIImageView new]; detailImgView.frame=CGRectMake(10, 10,10 , 25); [detailImgView setBackgroundColor:[UIColor hexColor:LIGHT_BROWN]]; [detailTitleView addSubview:detailImgView]; UILabel *titleDetail = [[UILabel alloc]init]; titleDetail.frame = CGRectMake(CGRectGetMaxX(detailImgView.frame)+10, 10, 100, 25); titleDetail.text = @"详细"; titleDetail.textColor = [UIColor blackColor]; titleDetail.font = [UIFont systemFontOfSize:NoDataFontOfSize]; [detailTitleView addSubview:titleDetail]; [detailContent addSubview:detailTitleView]; UIView *separator=[UIView new]; separator.frame=CGRectMake(0,detailTitleView.frame.size.height-1, detailTitleView.frame.size.width-20, 0.5); [separator setBackgroundColor:[UIColor lightGrayColor]]; [detailTitleView addSubview:separator ]; UIView *departmentView= [[UIView alloc]init]; departmentView.frame = CGRectMake(0,CGRectGetMaxY(detailTitleView.frame)+15, Screen_Width, 25); lblDepartment= [[UILabel alloc]init]; lblDepartment.frame = CGRectMake(0, 0,Screen_Width, 25); lblDepartment.textAlignment=NSTextAlignmentCenter; lblDepartment.textColor = [UIColor blackColor]; lblDepartment.font = [UIFont systemFontOfSize:NoDataFontOfSize]; [departmentView addSubview:lblDepartment]; [detailContent addSubview:departmentView]; UIView *totalView= [[UIView alloc]init]; totalView.frame = CGRectMake(0,CGRectGetMaxY(departmentView.frame)+15, Screen_Width, 25); lblTotalAmount= [[UILabel alloc]init]; lblTotalAmount.frame = CGRectMake(0, 0,Screen_Width, 25); lblTotalAmount.textAlignment=NSTextAlignmentCenter; lblTotalAmount.textColor = [UIColor blackColor]; lblTotalAmount.font = [UIFont systemFontOfSize:NoDataFontOfSize]; [totalView addSubview:lblTotalAmount]; [detailContent addSubview:totalView]; detailBorderV=[CustomBorderView new]; detailBorderV.frame=CGRectMake(5, CGRectGetMaxY(totalView.frame)+15,Screen_Width-30, 350); [detailBorderV setBackgroundColor:[UIColor whiteColor]]; [detailBorderV drawBoardLine:1 cornerRadius:2 color:[UIColor hexColor:@"D5CDCD"]]; [detailContent addSubview:detailBorderV]; _singleChartView=[[HorizontalBarChartView alloc]init]; _singleChartView.frame=CGRectMake(5, 5,detailBorderV.frame.size.width-10, 340); [detailBorderV addSubview:_singleChartView]; detailContent.frame=CGRectMake(10, 10,Screen_Width-20,CGRectGetMaxY(detailBorderV.frame)+10); detailContent.layer.cornerRadius=CornerRadius; CGFloat height=CGRectGetMaxY(detailContent.frame); content.frame=CGRectMake(0, 0,Screen_Width,height); scroll.contentSize = CGSizeMake(self.view.frame.size.width, height+rectStatusHeight+rectNavHeight+100); } -(void)loadFeesDetailData { NSString *urlStr = [NSString stringWithFormat:@"%@", ServerURL]; NSMutableDictionary *dict = [NSMutableDictionary dictionary]; [dict setObject:@"GetAccountFeeDetailReportDataIphone" forKey:@"Action"]; [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"]; [dict setObject:kkUserCode forKey:@"UserCode"]; [dict setObject:kkUserPwd forKey:@"UserPassword"]; [dict setObject:kkSessionKey forKey:@"SessionKey"]; [dict setObject:_accountMonth forKey:@"AccountMonth"]; [dict setObject:_typeId forKey:@"TypeID"]; [dict setObject:_organizationId forKey:@"OrganizationID"]; _feesDetailDownManager = [[ASIDownManager alloc] init]; _feesDetailDownManager.delegate = self; _feesDetailDownManager.onRequestSuccess = @selector(onFeesDetailLoadFinish:); _feesDetailDownManager.onRequestFail = @selector(onFeesDetailLoadFail:); [_feesDetailDownManager postHttpRequest:urlStr dic:dict path:nil fileName:nil]; } /** 销售利润加载完成 */ - (void)onFeesDetailLoadFinish:(ASIDownManager *)sender { // 取消进度条 // 服务器返回数据 RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr]; // 服务器返回数据状态值 int iStatus = resultModel.status; // 服务器返回数据消息 NSString *message = resultModel.message; [self stopLoading]; // 服务器返回数据状态值正确 if (iStatus == 0) { NSDictionary *result=(NSDictionary*)resultModel.result; NSArray *resultArray= [result objectForKey:@"Table"]; if(resultArray!=nil&&resultArray.count>0) { double totalFeeSum=0; NSDictionary *dic=[resultArray objectAtIndex:0]; NSString *organizationName=[dic objectForKey:@"OrganizationName"]; for(int i=0;imaximumValue) { maximumValue=yValue; } } return maximumValue; } /** 获取y轴最小值 */ -(double)getYAxisMinimumValue:(NSMutableArray*) yValueArray { double minimumValue=[[yValueArray objectAtIndex:0]doubleValue]; for(int i=1;i)formatter yAxisLabelCount:(NSInteger)count maximumValue:(double)maximumValue minimumValue:(double)minimumValue { barchartView.chartDescription.enabled = NO; barchartView.drawGridBackgroundEnabled = NO; barchartView.extraBottomOffset=20; barchartView.dragEnabled = NO; [barchartView setScaleEnabled:NO]; barchartView.pinchZoomEnabled = NO; barchartView.delegate = self; barchartView.drawBarShadowEnabled = NO; barchartView.drawValueAboveBarEnabled = YES; // barchartView.maxVisibleCount = 60; barchartView.legend.enabled=NO; ChartXAxis *xAxis = barchartView.xAxis; xAxis.labelPosition = XAxisLabelPositionBottom; xAxis.labelFont = [UIFont systemFontOfSize:10.f]; xAxis.drawAxisLineEnabled = NO; xAxis.granularity=1; xAxis.drawGridLinesEnabled = NO; xAxis.valueFormatter=formatter; ChartYAxis *leftAxis = barchartView.leftAxis; leftAxis.labelFont = [UIFont systemFontOfSize:10.f]; leftAxis.drawAxisLineEnabled =NO; leftAxis.granularity=1; leftAxis.drawGridLinesEnabled = NO; leftAxis.labelFont = [UIFont systemFontOfSize:10.f]; if(minimumValue<0) { leftAxis.axisMinimum = minimumValue; } else { leftAxis.axisMinimum = 0; } leftAxis.axisMaximum=maximumValue+100; ChartYAxis *rightAxis = barchartView.rightAxis; rightAxis.enabled = YES; rightAxis.labelFont = [UIFont systemFontOfSize:10.f]; rightAxis.drawAxisLineEnabled = YES; rightAxis.drawGridLinesEnabled = NO; if(minimumValue<0) { rightAxis.axisMinimum = minimumValue; } else { rightAxis.axisMinimum = 0; } rightAxis.axisMaximum=maximumValue+100; rightAxis.granularity=1; rightAxis.drawGridLinesEnabled = YES; // ChartLegend *l = _singleChartView.legend; // l.horizontalAlignment = ChartLegendHorizontalAlignmentLeft; // l.verticalAlignment = ChartLegendVerticalAlignmentBottom; // l.orientation = ChartLegendOrientationHorizontal; // l.drawInside = NO; // l.form = ChartLegendFormSquare; // l.formSize = 8.0; // l.font = [UIFont fontWithName:@"HelveticaNeue-Light" size:11.f]; // l.xEntrySpace = 4.0; barchartView.fitBars = YES; double barWidth = 0.6; NSMutableArray *yVals = [[NSMutableArray alloc] init]; for (int i = 0; i < barchartArray.count; i++) { [yVals addObject:[[BarChartDataEntry alloc] initWithX:i y:[[barchartArray objectAtIndex:i]doubleValue] icon: [UIImage imageNamed:@"icon"]]]; } BarChartDataSet *set1 = nil; if (barchartView.data.dataSetCount > 0) { set1 = (BarChartDataSet *)barchartView.data.dataSets[0]; [set1 replaceEntries:yVals]; [barchartView.data notifyDataChanged]; [barchartView notifyDataSetChanged]; } else { set1 = [[BarChartDataSet alloc] initWithEntries:yVals label:@"DataSet"]; [set1 setColor: [UIColor colorWithRed:70/255.0f green:116/255.0f blue:193/255.0f alpha:1]]; set1.drawIconsEnabled = NO; NSMutableArray *dataSets = [[NSMutableArray alloc] init]; [dataSets addObject:set1]; BarChartData *data = [[BarChartData alloc] initWithDataSets:dataSets]; [data setValueFont:[UIFont fontWithName:@"HelveticaNeue-Light" size:10.f]]; data.barWidth = barWidth; barchartView.data = data; } } @end