Selectable Chart Data

This example demonstrates how you can use a dropdown menu to allow a user to select, or filter, the data displayed on a column chart.

HTML

The select element will be used to filter the data for a column chart that will be inserted in the "chart2" div.

Javascript

Add the following code to the bottom of the setup() function. This will "listen" for changes to the dropdown selector and re-run the composeCharts() function when it is changed.

The following "viz.chart" function defines a column chart that will use the value selected by the user in the SQL to retrieve the right column of data to chart.

Last updated