你好,我有這樣的視覺:https://plnkr.co/edit/H6M1xoS9cZv5dKCTIyid?p=preview旋轉變換
我試圖旋轉x軸的標籤,並嘗試在線路299-317無濟於事修改代碼 - 所以我覺得代碼如.attr("transform", "rotate(-65)");
需要添加到以下內容?
// Add x labels to chart
var xLabels = svg
.append("g")
.attr("transform", "translate(" + margin.left + "," + (margin.top + height) + ")");
xLabels.selectAll("text.xAxis")
.data(BarData)
.enter()
.append("text")
.text(function(d) {
return d.dt;
})
.attr("text-anchor", "middle")
// Set x position to the left edge of each bar plus half the bar width
.attr("x", function(d, i) {
return (i * (width/BarData.length)) + ((width/BarData.length - barPadding)/2);
})
.attr("y", 15)
.attr("class", "xAxis")
讚賞你的幫助 - 相比於在excel中創建圖表,D3就像瑞士手錶......漂亮,但每個組件都需要痛苦的注意! – whytheq