3

我希望用 d3.js 绘制多项式函数,并且我正在寻找正确的解决方案(这应该比从头开始构建轴更简单)关于如何在 2D 中构建坐标轴,其中我有一个原点标签

4

1 回答 1

2

D3 轴生成后即可进行操作。例如,您可以通过专门选择它们来删除原点标​​签:

//make default origin labels invisible
svg.selectAll(".axis g text")
    .filter(function(d) {return d==0 ? true : false})
    .style("opacity", 1e-6);

然后您可以添加自己的原产地标签:

//add a custom origin identifier
svg.append("text")
    .attr({
        "class": "origintext",
        "x": -8,
        "y": height + 8,
        "text-anchor": "end",
        "dy": ".71em"
    })
    .text("(0,0)");

在这里查看完整的实现:http: //jsfiddle.net/kcPEX/1/

单一来源标签

于 2012-09-03T15:11:52.090 回答