为了账号安全,请及时绑定邮箱和手机立即绑定

在 React.js 中可视化谷歌分析数据,编辑 json

在 React.js 中可视化谷歌分析数据,编辑 json

郎朗坤 2021-06-10 17:08:00
我正在从谷歌分析中提取数据以显示在用户仪表板上。这是我在 React 中的第一个可视化项目,我决定使用 recharts 进行可视化。但是,我想重新格式化一些 google 分析数据,使其看起来像日期一样漂亮。我正在努力编写一个函数来遍历我的数据数组并将数据 201903 重新格式化为例如 2019 年 3 月(甚至更好的 2019 年 3 月)。我只需要一个可以做到这一点的函数。但是,我没有从数组中提取此类数据的经验。这是我的数据:[ [ '201811', '1', 'DailyPrep', '2' ],  [ '201812', '1', 'DailyPrep', '64' ],  [ '201901', '1', 'DailyPrep', '220' ],  [ '201902', '1', 'DailyPrep', '755' ],  [ '201903', '1', 'DailyPrep', '8534' ],  [ '201904', '1', 'DailyPrep', '4705' ],  [ '201905', '1', 'DailyPrep', '3667' ] ]我正在寻找的一个函数的例子是:Const FormatX = () => {   //year = the first four digits of the first data item in each array   //month = the last two digits of the first data item in each array   //monthyr = month + ', ' + year;   //return monthyr;}
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 178 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信