// // ZBSaleTrendVC.m // ZBProject // // Created by 学丽 on 2019/4/9. // Copyright © 2019 ZB. All rights reserved. // #import "ZBSaleTrendVC.h" @interface ZBSaleTrendVC () @property(nonatomic,strong) SSWLineChartView *barChartView; @property(nonatomic,copy)NSString *types; @end @implementation ZBSaleTrendVC - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor =[UIColor whiteColor]; self.types = @"1"; [self.view addSubview:self.barChartView]; [self.barChartView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self.view.mas_top).offset(20); make.left.mas_equalTo(10); make.right.mas_equalTo(-10); make.height.mas_offset(329); }]; [self OrderStatistics]; } -(SSWLineChartView *)barChartView { if (!_barChartView) { _barChartView =[[SSWLineChartView alloc]initWithChartType:SSWChartsTypeBar]; _barChartView.layer.cornerRadius=3; _barChartView.layer.masksToBounds=YES; _barChartView.backgroundColor = [UIColor whiteColor]; _barChartView.unit = @"单"; _barChartView.showEachYValus=NO; _barChartView.yScaleValue=100; __weak ZBSaleTrendVC *weakSelf = self; _barChartView.changeBtn = ^(UIButton *button) { if (button.tag == 1001) { weakSelf.types =@"1"; }else{ weakSelf.types = @"0"; } [weakSelf OrderStatistics]; }; } return _barChartView; } #pragma mark---订单统计 -(void)OrderStatistics { if (![AccountTool isLogin]) { return; } [LoadingView showInView:self.view]; [ZBHTTP post:getOrderStatisticsURL params:@{@"type":self.types} success:^(id _Nonnull json) { [LoadingView dismiss]; NSArray *resultA =(NSArray *)json; NSMutableArray *xArray=[NSMutableArray array]; NSMutableArray *valueArray =[NSMutableArray array]; for (NSDictionary *dics in resultA) { [xArray addObject:dics[@"time"]]; [valueArray addObject:dics[@"num"]]; } self.barChartView.xValuesArr = [xArray mutableCopy]; self.barChartView.yValuesArr=[valueArray mutableCopy]; } failure:^(NSError * _Nonnull error) { [LoadingView dismiss]; }]; } @end