import 'package:fl_chart/fl_chart.dart';
//import 'package:flustars/flustars.dart';
import 'package:flutter/material.dart';
import 'package:flutter_echarts/flutter_echarts.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:hyzp_ybqx/components/commonFun.dart';
import 'package:hyzp_ybqx/components/dioFun.dart';
import 'package:hyzp_ybqx/components/doJSON.dart';
import 'package:hyzp_ybqx/components/hyxx_data_handle.dart';
import 'package:hyzp_ybqx/pages/Works/TJXX/tj_data.dart';
import 'package:hyzp_ybqx/widget/DropdownItem.dart';

import '../../../services/EventBus.dart';

class ZptjBarEchartsTrinityNewGetData {
  static const Color red = const Color(0xffff5182);
  static const Color blue = const Color(0xff0000ff);

  static const Color firstBarColor = const Color(0xffff5182);
  static const Color secondBarColor = const Color.fromRGBO(0, 150, 150, 1);
  static const Color thirdBarColor = const Color(0xff00000f);

  // static const Color firstBarColor = const Color.fromRGBO(200, 55, 55, 1);
  // static const Color secondBarColor = const Color.fromRGBO(100, 170, 170, 1);
  // static const Color thirdBarColor = const Color.fromRGBO(45, 45, 45, 1);

  static const Color bottomBarColor = const Color(0xff939393);
  static const Color gridColor = const Color(0xffe7e8ec);
  static const double width = 7;
  static const double widthTrinity = 1;

  String _textBottom1;
  String _textBottom2;
  String _textTop1;
  String _textTop2;
  int _rate = 10; // today 字段放大倍率
  int _rateCoord = 10000; // 坐标压缩倍率
  int _interval = 20; // 坐标间隔
  int _maxY = -1;

  List<BarChartGroupData> _listBarData = [];

  int nDwbh = 0; // 点位编号，0代表所有点位，其他数字对应其他点位编号

  ZptjBarEchartsTrinityNewGetData() {
    cllRStatisDataGeting = true;
    print('cllRStatisDataOk = ${cllRStatisDataOk}');

    ///获取点位信息数据
    if (!cllRStatisDataOk) {
      //listCllrtjStatis 中的数据未准备好
      listCllrtjStatis.clear(); //最后需要显示的数据
      // 获得前 31 天的日期起点和终点：['2021-03-18', '2021-04-17']
      List _listDateDuration = getLast31DateString();
      mapStatisType['cllrtj']['startDate'] = _listDateDuration[0];
      mapStatisType['cllrtj']['endDate'] = _listDateDuration[1];
    }

    if (listCllrtjStatis.isEmpty) {
      if (listDwinfoGetList2.isEmpty) {
        //若没有读取点位数据，便需要先读取
        getThePageList(theHyshlx: 'dwxx').then((value) {
          listDwinfoGetList2 = value;
          print('listDwinfoGetList2 = \n$listDwinfoGetList2');
          getCllrtjStatisNew('cllrtj').then((value) {
            //按 sortField 升序排序
            //listCllrtjStatis.sort((a, b) => (a['dwbh']).compareTo(b['dwbh']));
            getEchartsOptionData().then((value) {
              updateEchartsAndTable(); //刷新页面数据
            });
          });

          // getCllrtjStatis('cllrtj').then((value) {
          //   //按 sortField 升序排序
          //   listCllrtjStatis.sort((a, b) => (a['dwbh']).compareTo(b['dwbh']));
          //   getEchartsOptionData().then((value) {
          //     updateEchartsAndTable(); //刷新页面数据
          //   });
          // });
        });
      } else {
        //若已经读取了点位数据，便直接使用
        print('listDwinfoGetList2 = \n$listDwinfoGetList2');
        getCllrtjStatisNew('cllrtj').then((value) {
          //按 sortField 升序排序
          //listCllrtjStatis.sort((a, b) => (a['dwbh']).compareTo(b['dwbh']));
          getEchartsOptionData().then((value) {
            updateEchartsAndTable(); //刷新页面数据
          });
        });
      }
    } else {
      updateEchartsAndTable(); //刷新页面数据
    }

    // //监听 选择LED点位 更新事件
    // eventBus.on<SelectLedDwUpdateEvent>().listen((event) async {
    //   print(event.str);
    //
    //   //获取用户选择项对应的id号
    //   int id = listItems.indexOf(event.selectedValue);
    //   print('SelectLedDwUpdateEvent: id = ${id}, nDwbh = ${nDwbh}');
    //   if (id != nDwbh) {
    //     nDwbh = id;
    //     updateEchartsAndTable(bFirst: false); //刷新页面数据
    //   }
    // });
  }

