Hi,
The methods you found seem to be from our .NET API and are for changing the definitions of the states themselves on a metric set. (States are part of the metric set so that they can be reused in different visualizations.) You can set up more than one state group through the UI so I wouldn’t think these methods are necessary, it’s just that for gauges, only one state group can be shown as ranges at one time.
If you’ve already set up two state groups and want to switch between them using script like you can with the Range State Group dropdown in your screenshot, this dropdown is in the Properties window for your gauge, and there is an equivalent property on gauges in the JavaScript API: Gauge.stateGroupId Property (dundas.com) You would need to set it to the state group ID from the metric set, which is available through script - for example:
gauge.stateGroupId = gauge.metricSetBindings[0].dataResult.metricSet.stateGroups[0].id
Just mentioning that you could do something similar using formulas with parameters instead, setting up states to compare your data against the formulas. Each formula could take input directly from the user via a connected numeric filter, or else use some logic in the formula script to determine the values.