我正在從谷歌分析中提取數據以顯示在用戶儀表板上。這是我在 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;}
在 React.js 中可視化谷歌分析數據,編輯 json
郎朗坤
2021-06-10 17:08:00