  Future updateEchartsAndTable({bool bFirst = true}) {
    if (bFirst) {
      getListFlields(); //更新_listItems内容
    }
    replaceEchartsOptionData(bFirst: bFirst).then((value) {
      cllRStatisDataOk = true;
      cllRStatisDataGeting = false;
      eventBus.fire(SelectLedDwUpdateEvent('Dropdown选项已改变', nDwbh.toString()));
      //try_setState();
    });
  }

  //LED点位名称List，除第一项外，后面都按ID号排列
  List listItems = [
    // '全部',
    // '1、江北振兴大道',
    // '2、宜飞路',
    // '3、宜宾南收费站',
    // '4、一曼路',
    // '5、柏溪收费站',
    // '6、七星路万达广场',
    // '7、宜宾财政局',
    // '8、宜威路南广镇',
    // '9、宜长路',
    // '10、宜南快速通道',
    // '11、观斗山隧道',
    // '12、大麦坝',
    // '13、外江路',
  ];

  //更新_listItems内容
  Future getListFlields() async {
    listItems = ['全部'];
    int len = listDwinfoGetList2.length;
    for (int i = 0; i < len; i++) {
      listItems.add('${i + 1}.' + listDwinfoGetList2[i]['dwmc']);
    }
    print('_listItems = $listItems');

    //_title = '${widget.title}（${widget.id.toString()} / ${listDwinfoGetList2.length}）';
    //try_setState();
  }

  //1、得到选择LED点位组件
  Widget getSelectLedDw() {
    return Container(
      padding: EdgeInsets.only(top: ScreenUtil().setHeight(11)),
      alignment: Alignment.centerLeft,
      child: DropdownItem(
        listItems: listItems,
        //初始值 initValue 必须是 listItems 中的已有元素
        initValue: listItems[0],
        dropdownEvent: 'SelectLedDwUpdateEvent',
        width: ScreenUtil().setWidth(500),
        height: 35,
      ), //SizedBox(width: _marginLeft),
    );
  }

  String strDateNew = 'data: ['; // 全部 和 13 个点位都相同
  List listStrFlowNew = [];
  List listStrAmRushNew = [];
  List listStrPmRushNew = [];

  // 所有点位 31 天的车流量日统计数据，每天有 3 个数据：车流量、早高峰、晚高峰
  Map mapAllDw = {}; // 有 31 个元素，每个元素又是一个 Map：包含车流量、早高峰、晚高峰

