zoukankan      html  css  js  c++  java
  • 数据扩样处理

    1.html:

    1  <ul class="search-content">
    2             <li>
    3               <span class="name" (click)="selectorChange('扩样数据', true)">扩样数据</span>
    4             </li>
    5             <li>
    6               <span class="name" (click)="selectorChange('原始数据', false)">原始数据</span>
    7             </li>
    8           </ul>

    1.ts:

    import { CommonService } from './../../service/common.service';
    
     dataType = this.commonService.expandName;
      isShowList: boolean = false;
    
     selectorChange(item, isExpand) {
        if (this.commonService.expand !== isExpand) {
          this.isShowList = false;
          this.commonService.expandName = item;
          this.dataType = item;
          this.commonService.expand = isExpand;
          this.commonService.expandType.next(isExpand);
        }
      }

    common.service.ts:

    import { of, Subject, Subscription } from 'rxjs'; 
    
    expandType = new Subject();
    expand: boolean = true;
    expandName: string = '扩样数据';
    
      // 数据扩样处理
      HandleData(data) {
        if (this.expand) {
          if (typeof data === 'number') {
            //
            data = Math.round((data / 0.73) / 0.9165);
          } else if (!(data instanceof Array)) {
            // 对象
            if (data['subscriberCounts']) {
              data['subscriberCounts'].forEach((item, index) => {
                if (item['countList']) {
                  item['countList'].forEach((item1, index1) => {
                    data['subscriberCounts'][index]['countList'][index1] = Math.round((item1 / 0.73) / 0.9165);
                  });
                }
              });
            } else if (data['countList']) {
              data['countList'].forEach((item, index) => {
                data['countList'][index] = Math.round((item / 0.73) / 0.9165);
              });
            } else if (data['populations']) {
              data['populations'].forEach((item, index) => {
                if (item['countList']) {
                  item['countList'].forEach((item1, index1) => {
                    data['populations'][index]['countList'][index1] = Math.round((item1 / 0.73) / 0.9165);
                  });
                }
              });
            }
          } else {
            // 数组
            data.forEach(item => {
              if (item.subscriberCount) {
                item.subscriberCount = Math.round((item.subscriberCount / 0.73) / 0.9165);
              } else if (item['currentCount']) {
                item.currentCount = Math.round((item.currentCount / 0.73) / 0.9165);
              }else {
                item.populations = Math.round((item.populations / 0.73) / 0.9165);
              }
            });
    
          }
        }
        return data;
      }
  • 相关阅读:
    7、JsonCpp简单使用(3)
    8、mysql外键(FOREIGN KEY)的简单使用
    7、mysql创建数据库失败,提示Access denied for user ''@'localhost'
    6、JsonCpp简单使用(2)
    ASP.NET2.0快速入门--高级数据方案(3)
    DELL电脑系统恢复出常值
    一步一步学习ObjectDataSource(1)
    来自微软的ASP.NET2.0开源代码
    ASP.NET2.0 Person Web Site:将图片以二进制的从数据库读取
    ASP.NET2.0快速入门--高级数据方案(中)
  • 原文地址:https://www.cnblogs.com/a1-top/p/14047180.html
Copyright © 2011-2022 走看看