में ईवेंट पर क्लिक करने की आवश्यकता है, मैं एक बबल चार्ट बनाने की कोशिश कर रहा हूं, अगर मैं एक बबल पर क्लिक करता हूं, तो बबल का शीर्षक कंसोल में दिखाई देना चाहिए। मैंने कुछ तरीकों की कोशिश की, लेकिन सफल नहीं हुआ।D3.js, d3.js
d3.json("deaths.json",
function (jsondata) {
var deaths = jsondata.map(function(d) { return d.deaths; });
var infections = jsondata.map(function(d) { return d.infections; });
var country = jsondata.map(function(d) { return d.country; });
var death_rate = jsondata.map(function(d) { return d.death_rate; });
console.log(deaths);
console.log(death_rate);
console.log(infections);
console.log(country);
console.log(date);
//Making chart
for (var i=0;i<11;i++)
{
var f;
var countryname=new Array();
var dot = new Array();
dot = svg.append("g").append("circle").attr("class", "dot").attr("id",i)
.style("fill", function(d) { return colorScale(death_rate[i]); }).call(position);
//adding mouse listeners....
dot.on("click", click());
function click()
{
/***********************/
console.log(country); //i need the title of the circle to be printed
/*******************/
}
function position(dot)
{
dot .attr("cx", function(d) { return xScale(deaths[i]); })
.attr("cy", function(d) { return yScale(death_rate[i]); })
.attr("r", function(d) { return radiusScale(infections[i]); });
dot.append("title").text(country[i]);
}
}
});
मैं चक्र के शीर्षक की जरूरत है मुद्रित करने के लिए कृपया मदद !!!