  // 从 listCllrtjStatis 中获取的车流量日统计数据
  Future getEchartsOptionData() async {
    // 读取 13 个点位车流量日统计数据的循环
    int j = -1;
    for (Map mapDw in listCllrtjStatis) {
      List listCllmx = mapDw["cllmx"];
      String strFlowList2 = 'data: [';
      String strAmRushList2 = 'data: [';
      String strPmRushList2 = 'data: [';

      // 读取每个点位 31 天的车流量日统计数据的循环。反序遍历
      int len = listCllmx.length;
      print('len = $len');
      j++;
      for (int i = len - 1; i > -1; i--) {
        Map mapDay = listCllmx[i];

        if (0 == j) {
          // 第一次处理点位数据时添加 listAllDw 的元素
          mapAllDw[mapDay["day"]] = {
            "all": 0,
            "am": 0,
            "pm": 0
          }; //有 31 个元素，每个元素又是一个 Map：包含车流量、早高峰、晚高峰
        }

        //print(mapDay);
        //print('mapDay = ${mapDay}, len = ${mapDay.length}');
        //mapDay = {day: 2021-05-19, am_order: 0730:0930, pm_order: 1730:1930, all: null, am: null, pm: null}, len = 6
        //mapDay = {day: 2021-05-09, am_order: 0730:0930, pm_order: 1730:1930, all: null, am: null, pm: null}, len = 6
        //print('mapDay["all"] = ${mapDay["all"]}, len = ${mapDay["all"].length}');
        //Unhandled Exception: NoSuchMethodError: The getter 'length' was called on null.

        if (0 == j) {
          // 第一次处理点位数据时添加
          strDateNew += getStrMonthDay(mapDay["day"]); // 获取日字符串
        }

        strFlowList2 += (null == mapDay["all"] ? '0' : mapDay["all"]) + ', '; // 获取车流量日统计数据字符串
        mapAllDw[mapDay["day"]]["all"] += null == mapDay["all"] ? 0 : int.parse(mapDay["all"]);

        strAmRushList2 += (null == mapDay["am"] ? '0' : mapDay["am"]) + ', '; // 获取早高峰统计数据字符串
        mapAllDw[mapDay["day"]]["am"] += null == mapDay["am"] ? 0 : int.parse(mapDay["am"]);

        strPmRushList2 += (null == mapDay["pm"] ? '0' : mapDay["pm"]) + ', '; // 获取晚高峰统计数据字符串
        mapAllDw[mapDay["day"]]["pm"] += null == mapDay["pm"] ? 0 : int.parse(mapDay["pm"]);
      }
      strFlowList2 += ']'; // 加上尾巴
      strAmRushList2 += ']'; // 加上尾巴
      strPmRushList2 += ']'; // 加上尾巴

      if (0 == j) {
        // 第一次处理点位数据时添加
        strDateNew += ']'; // 加上尾巴
      }

      listStrFlowNew.add(strFlowList2);
      listStrAmRushNew.add(strAmRushList2);
      listStrPmRushNew.add(strPmRushList2);
    }

    // 在 List 头部插入 AllDw 数据
    insertAlldwData(mapAllDw);

    // my_segmentPrint(strDateList);
    // my_segmentPrint(strDateNew);
    //data: ['1st', '2nd', '3rd', '4th', '5th', '6th', '7th', '8th', '9th', '10th', '11th', '12th', '13th', '14th', '15th', '16th', '17th', '18th', '19th', '20th
    // ', '21st', '22nd', '23rd', '24th', '25th', '26th', '27th', '28th', '29th', '30th', '31st',]
    //data: ['3.18', '3.19', '3.20', '3.21', '3.22', '3.23', '3.24', '3.25', '3.26', '3.27', '3.28', '3.29', '3.30', '3.31', '4.01', '4.02', '4.03', '4.04', '4.0
    // 5', '4.06', '4.07', '4.08', '4.09', '4.10', '4.11', '4.12', '4.13', '4.14', '4.15', '4.16', '4.17', ]

    // my_segmentPrint(strFlowList);
    // my_segmentPrint(listStrFlowNew[0]);
    //data: [320, 302, 301, 334, 390, 330, 320, 320, 302, 301, 334, 390, 330, 320, 320, 302, 301, 334, 390, 330, 320, 320, 302, 301, 334, 390, 330, 320, 320, 302
    // , 301,]
    //data: [194893, 211019, 242299, 209904, 100941, 261849, 117473, 94218, 130115, 206901, 203021, 176968, 83047, 168084, 178937, 197859, 224155, 190689, 201393
    // , 184673, 198215, 200415, 192958, 203951, 198704, 174829, 200787, 205696, 169762, 196270, 193892, ]

    // my_segmentPrint(strAmRushList);
    // my_segmentPrint(listStrAmRushNew[0]);
    //data: [120, 132, 101, 134, 90, 230, 210, 120, 132, 101, 134, 90, 230, 210, 120, 132, 101, 134, 90, 230, 210, 120, 132, 101, 134, 90, 230, 210, 120, 132, 10
    // 1,]
    //data: [5055, 31048, 23814, 23344, 38457, 36880, 32959, 7875, 6916, 27568, 26921, 20085, 17335, 16304, 22311, 21469, 21440, 15561, 18854, 25972, 25305, 2374
    // 3, 23024, 20813, 17755, 21151, 26523, 25628, 17657, 21632, 16196, ]

    // my_segmentPrint(strPmRushList);
    // my_segmentPrint(listStrPmRushNew[0]);
    //data: [220, 182, 191, 234, 290, 330, 310, 220, 182, 191, 234, 290, 330, 310, 220, 182, 191, 234, 290, 330, 310, 220, 182, 191, 234, 290, 330, 310, 220, 182
    // , 191,]
    //data: [44288, 36414, 32965, 18464, 4156, 30809, 9437, 6974, 24531, 28787, 21435, 24525, 0, 24785, 29147, 26628, 24129, 21751, 30712, 25291, 33308, 32587, 3
    // 1470, 29432, 25386, 25123, 27701, 29828, 30249, 33947, 19888, ]
  }

