require(["esri/renderers/support/utils"], (rendererUtils) => { /* code goes here */ });
import * as rendererUtils from "@arcgis/core/renderers/support/utils.js";
esri/renderers/support/utils
Various utilities for accessing renderer colors that match to fields, Arcade expressions, or values.
Method Overview
Name | Return Type | Summary | Object |
---|---|---|---|
Promise<FieldToValueColorMap> | Resolves with a FieldToValueColorMap that contains the fields and a map of values to its matched color in the renderer. | utils | |
Resolves with a Map of fields matched to the color that the field is represented by in the renderer. | utils |
Method Details
-
getColorsForRendererValues
getColorsForRendererValues(renderer){Promise<FieldToValueColorMap>}
-
Resolves with a FieldToValueColorMap that contains the fields and a map of values to its matched color in the renderer. If the renderer has a default symbol, the string value in the returned FieldToValueColorMap will be "default".
ParameterThe renderer from which to match values with their associated colors.
ReturnsType Description Promise<FieldToValueColorMap> Resolves with a FieldToValueColorMap. Exampleconst fieldToValueColorMap = await rendererUtils.getColorsForRendererValues(renderer); // Loop through the returned fieldToValueColorMap to access the fields and their matching ValueToColorMap object. for (const expressionOrField in Object.fromEntries(fieldToValueColorMap)) { const valueToColorMap = fieldToValueColorMap.get(expressionOrField); }
-
Resolves with a Map of fields matched to the color that the field is represented by in the renderer. If the renderer has a default symbol, the string returned in the map will be "default".
Parameterrenderer ClassBreaksRenderer|DotDensityRenderer|HeatmapRenderer|PieChartRenderer|SimpleRenderer|UniqueValueRendererThe renderer from which to extract fields and their associated matching colors.
ReturnsExampleconst fieldToColorMap = await rendererUtils.getColorsFromRenderer(renderer); // Loop through the returned fieldToColorMap to access the fields and their matching color. for (const field in Object.fromEntries(fieldToColorMap)) { const color = fieldToColorMap.get(field); }
Type Definitions
-
FieldToValueColorMap
FieldToValueColorMap Map<string, ValueToColorMap>
-
A mapping of the field or Arcade expression to a ValueToColorMap object.
-
A Map object that holds a renderer value and its corresponding color. Type definition for FieldToValueColorMap.