我想只顯示一次在行圖形的每個步驟上重複的值,並將其位置設置到行尾。如何在圖形的整行上設置一個標籤
假設我的數據中值列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