Javascript d3.js csv数据过滤器包含一个单词
我有一个像这样的CSV文件Javascript d3.js csv数据过滤器包含一个单词,javascript,d3.js,bar-chart,Javascript,D3.js,Bar Chart,我有一个像这样的CSV文件 product, year Apple Iphone11,2019 Apple Iphone11 pro,2019 Apple Iphone11 pro max,2019 Samsung Galaxy S10+,2019 Samsung Galaxy Note10+, 2019 Sony Xperia 1,2019 Sony Xperia 5,2019 如何用条形图过滤单词(苹果、三星、索尼) 图表将显示产品数量和公司名称 例如,(x,y)将是(苹果,3) 创建地
product, year
Apple Iphone11,2019
Apple Iphone11 pro,2019
Apple Iphone11 pro max,2019
Samsung Galaxy S10+,2019
Samsung Galaxy Note10+, 2019
Sony Xperia 1,2019
Sony Xperia 5,2019
如何用条形图过滤单词(苹果、三星、索尼)
图表将显示产品数量和公司名称
例如,(x,y)将是(苹果,3)
const brand2occurrences=newmap()代码>
const currentBrand=currentRow.split(“,”[0]。split(“”[0]代码>
所以现在你有了品牌名称
const currentOccurrencesOfThisBrand=brand2occurrences.get(currentBrand)代码>
brand2occurrences.set(currentBrand,(CurrentOccurrencesofhisBrand?CurrentOccurrencesofhisBrand++:1))