  // 用获取的车流量日统计数据，替换 strEchartsOption 中要需要替换的字符串
  Future replaceEchartsOptionData({bool bFirst = true}) async {
    print('replaceEchartsOptionData bFirst = $bFirst');
    print('replaceEchartsOptionData nDwbh = $nDwbh');
    //1、strEchartsOption 中要需要替换的字符串
    String strDateList =
        '''data: ['1st', '2nd', '3rd', '4th', '5th', '6th', '7th', '8th', '9th', '10th', '11th', '12th', '13th', '14th', '15th', '16th', '17th', '18th', '19th', '20th', '21st', '22nd', '23rd', '24th', '25th', '26th', '27th', '28th', '29th', '30th', '31st',]''';
    String strFlowList =
        '''data: [320, 302, 301, 334, 390, 330, 320, 320, 302, 301, 334, 390, 330, 320, 320, 302, 301, 334, 390, 330, 320, 320, 302, 301, 334, 390, 330, 320, 320, 302, 301,]''';
    String strAmRushList =
        '''data: [120, 132, 101, 134, 90, 230, 210, 120, 132, 101, 134, 90, 230, 210, 120, 132, 101, 134, 90, 230, 210, 120, 132, 101, 134, 90, 230, 210, 120, 132, 101,]''';
    String strPmRushList =
        '''data: [220, 182, 191, 234, 290, 330, 310, 220, 182, 191, 234, 290, 330, 310, 220, 182, 191, 234, 290, 330, 310, 220, 182, 191, 234, 290, 330, 310, 220, 182, 191,]''';

    strEchartsOptionNew = strEchartsOption;
    //print('strEchartsOptionNew.indexOf(strDateList) = ${strEchartsOptionNew.indexOf(strDateList)}');
    //I/flutter (23047): strEchartsOptionNew.indexOf(strDateList) = 1667
    strEchartsOptionNew = strEchartsOptionNew.replaceAll(strDateList, strDateNew);
    strEchartsOptionNew = strEchartsOptionNew.replaceAll(strFlowList, listStrFlowNew[nDwbh]);
    strEchartsOptionNew = strEchartsOptionNew.replaceAll(strAmRushList, listStrAmRushNew[nDwbh]);
    strEchartsOptionNew = strEchartsOptionNew.replaceAll(strPmRushList, listStrPmRushNew[nDwbh]);

    // 第一次处理点位数据时添加 listAllDw 的元素
    // mapAllDw[mapDay["day"]] = {
    //   "all": 0,
    //   "am": 0,
    //   "pm": 0
    // }; //有 31 个元素，每个元素又是一个 Map：包含车流量、早高峰、晚高峰
    if (!bFirst) {
      List _listStrFlow = listStrFlowNew[nDwbh]
          .substring(listStrFlowNew[nDwbh].indexOf('[') + 1, listStrFlowNew[nDwbh].lastIndexOf(']'))
          .split(',');
      List _listStrAmRush = listStrAmRushNew[nDwbh]
          .substring(
              listStrAmRushNew[nDwbh].indexOf('[') + 1, listStrAmRushNew[nDwbh].lastIndexOf(']'))
          .split(',');
      List _listStrPmRush = listStrPmRushNew[nDwbh]
          .substring(
              listStrPmRushNew[nDwbh].indexOf('[') + 1, listStrPmRushNew[nDwbh].lastIndexOf(']'))
          .split(',');

      List listKeys = mapAllDw.keys.toList();
      int len = listKeys.length;
      for (int i = 0; i < len; i++) {
        mapAllDw[listKeys[i]]["all"] = int.parse(_listStrFlow[i].trim());
        mapAllDw[listKeys[i]]["am"] = int.parse(_listStrAmRush[i].trim());
        mapAllDw[listKeys[i]]["pm"] = int.parse(_listStrPmRush[i].trim());
      }
      // Map 遍历时修改 value 值
      //mapAllDw.forEach((var key, var value) {});
    }
  }

