Skip to main content
100%

Fork of Exploring survey data interactively - y-axis

✓ Published1🌍 Public
DDhiva21
Last edited Feb 8, 2023
Created on Feb 8, 2023

This interactive bar chart explores survey data by grouping respondents by their academic subject preference on the x-axis while a dropdown menu selects the y-axis variable, such as average height or stress levels. The visualization uses d3.scaleBand and d3.scaleLinear to map the data, and a d3.select form element triggers a `selectionChanged` handler that updates the axis and bar heights using the general update pattern. Data is loaded from a remote JSON source and processed with d3.nest, d3.mean, and d3.sum to aggregate values per preference group.

AI-generated description

Interactive bar chart example

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

Steps

  • Find good example of update loop
  • Write a concept that uses interaction (changing scales?)
  • Set up basic chart
  • Set up interacion
  • 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 subject interest on 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

Inspiration

MIT Licensed

Similar vizzes