Reusable Scatter Plot
This animated scatter plot cycles through the numeric attributes of the Iris dataset, sequentially updating the x-axis to display sepal length, sepal width, petal length, and petal width while keeping petal width on the y-axis. The visualization uses D3's `scaleLinear`, `axisBottom`, and `axisLeft` to render axes, with `transition` controlling the smooth repositioning of circles and axis titles every three seconds. The reusable chart component, built with a custom `scatterPlot` factory, supports setters for data, dimensions, and accessors. Data loads via D3's `csv` from a GitHub Gist, with SVG circles animated through enter, update, and exit joins.
AI-generated descriptionAdded axis titles and animation to the x-axis label.
A couple of questions when making this update:
When using the ternary operator
continuedoes not seem to work whithin aforloop. line 43 of index.jsNeed to call the
plot()function beforeiis incremented. Is this related to the fact that this is anasyncfunction? So willionly be evaluated withincall()and not when thescatterPlot()instance is created? line 65 of index.js