我想知道如何映射 2 个数组的数据,以便我可以使用数据生成使用 d3.js 的图表
当前我有2个数组:
wordsArray = {"THE","MAIN","PURPOSE","OF","PHOTOSYNTHESIS","IS","TO","MAKE",
"FOOD","FOR","PLANT","IT","PRODUCE","SUGAR","MANUFACTURE"};
computationArray = {6,1,2,2,1,3,3,1,3,4,4,2,1,2,1};
wordsArray 包含所有不同的单词,而 computingArray 包含每个单词出现的次数。
我想知道是否有任何捷径可以使它看起来像这样:
var data = [{"words":"THE", "count": "6"},
{"words":"MAIN", "count": "1"}, {"words":"PURPOSE", "count": "2"},
{"words":"OF", "count": "2"}.... ];
谢谢!