【发布时间】:2021-06-24 19:29:23
【问题描述】:
当前值数据较小时图表出现问题,我有一个“耳朵”效应,你能帮我看看这个吗?
这是我正在使用的代码:
const rx = 30;
const ry = 30;
svg
.selectAll(".bar")
.data(data)
.enter()
.append("path")
.attr("class", "bar")
.attr("x", function (d) {
return x(d.key);
})
.attr("width", x.bandwidth())
.attr("y", function (d) {
return y(d.value);
})
.attr("height", function (d) {
return height - y(d.value);
})
.attr("fill", "#206BF3")
.attr(
"d",
(item) => `
M${x(item.key)},${y(item.value) + ry}
a${rx},${ry} 0 0 1 ${rx},${-ry}
h${x.bandwidth() - 2 * rx}
a${rx},${ry} 0 0 1 ${rx},${ry}
v${height - y(item.value) - ry}
h${-x.bandwidth()}Z
`
)
我尝试了很多方法,但都有效:|
【问题讨论】:
标签: javascript reactjs d3.js