Skip to main content
100%

D3 Mouse Events

✓ Published0🌍 Public
WWilliamQLiu
Last edited Nov 17, 2014
Created on Nov 17, 2014

This example demonstrates interactive mouse events in D3.js using SVG circles positioned on a scatterplot with linear scales and axes. Hovering over a circle changes its fill color to orange, doubles its radius, and displays a text label showing its x and y coordinates; moving the mouse away restores the original black fill and size. Clicking on the SVG background converts pixel coordinates to data values via `xScale.invert` and `yScale.invert`, appends the new point to the dataset, and redraws the circle. The code uses `d3.svg.axis`, `d3.scale.linear`, and D3 v3 event handlers `.on("mouseover")`, `.on("mouseout")`, and `.on("click")`.

AI-generated description

Similar vizzes