我正在從谷歌分析中提取數(shù)據(jù)以顯示在用戶儀表板上。這是我在 React 中的第一個可視化項目,我決定使用 recharts 進(jìn)行可視化。但是,我想重新格式化一些 google 分析數(shù)據(jù),使其看起來像日期一樣漂亮。我正在努力編寫一個函數(shù)來遍歷我的數(shù)據(jù)數(shù)組并將數(shù)據(jù) 201903 重新格式化為例如 2019 年 3 月(甚至更好的 2019 年 3 月)。我只需要一個可以做到這一點的函數(shù)。但是,我沒有從數(shù)組中提取此類數(shù)據(jù)的經(jīng)驗。這是我的數(shù)據(jù):[ [ '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' ] ]我正在尋找的一個函數(shù)的例子是: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 中可視化谷歌分析數(shù)據(jù),編輯 json
郎朗坤
2021-06-10 17:08:00