ClassBreaksRenderer Dynamic field property?

426
1
07-22-2019 08:29 PM
EricFeminella
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
Noah-Sager
Esri Regular Contributor

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

DefaultValue

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

Replaces an empty value with a provided default value.

NameTypeDescription
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.

Doc

https://developers.arcgis.com/arcade/function-reference/logical_functions/

Using DefaultValue in a 4x sample for labeling

https://developers.arcgis.com/javascript/latest/sample-code/sandbox/index.html?sample=symbols-points...

0 Kudos