D3 Scatter Plot triggering alerts as tooltips (Vanilla JS)
✓ Published0🌍 Public
This example renders an interactive scatter plot of the classic Iris dataset, loaded from a CSV file via d3.csv. The visualization maps petal length to the x-axis and sepal length to the y-axis using d3.scaleLinear, d3.extent, and d3.axisLeft/axisBottom for the axes. Circles are drawn as SVG elements with d3.selectAll and .join, and hovering over a point triggers a JavaScript alert displaying the approximate coordinates, which are computed by inverting the scale with x.invert. The plot fills the entire browser window, using the viewport dimensions for the chart’s width and height.
AI-generated descriptionHover the mouse pointer over a point...
A bare minimum HTML page demonstrating use of CSS and JavaScript.
See also React Starter.
MIT Licensed