我有这个代码:
y.domain([-arr2, arr2]).nice();
svg.append("g")
.attr("class", "y axis")
.call(yAxis)
.append("text")
.attr("class", "label")
.attr("transform", "rotate(-90)")
.attr("x", 150)
.attr("y", -10)
.attr("dy", ".71em")
.style("text-anchor", "end")
.attr("font-family", "sans-serif")
.attr("font-size", "34px")
.text("log(Lev)");
这是用这段代码创建的带有 Y 轴的图表:
如您所见,Y 轴在 X 轴下方有一个负数部分 (0 <--> -25), 我想将负 Y 轴域更改为正。
所以我得到类似的东西:
最佳答案
您可以使用:
yAxis = Math.abs(yAxis);
关于javascript - 如何将负 Y 轴域更改为正,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24493255/