Skip to main content
Public

Share visualization

Loading preview…

Fork of Exploring survey data interactively - both axes

vizhub.com

Shared links may look like this on X, LinkedIn, Slack, and Discord.

Before sharing, review the publishing checklist.

Choose how to deliver this visualization

LinkedIn caption

LinkedIn may not keep text supplied by the share sheet. Copy the caption and paste it into the post if needed. You can tag the VizHub company page when posting.

More options

Embed on a websiteCopy iframe embed code
Download & exportPNG, HTML, source ZIP

Fork of Exploring survey data interactively - both axes

0
Yyingzhe-z
Last edited Apr 2, 2021
Created on Apr 2, 2021

This interactive scatterplot lets viewers explore survey data by changing both the x- and y-axis variables through dropdown menus. The visualization uses the D3.js general update pattern to dynamically re-nest data, update scales, and redraw SVG rectangles with enter, update, and exit selections. The x-axis groups respondents by categorical preferences or gender, while the y-axis displays averages for numeric variables like height, stress, or expenses. Data loads as JSON via `d3.json`, with axes rendered using `d3.axisBottom` and `d3.axisLeft`.

AI-generated description

Dynamic axes using the update pattern example

In this visualization, the data that's rendered in the view changes because of user interaction

Steps

  • Make the nesting dynamic
  • Nest on health, stress dynamically
  • Make x-axis interactive so remove and enter are also needed

Concept

A chart showing distribution or relation between to variables. The vriables can be chosen through a dropdown menu resulting in a rerendering of datapoints and axis.

  • Group students by a variable on the x axis.
  • Get data from different vars on y axis

Notes

  • Note that d3 has a new way of handling enter, update and exit explicitly as explained in this article.
  • The options in the form are generated from the data using a data join
  • The scales, the data and the selected opton are global. I found that to be nicer than to keep passing them everywhere
  • If you want to add a new option to this interactive graph, all you have to do is add a new computed variable in the prepareData module and everything else will happen automatic
  • Observe how prepareData module now exports 2 functions separately which we can use to have greater control over the transformation of data from our index.js file.

Inspiration

Comments

Sign in to join the discussion.

MIT Licensed