-1
我有一個帶有頻繁變化數據點的d3圖,我想在圖中顯示。目前,我每天都在數據對象被更新時重繪的全部劇情:如何更新d3圖形的數據?
container.remove()
container = svg.append("g");
drawContainer();
與drawContainer繪圖功能:
container.selectAll(".dot")
.data(datajson)
.enter().append("circle")
.attr("class", "dot")
.attr("r", 3.5)
.attr("cx", xMap)
.attr("cy", yMap)
.style("fill", function(d) { return color(cValue(d));})
我想簡單地調用:
container.selectAll(".dot")
.data(newdata)
添加新的數據點,但這並沒有使新的數據點可見。我怎樣才能更新只有新的數據點的情節?
這裏一個很好的閱讀關於如何創建更新刪除寶在d3中使用enter in exit輸入d3 https://medium.com/@c_behrens/enter-update-exit-6cafc6014c36 – Cyril