更新时间:2022-12-24 12:52:03
您有一个很好的实现,但由于一个主要的错字而出轨了:
You had a pretty good implementation that was derailed by one major typo:
function transform(d) {
return "translate(" + x(d.y) + "," + x(d.x) + ")";
}
应该是
function transform(d) {
return "translate(" + x(d.y) + "," + y(d.x) + ")";
}
要使路径不翻转,您应该不应该反转y轴:
To have your paths not flip you should have probably not reversed the y-axis:
y = d3.scale.linear().domain([0, h]).range([h, 0])
更改为
y = d3.scale.linear().domain([0, h]).range([0, h])
固定在此处: http://jsfiddle.net/6kEpp/2/.但是,为将来参考,您可能应该让x轴在x值上运行,而y轴在y值上运行,否则您将真的感到困惑.
Fixes are here: http://jsfiddle.net/6kEpp/2/. But for future reference, you should probably have your x-axis operate on x-values, and y-axis operate on y-values, or you're just going to really confuse yourself.
最后的评论以完善您的实现: