You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -243,9 +243,7 @@ Most important selectors explained in an example
243
243
</style>
244
244
</head>
245
245
<body>
246
-
<divclass="header">
247
-
D3 Test
248
-
</div>
246
+
<divclass="header">D3 Test</div>
249
247
<divid="main">
250
248
<pclass="header">Lorem Impsum Header</p>
251
249
<p>Lorem Impsum</p>
@@ -724,7 +722,7 @@ Adding linear and ordinal scale: [barchart04_scale.html](examples/barchart04_sca
724
722
725
723
## Interactivity
726
724
727
-
Interactivity is event-driven as in the usual DOM. However, you have easy access to the currently bound data-item. The raw DOM event is hidden but can be accessed using `d3.event`. This is useful for stopping the event propagation (bubbling) `d3.event.stopPropagation()`or preventing the default behavior`d3.event.preventDefault()`. Moreover, the current context of the function `this` is the current DOM element.
725
+
Interactivity is event-driven as in the usual DOM. However, you have easy access to the currently bound data-item as the second argument to the event listener. The first argument is the DOM event itself, which is useful for stopping the event propagation (bubbling) or preventing the default behavior. Moreover, the current context of the function `this` is the current DOM element.
728
726
729
727
```js
730
728
constdata= [1, 2, 3];
@@ -738,8 +736,8 @@ const circles = d3
738
736
.attr("r", 10)
739
737
.attr("cy", 40)
740
738
.attr("cx", (d, i) =>30+ i *30)
741
-
.on("click", function (d, i) {
742
-
console.log(`clicked on: ${d} (${i})`);
739
+
.on("click", function (event, d) {
740
+
console.log(`clicked on: ${d}`);
743
741
constcircle=d3.select(this); // can't use arrow scoping
0 commit comments