  // 在 List 头部插入 AllDw 数据
  insertAlldwData(Map mapAllDw) {
    // 所有点位 31 天的车流量日统计数据，每天有 3 个数据：车流量、早高峰、晚高峰
    //Map mapAllDw = {}; // 有 31 个元素，每个元素又是一个 Map：包含车流量、早高峰、晚高峰

    String strFlow = 'data: [';
    String strAmRush = 'data: [';
    String strPmRush = 'data: [';
    List list = mapAllDw.values.toList();
    for (Map m in list) {
      strFlow += (m["all"].toString() + ', ');
      strAmRush += (m["am"].toString() + ', ');
      strPmRush += (m["pm"].toString() + ', ');
    }
    strFlow += ']';
    strAmRush += ']';
    strPmRush += ']';

    listStrFlowNew.insert(0, strFlow);
    listStrAmRushNew.insert(0, strAmRush);
    listStrPmRushNew.insert(0, strPmRush);
  }

  // 从日期字符串 _strDate 得到月.日字符串
  String getStrMonthDay(String _strDate) {
    String _monthDay = '\'' + getStrMonth(_strDate) + getStrDay(_strDate) + '\',';
    _monthDay = _monthDay.replaceAll(' ', '');
    return _monthDay + ' ';
  }

  // 从日期字符串 _strDate 得到日字符串 _strDay
  String getStrDay(String _strDate) {
    String _day = _strDate.substring(_strDate.lastIndexOf('-') + 1);
    return _day;
  }

  // 从日期字符串 _strDate 得到月字符串 _strMonth
  String getStrMonth(String _strDate) {
    String _month = _strDate.substring(_strDate.indexOf('-') + 1, _strDate.lastIndexOf('-'));
    _month = '0' == _month[0] ? _month[1] : _month; //去除前导0
    _month = _month + '.';
    return _month;
  }

