我想只显示一次在行图形的每个步骤上重复的值,并将其位置设置到行尾。如何在图形的整行上设置一个标签
假设我的数据中值列3(列的名称是“目标”,但可以是任何)将始终为每个对象具有相同的值,我想用它的值标记行“目标”在行末显示25)只有一次。
这里是working_code及以下的代码段,其上创建这些点上面的线条和文本值的点:
// points on the lines
point.selectAll("circle")
.data(function(d,i){ return d.values; })
.enter().append("circle")
.attr("cx", function(d) {
return x(d.date);
})
.attr("cy", function(d, i) { return y(d.value); })
.attr("r", 3)
.style("fill", function(d) { return color(d.name); });
// values above the points
var val = column.append("g")
.attr("class","valori");
val.selectAll("text")
.data(function(d){ return d.values; })
.enter().append("text")
.attr("x", function(d) {
return x(d.date);
})
.attr("y", function(d) { return y(d.value); })
.attr('dy', -10)
.attr("text-anchor", "middle")
.text(function(d) { return d.value; });
我使用的https://bl.ocks.org/mbostock/3884955
任何想法略微改变的例子怎么做?
在此先感谢!
你能扩展你想要的吗?目前你的小提琴只显示目标在行末? – thatOneGuy
我认为op只能在行尾 – echonax
只显示25次耶!感谢echonax,这就是我的意思 – Slava32