Skip to main content
100%

Reusable Scatter Plot

✓ Published0🌍 Public
UUmarani Vemula
Last edited Jul 21, 2023
Created on Jul 21, 2023

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 description

Added axis titles and animation to the x-axis label.

A couple of questions when making this update:

  1. When using the ternary operator continue does not seem to work whithin a for loop. line 43 of index.js

  2. Need to call the plot() function before i is incremented. Is this related to the fact that this is an async function? So will i only be evaluated within call() and not when the scatterPlot() instance is created? line 65 of index.js

MIT Licensed

Similar vizzes