ClassBreaksRenderer Dynamic field property?

07-22-2019 08:29 PM
New Contributor

We are in the process of migrating from ESRI JS 3.28 to 4.12, and I am trying to determine how one can dynamically set the ClassBreaksRenderer field attribute?

For instance, given the field attribute docs as an example (see below), assume that in the absence of the “totalAcres” property’s having a value, how can I fallback to another attribute on the feature, say, “totalAcres2”?

ClassBreaksRenderer | ArcGIS API for JavaScript 4.12 

Is there a simple way to accomplish this? The field attribute is of type string and so I can’t seem to find an alternative. I’ve explored using Arcade expressions but feel there must be an easier way to specify which field to use at runtime.

Any help would be greatly appreciated.

0 Kudos
1 Reply
Esri Regular Contributor

You could try using `DefaultValue`, which is a logical expression in Arcade.


DefaultValue( value, defaultValue? ) -> returns: *

Replaces an empty value with a provided default value.

value*The input value to compare against null or ''. This may be a value of any type. However, if this value is an empty array, then the empty array will be returned.
defaultValue*optional Return this value if the provided value is empty. This may be a value of any type.


Using DefaultValue in a 4x sample for labeling

0 Kudos