[英]Filtering the d3 bubble chart as we type
我正在嘗試在文本框中鍵入內容時過濾氣泡圖。 對於我們鍵入的每個按鍵,應該使用名稱值與到目前為止鍵入的表達式匹配的節點來更新氣泡圖。
這是我正在嘗試的方法,但似乎沒有用。 還有其他方法嗎?
var selectedVal = document.getElementById('autocompleteInput').value;
var regexp = new RegExp("^" + selectedVal.toLowerCase() + "\\w*");
var updatedData = feedsChart['children'].filter(function(obj){
return regexp.test(obj['name'].toLowerCase());
});
var newObj = {"children":updatedData,"name":"All Feeds"};
drawBubble(newObj); // This function redraws the entire bubble chart
我相信您需要將更新圖表的功能綁定到onkeyup事件。 使用jQuery,它可能看起來像這樣
d3.select("#autocompleteInput").on("keyup", drawBubble);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.