Reusable Scatter Plot with d3.js
✓ Published0🌍 Public
This example demonstrates a reusable scatter plot function built with D3 v6, rendered as SVG. It maps quantitative x and y values to positions using `d3.scaleLinear` and draws circles as data points, with axes generated by `d3.axisBottom` and `d3.axisLeft`. The code uses the D3 selection and enter-append pattern to bind sample data, and includes labels for both axes. The plot is encapsulated within a `createScatterPlot` function, allowing it to be called with custom data and dimensions. Loading D3 via UNPKG, the example also shows an ES6 module import in `myMessage.js`.
AI-generated descriptionAn example showing the capabilities of VizHub:
- Loads D3 via UNPKG.
- Demonstrates use of
importfrom"d3". - Demonstrates use of
importfrom local ES6 modules.
MIT Licensed