Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在 D3 中绘制了一个折线图。我在 x 轴对齐方面面临问题。小提琴链接
var x = d3.scale.ordinal().rangeRoundBands([0, width], .2); x.domain(dataset.map(function(d) { return d.qName; }));
问题是 - “点和 x 轴不在同一水平”。(有一些可见的转变))。如何将 Q1 移动到 x 轴和 Y 轴的交点。在这方面的任何帮助将不胜感激。
您可以通过调整包含轴的组的平移来调整高度,例如更改height值
height
svg.append("g") .attr("class", "x axis") .attr("transform", "translate(0," + height + ")");
例如,您可能想尝试一下(height-20)。
(height-20)