如何在 JavaScript 中顯示給定數(shù)組的值?換句話說,如何使用console.log over“pie”來顯示(42.9、37.9和19.2)?它嘗試了 console.log(Object.values(pie)) 但沒有成功。多謝。這就是我創(chuàng)建數(shù)組的方式:var width = 350 height = 350 margin = 40// The radius of the pieplot is half the width or half the height (smallest one). I subtract a bit of margin.var radius = Math.min(width, height) / 2 - margin// append the svg object to the div called 'my_dataviz'var svg = d3.select("#my_dataviz_b") .append("svg") .attr("width", width) .attr("height", height) .append("g") .attr("transform", "translate(" + width / 2 + "," + height / 2 + ")"); var color =["#98abc5", "#8a89a6", "#7b6888"] var annotations = ["Home win", "Draw game", "Away win"] var data = d3.selectAll('.values_half_before').nodes(); var pie = d3.pie() //we create this variable, for the values to be readeable in the console .value(function(d) {return d.innerHTML; })(data);
如何在 javascript 控制臺中顯示該數(shù)組中的值?
慕絲7291255
2023-07-20 15:06:38