Build a demographic bar chart
We'll explain below how to build an Apache Superset chart with one more example, in which we are going to build ...
- ... a bar-type chart ...
- ... to show the distribution by age of adults over 18 ...
- ... separately by males and females;
- The age sub-ranges of our interest are:
0 - 17
18 - 24
25 - 34
35 - 44
45 - 59
60+
- Click the +Chart on the Charts page on the Apache Superset home screen.
- On the Select dataset list, click the IREX event database name, "kx_events" in our case.
- In the Choose chart type workspace, click Bar chart.
- Click Create new chart to open the next screen, for formulating the query conditions to extract the relevant data from the database.
- Enter the chart name, e.g., "Demographic groups".
- We would like to have age plotted along the X-axis on the chart, split by the sub-ranges of our interest. This age value is stored in face_age column of the event database. The sub-ranges by age can be built with the following SQL query in the X-axis field:
-
Metrics defines the metric displayed on the chart. In this example, it is the number of people in each age category, or COUNT in SQL terms. So, select COUNT in the Metrics and then click Save.
- Dimensions are the attributes by which we are going to categorize chart data. In this example, it is gender. The genders are in the face_gender column, so select face_gender in Dimensions and then click Save.
- Age estimate can only be produced by FaceTrack Pro. so add a "module In KX.Faces" filter in Filters.
-
Click Create chart below to send a query to the IREX event database for data matching the conditions formulated at the steps. The query is executed and the resulting chart is displayed.
-
Use the options on the Customize tab to customize the chart, e.g., stack the bars, change color scheme, etc.
- Click Save in the upper-right corner of the screen to complete the chart saving dialog.
Then click Save.