阿里云数据大屏数据过滤脚本

数据过滤脚本

最近业务上需要用阿里云物联网平台搭建数据监控大屏,接触了平台上常用的API形式,通过常用API查询得到数据源返回结果,然后再通过数据过滤器得到控件适用的数据。

查询参数:
[
  {
    "paramValue": "-7d",
    "paramType": "VARCHAR",
    "paramName": "start_date"
  },
  {
    "paramValue": "now",
    "paramType": "VARCHAR",
    "paramName": "end_date"
  }
]
参数 参数含义
now 当前时间
-1h 上一小时整点
-1d 昨日零点
-7d 七天前零点

数据过滤前:
[													
  {
    "statDate": "20200320",
    "msgDailyCnt": 109
  },
  {
    "statDate": "20200324",
    "msgDailyCnt": 638
  },
]
return data.map(item => (
  {
    x: `${item.statDate.slice(0, 4)}/${item.statDate.slice(4, 6)}/${
      item.statDate.slice(6, 8)}`,
    y: item.msgDailyCnt
  }
));

这里将日期格式做了一下转换以供我的折线图控件使用,使用到了部分JavaScript语法,还是很容易理解的

数据过滤后
[
  {
    "x": "2020/03/20",
    "y": 109
  },
  {
    "x": "2020/03/24",
    "y": 638
  },
]

最终的显示效果如下:
波形图显示效果

发布了13 篇原创文章 · 获赞 16 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/qq_32969455/article/details/105114757