我们如何将 id 添加到数据映射气泡中,以便我们可以像这样访问单个气泡:
d3.select("#my_bubble_id")
如果气泡是这样声明的:
var bombs = [{
name: 'Tsar Bomba',
radius: 1,
yeild: 50000,
country: 'USSR',
fillKey: 'RUS',
significance: 'Largest thermonuclear weapon ever tested—scaled down from its initial 100 Mt design by 50%',
date: '1961-10-31',
latitude: 40.8499966,
longitude: 129.666664
}];
// draw bubbles for bombs
map.instance.bubbles(bombs, {
popupTemplate:function (geography, data) {
return ['<div class="hoverinfo"><strong>' + data.name + '</strong>',
'<br/>Payload: ' + data.yeild + ' kilotons',
'<br/>Country: ' + data.country + '',
'<br/>Date: ' + data.date + '',
'</div>'].join('');
}
});