  String strEchartsOptionNew = '';
  String strEchartsOption = '''
    {
      height: 260,
      tooltip: {
        trigger: 'axis',
        // position: function (pt) {
        //   return [pt[0], '10%'];
        // }
        position: function(point, params, dom, rect, size) {
          //其中point为当前鼠标的位置，size中有两个属性：viewSize和contentSize，分别为外层div和tooltip提示框的大小
          var x = point[0];
          var y = point[1];
          var viewWidth = size.viewSize[0];
          var viewHeight = size.viewSize[1];
          var boxWidth = size.contentSize[0];
          var boxHeight = size.contentSize[1];
          var posX = 0; //x坐标位置
          var posY = 0; //y坐标位置

          if (x < boxWidth) { //左边放不下
              posX = 5;
          } else { //左边放的下
              posX = x - boxWidth;
          }

          if (y < boxHeight) { //上边放不下
              posY = 5;
          } else { //上边放得下
              posY = y - boxHeight;
          }

          return [posX, posY];
        },
      },
      toolbox: {
        //left: '13',//距左
        right: '12',//距右
        top: '7',//距上
        itemSize: '18',
        feature: {
          // dataZoom: {
          //     yAxisIndex: 'none'
          // },
          restore: {},
          // saveAsImage: {},
        }
      },
      legend: {
        top: '49',//距上
        left: '70',//距左
        //orient: 'vertical',
        //data: ['Flow', 'amRush', 'pmRush']
        data: ['车流量', '早高峰', '晚高峰']
      },
      grid: {
        height: 230,
        left: '0%',
        right: '4%',
        bottom: '18%',
        containLabel: true
      },
      yAxis: {
        type: 'value',
          axisLabel: {
          show:true,
          // textStyle: {
          //   color: "rgba(255,255,255,.6)",
          //   fontSize: '12',
          // },
          formatter: function(value, index) {
            // var value;
            // if (value >= 100) {
            //   value = value / 10000;
            // } else if (value < 100) {
            //   value = value;
            // }
            value = value / 10000;
            var dispValue;
            if (value < 10) {
              dispValue = value.toFixed(1);
            } else {
              dispValue = value.toFixed(0);
            }
            return dispValue
          },
        },
      },
      xAxis: {
        type: 'category',
        data: ['1st', '2nd', '3rd', '4th', '5th', '6th', '7th', '8th', '9th', '10th', '11th', '12th', '13th', '14th', '15th', '16th', '17th', '18th', '19th', '20th', '21st', '22nd', '23rd', '24th', '25th', '26th', '27th', '28th', '29th', '30th', '31st',]
      },
      series: [
        {
          name: '车流量',
          type: 'bar',
          data: [320, 302, 301, 334, 390, 330, 320, 320, 302, 301, 334, 390, 330, 320, 320, 302, 301, 334, 390, 330, 320, 320, 302, 301, 334, 390, 330, 320, 320, 302, 301,]
        },
        {
          name: '早高峰',
          type: 'bar',
          data: [120, 132, 101, 134, 90, 230, 210, 120, 132, 101, 134, 90, 230, 210, 120, 132, 101, 134, 90, 230, 210, 120, 132, 101, 134, 90, 230, 210, 120, 132, 101,]
        },
        {
          name: '晚高峰',
          type: 'bar',
          data: [220, 182, 191, 234, 290, 330, 310, 220, 182, 191, 234, 290, 330, 310, 220, 182, 191, 234, 290, 330, 310, 220, 182, 191, 234, 290, 330, 310, 220, 182, 191,]
        },
      ],
      dataZoom: [
        {
          type: 'inside',
          start: 0,
          end: 100,
        },
        {
          //backgroundColor: 'rgba(255,255,255,1)',
          //fillerColor: 'rgba(240,240,240,0.25)',
          height: 48,  //组件高度
          top: 318, //组件离容器上侧的距离,'top', 'middle', 'bottom','20%'
          bottom: 0, //组件离容器下侧的距离,'20%'
          //bottom: 30
          left: 22, //组件离容器左侧的距离,'left', 'center', 'right','20%'
          right: 17, //组件离容器右侧的距离,'20%'
          start: 0,
          end: 100,
          handleIcon: 'M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4v1.3h1.3v-1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z',
          handleSize: '60%',
          handleStyle: {
            color: '#fff',
            shadowBlur: 3,
            shadowColor: 'rgba(0, 0, 0, 0.6)',
            shadowOffsetX: 2,
            shadowOffsetY: 2
          },
        },
      ],
    }
    ''';

