Skip to content
import { getThemes, getSchemes, getSchemeByName, getSchemesByTag, cloneScheme } from "@arcgis/core/smartMapping/symbology/pieChart.js";
Since
ArcGIS Maps SDK for JavaScript 4.24

Object containing helper methods for getting optimal color schemes used to create pie chart visualizations. The getSchemes() returns color schemes best suited to the given basemap for this visualization style.

Functions

getThemes

Function

Returns metadata for the available themes. If a basemap is provided, returns themes that work best with the given basemap.

Signature
getThemes (basemap?: Basemap | string): Theme[]
Parameters
ParameterTypeDescriptionRequired
basemap

The Esri basemap string or object that will be used with the returned theme(s).

Returns
Theme[]

Returns an object containing information about the available themes for the given basemap.

getSchemes

Function

Returns a primary scheme and secondary schemes defining properties for pie chart visualizations. The basemap parameter determines the colors used to visualize each pie slice.

Signature
getSchemes (params: GetSchemesParameters): PieChartSchemes | null | undefined
Parameters
ParameterTypeDescriptionRequired
params

The function parameters.

Returns
PieChartSchemes | null | undefined

Returns an object containing the optimal pie chart scheme to use for the given basemap; it also contains secondary schemes.

Example
// gets the primary scheme for the features of the given geometry type and basemap
const { primaryScheme, secondarySchemes } = pieChartSchemes.getSchemes({
basemap: map.basemap,
geometryType: featureLayer.geometryType
});
// primaryScheme is the suggested default scheme for the layer and basemap

getSchemeByName

Function

Returns a pie chart scheme with the given name.

Signature
getSchemeByName (params: GetSchemesByNameParameters): PieChartScheme | null | undefined
Parameters
ParameterTypeDescriptionRequired
params

The function parameters.

Returns
PieChartScheme | null | undefined

Returns the pie chart scheme with the given name.

Example
// Returns the Flower Field scheme
let flowerFieldScheme = pieChartSchemes.getSchemeByName({
name: "Flower Field",
basemap: map.basemap,
geometryType: featureLayer.geometryType
});

getSchemesByTag

Function

Returns an array of pie chart schemes with the provided tags. These schemes define properties for pie charts in any layer that can be rendered with a PieChartRenderer.

Signature
getSchemesByTag (params: GetSchemesByTagParameters): PieChartScheme[]
Parameters
ParameterTypeDescriptionRequired
params

The function parameters.

Returns
PieChartScheme[]

Returns an array of pie chart schemes either including or excluding the provided tags.

Example
let schemes = pieChartSchemes.getSchemesByTag({
includedTags: [ "types", "reds" ],
basemap: map.basemap,
geometryType: featureLayer.geometryType
});

cloneScheme

Function

Clones a pie chart scheme object.

Signature
cloneScheme (scheme: PieChartScheme | null | undefined): PieChartScheme | null | undefined
Parameters
ParameterTypeDescriptionRequired
scheme

The pie chart scheme object to clone.

Returns
PieChartScheme | null | undefined

Returns a clone of the given pie chart scheme object.

Example
// clones the primary scheme returned from the getSchemes() method
const pieChartScheme = primaryScheme.clone();

Type definitions

GetSchemesParameters

Type definition

geometryType

Property
Type
"point" | "polygon"

The geometry type of the features to visualize.

numColors

Property
Type
number

The number of unique values to include in the pie chart visualization.

basemap

Property
Type
Basemap | string | null | undefined

The Esri basemap to pair with the visualization. This value indicates the best color schemes for visualizing charts against the given basemap. If you have a non-Esri basemap (e.g. a VectorTileLayer basemap with a custom style) or no basemap at all, then use the basemapTheme parameter instead.

basemapTheme

Property
Type
BasemapTheme | null | undefined

If you have a non-Esri basemap (e.g. a VectorTileLayer basemap with a custom style) or no basemap at all, use this parameter to indicate whether the background of the visualization is light or dark.

GetSchemesByNameParameters

Type definition

name

Property
Type
string

The name of the scheme to retrieve.

GetSchemesByTagParameters

Type definition

includedTags

Property
Type
string[] | null | undefined

When provided, only schemes containing all the matching tags will be returned.

Known Tags: light | dark | reds | yellows | oranges | greens | blues | purples | pinks | browns | grays | bright | subdued | deuteranopia | protanopia | tritanopia | grayscale | types | dot-density

excludedTags

Property
Type
string[] | null | undefined

When provided, only schemes missing all the provided tags will be returned.

Known Tags: light | dark | reds | yellows | oranges | greens | blues | purples | pinks | browns | grays | bright | subdued | deuteranopia | protanopia | tritanopia | grayscale | types | dot-density