我不确定我错过了什么,我有一个在我的图表上呈现气泡的功能,我希望在新数据可用时调用该功能,但是,它会在顶部创建新的气泡我称之为现有的。它不是删除和更新?我错过了什么?
=B2+IF(COUNTIF(A1:B1,"X")=2,A2)
答案 0 :(得分:1)
this.bubblePeople
是输入选择。您必须在更新选择上调用.exit()
,您可以通过将变量设置为等于.data(data)
的返回值来获得。从更新选择中,您可以拨打.enter()
和.exit()
。
我已更改变量名称以表示变量引用的选择。
renderCalls(data){
let self = this;
this.bubblePeopleUpdate = this.canvas.selectAll('.openCalls').data(data);
this.bubblePeopleEnter = this.bubblePeopleUpdate.enter().append('g')
.attr('class', '.openCalls').attr('id', function (d) { return d.index })
.attr('transform', function (d) { return "translate(" + (self.getColX(d.x) + 25) + "," + (self.getRowY(d.y) + 25) + ")" })
.call(D3['drag']().on("start", this.dragstarted)
.on("drag", this.dragged)
.on("end", this.dragended.bind(this)));
this.bubblePeopleEnter.append("title").text(function (d) { return d.name + ' (' + d.index + ')' })
this.bubblePeopleEnter.append('circle')
.attr('r', 30)
.attr('fill', 'red')
.attr('fill-opacity', .5)
.attr("text-anchor", "middle");
this.bubblePeopleEnter.append('text')
.attr('text-anchor', 'middle')
.style('fill', 'white')
.style('font-size', function (d) { return d.shopcode == 'PSO' ? '14px' : '18px' })
.style('font-weight', 'bold')
.text(function (d) { return d.shopcode == 'PSO' ? 'PSO (' + d.count + ')' : d.count });
this.bubblePeopleUpdate.exit().remove();
}