  //2、得到统计图表组件
  Widget getBarEcharts(String _strEchartsOptionNew) {
    return Stack(
      children: [
        //1、显示 Echarts 图表
        Align(
          child: Container(
            width: 350,
            height: 379,
            alignment: Alignment(0, 0),
            child: Echarts(
              // extensions: [darkThemeScript],
              // theme: 'dark',
              captureAllGestures: true,
              extraScript: '''
                var base = +new Date(1968, 9, 3);
                var oneDay = 24 * 3600 * 1000;
                var date = [];  // 该句不能删
                var data = [Math.random() * 300];
                for (var i = 1; i < 20000; i++) {
                  var now = new Date(base += oneDay);
                  date.push([now.getFullYear(), now.getMonth() + 1, now.getDate()].join('/'));
                  data.push(Math.round((Math.random() - 0.5) * 20 + data[i - 1]));
                }
              ''',
              option: _strEchartsOptionNew,
            ),
          ),
        ),
        //2、得到点位选择下拉按钮组件
        Positioned(
          top: ScreenUtil().setHeight(5),
          left: ScreenUtil().setHeight(85),
          child: listItems.isEmpty ? getMoreWidget2() : getSelectLedDw(),
        ),
        //3、显示坐标单位
        Positioned(
          top: ScreenUtil().setHeight(155),
          left: ScreenUtil().setHeight(20),
          child: Text('万辆', style: TextStyle(fontSize: 12)),
        ),
      ],
    );
  }

// @override
// Widget build(BuildContext context) {
//   return Scaffold(
//     // appBar: AppBar(
//     //   title: Text(mapStatisType['cllrtj']['text']),
//     //   centerTitle: true,
//     // ),
//     appBar: PreferredSize(
//       preferredSize: Size.fromHeight(ScreenUtil().setHeight(173)), // 设置appBar高度
//       // 设置appBar高度
//       child: AppBar(
//         automaticallyImplyLeading: false,
//         centerTitle: true,
//         titleSpacing: 0.0,
//         flexibleSpace: Container(
//           //SizedBox(height: ScreenUtil().statusBarHeight), //显示顶部状态栏
//           // SizedBox(height: ScreenUtil().setHeight(10)), //显示顶部状态栏
//           padding: EdgeInsets.only(top: ScreenUtil().statusBarHeight), //留出顶部状态栏高度
//           child: Container(
//             //height: ScreenUtil().setHeight(173),
//             decoration: BoxDecoration(
//               gradient: LinearGradient(
//                 begin: Alignment.centerLeft,
//                 end: Alignment.centerRight,
//                 colors: [
//                   Color.fromRGBO(12, 186, 156, 1),
//                   Color.fromRGBO(39, 127, 235, 1),
//                 ],
//               ),
//             ),
//             // decoration: BoxDecoration(
//             //   gradient: LinearGradient(colors: [
//             //     Color(0xFF0018EB),
//             //     Color(0xFF01C1D9),
//             //   ], begin: Alignment.bottomCenter, end: Alignment.topCenter),
//             // ),
//           ),
//         ),
//         title: Padding(
//           padding: EdgeInsets.only(left: 0, right: 0),
//           child: Row(
//             mainAxisAlignment: MainAxisAlignment.start,
//             children: [
//               getIconAndTextButton(
//                 iconColor: Colors.white,
//                 iconData: Icons.chevron_left_outlined,
//                 onPress: () {
//                   Navigator.pop(context);
//                 },
//               ),
//               Expanded(
//                   child: RichText(
//                 textAlign: TextAlign.center,
//                 overflow: TextOverflow.ellipsis,
//                 text: TextSpan(children: [
//                   TextSpan(
//                     text: mapStatisType['cllrtj']['text'],
//                     style: TextStyle(color: Colors.white, fontSize: 20),
//                   ),
//                   TextSpan(
//                       text: '\n' + mapStatisType['cllrtj']['textTerm'],
//                       style: TextStyle(fontSize: 14.0)),
//                 ]),
//               )),
//               SizedBox(width: 50),
//             ],
//           ),
//         ),
//       ),
//     ),
//     body: (listCllrtjStatis.isEmpty || strEchartsOptionNew.isEmpty || mapAllDw.length < 31)
//         ? getMoreWidget(
//             color: Colors.black38,
//             text: '正在下载大量数据，\n请耐心等待...',
//             size: 25,
//             textAlign: TextAlign.center)
//         : Column(
//             children: [
//               SizedBox(height: ScreenUtil().setHeight(20)),
//               //2、得到统计图表组件
//               getBarEcharts(strEchartsOptionNew),
//               //SizedBox(height: ScreenUtil().setHeight(0)),
//               //3、得到数据表组件
//               TableScrollable(mapTableData: mapAllDw),
//             ],
//           ),
//   );
// }
}
