2017-03-20 73 views

回答

0

可以用戶filter(function)過濾使用函數取出某些值。在你的情況下,你可以使用:

data_arr.filter((date_str) => new Date(date_str).getFullYear() == new Date().getFullYear()) 

獲得當年的所有值。

+0

這是我的圖表製作功能。不工作看到只有一年幫助我。 –

+0

圖表 .WIDTH(308) .height(220) .slicesCap(4) .innerRadius(30) .dimension(runDimension) 。集團(speedSumGroup) .legend(dc.legend()) 。 ordinalColors([「#8A8AD6」,「#00BBDE」,「#FE6672」,「#EEB058」]) //解決方法#703:沒有足夠的數據可通過.label()訪問以顯示百分比 .on '轉變前',函數(圖表){ chart.selectAll( 'text.pie切片')。文本(函數(d){ 返回d.data.key + '' + dc.utils.printSingleValue((d。 endAngle - d.startAngle)/(2 * Math.PI)* 100)+'%'; }) }); –

相關問題