更新时间:2023-08-30 23:14:34
您可以传入一个返回标签的格式函数,这是d3js的API。
You can pass in a format function that returns label. This is an API of d3js.
var x_format = function(num) {
if (num === 2.3)
return "A";
else if (num === 5.6)
return "B";
else if (num === 45.2)
return "C";
};
var xAxis = d3.svg.axis()
.scale(x)
.orient("bottom")
.tickFormat(x_format);
查看这个散点图的例子。
Check out this example that I make for scatterplot.
http://vida.io/documents/jSGz9TQEmzwMqQzhs
{(A,2.3),(B,5.6), C,45.2)}
{(A, 2.3), (B, 5.6), (C, 45.2) }
更新:我的答案为固定值。
Update: my answer with fixed value.
更新:行,条形图,散点图之间的混合组合:
Update: hybrid combination between line, bar, scatterplot: