我正在嘗試在 D3js 多線圖表上的 xCaption 和 x 軸標簽之間添加空格,但無法添加。另外,我怎樣才能擺脫最后一個 x-label(5 之后的那個)。

const XCaption = svg.append('g')
.attr('class', 'x axis')
.attr('transform', `translate(0, ${height - margin})`)
.call(xAxis)
.append('text')
.attr('x', (width/2) - 24)
.attr('y', 25)
.attr('transform', 'rotate(0)')
.attr('fill', '#437495')
.attr('font-size', '16px');
uj5u.com熱心網友回復:
您可以通過更改 y 來向下滑動 x 標題:
const XCaption = svg.append('g')
.attr('class', 'x axis')
.attr('transform', `translate(0, ${height - margin})`)
.call(xAxis)
.append('text')
.text('Sprints')
.attr('x', (width/2) - 24)
.attr('y', 30) // move your text down 5 more pixels
.attr('transform', 'rotate(0)')
.attr('fill', '#437495')
.attr('font-size', '16px');
末尾的那些小刻度通常是軸域的一部分。使用 css:
.x.axis .domain { display: none; }
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/462639.html
