Skip to main content
100%

Reusable D3 Scatterplot with Default Values

✓ Published1🌍 Public
MMatthew Bruffey
Last edited Jul 10, 2023
Created on Jul 9, 2023

This reusable scatterplot displays the Iris dataset, plotting petal width against sepal length with points encoded by species and adjustable point size, chart title, and axis labels. Built as a reusable D3 chart following Mike Bostock’s “Towards Reusable Charts” convention, it exposes setter functions for width, height, data, xValue, yValue, size, symbolValue, margin, and labels. The code uses D3 v3 APIs like `scaleLinear`, `scaleOrdinal`, `symbol`, `axisLeft`, and `axisBottom`. Axis ranges extend 10% beyond data extremes, and all options except data fall back to defaults when unspecified.

AI-generated description

A reusable D3 scatterplot built following the convention layed out in Mike Bostock's Towards Reusable Charts

Allows specification of a number of values including the size of the points, the accessor functions for x and y values, the symbols to be used for points, the chart title, and axes labels. When any of the options are not set (except for the data value) default values are supplied.

Axis ranges by default extend 10% above and below the smallest and largest data points. This prevents points from running into the axes which I think looks bad. There is currently no defined method to alter this behavior.

MIT Licensed

Similar vizzes