Select Data
Terms defined: event handler, form, query parameter, Uniform Resource Locator (URL)
server.py
creates a form with checkboxes for every sex in the data- Add
onload
event handler tobody
element to display chart when browser first loads page- Use the default settings in the form to ensure consistent behavior
static/dashboard.js
turns form data into query parameters and appends them to the URL- Checkbox's value is only present if it is ticked
select_data(…)
in../shared/util.py
selects data based on those query parameters- Partition data according to sex
- First version didn't specify colors, so point colors changed when data subsetted
- Selector buttons would also change order
- Solution is to order everything explicitly
Run
python server.py --seed 12345
- Go to http://127.0.0.1/5000
- Change the checkboxes
- Click the button to fetch data and redisplay chart