Tell us what’s happening:
the text of every circle tooltip show only the cordinates of the first of them (34, 78) even though my DOM inspector show such node to have the required values. Besides that it doesn’t pass the “run the test” button not sure why. Other than that the rest works fine it seems
Your code so far
<body>
<script>
const dataset = [
[ 34, 78 ],
[ 109, 280 ],
[ 310, 120 ],
[ 79, 411 ],
[ 420, 220 ],
[ 233, 145 ],
[ 333, 96 ],
[ 222, 333 ],
[ 78, 320 ],
[ 21, 123 ]
];
const w = 500;
const h = 500;
const svg = d3.select("body")
.append("svg")
.attr("width", w)
.attr("height", h);
svg.selectAll("circle")
.data(dataset)
.enter()
.append("circle")
.attr("cx", (d, i) => d[0] )
.attr("cy", (d, i) => h - d[1])
.attr("r", 5);
svg.selectAll("text")
.data(dataset)
.enter()
.append("title")
.text((d) => (d[0] + ", " + d[1]))
</script>
</body>
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36
.
Challenge: Add Attributes to the Circle Elements
Link to the challenge: