This article explains how to populate graphs that dynamically create subsets. The examples contained in G2 only show hard-coded subsets and data.
The attached KB was created to show how to dynamically create subsets for G2 graphs as well as the screen recording showing the base for it.
These files can be shared with the customer if requested.
The code is complex and split into a few procedures. Therefore, it is best analyzed via the screen recording (Subsets.mp4) and demonstration KB (charts-subsets.kb).