我正在从谷歌分析中提取数据以显示在用户仪表板上。这是我在 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;}
添加回答
举报
0/150
提交
取消