/** * Public types used to configure [LegendModel](https://developers.arcgis.com/javascript/latest/references/core/legend/LegendModel/) and describe the legend elements generated by * [ActiveLayerInfo](https://developers.arcgis.com/javascript/latest/references/core/legend/ActiveLayerInfo/). * * These types can be used when rendering a custom legend independently of the Legend component. * * @since 5.2 */ import type Color from "../Color.js"; import type Layer from "../layers/Layer.js"; import type Sublayer from "../layers/support/Sublayer.js"; import type { RelationshipFocus } from "../renderers/support/types.js"; import type { SymbolUnion } from "../symbols/types.js"; /** Describes the schema of the ClusterTitle element. */ export interface ClusterTitle { /** Whether to show the count. */ showCount: boolean; } /** Describes the schema of the ColorRampElement used as a [legendElement](https://developers.arcgis.com/javascript/latest/references/core/legend/ActiveLayerInfo/#legendElements). */ export interface ColorRampElement { /** The type of this element is always `color-ramp`. */ type: "color-ramp"; /** The title of the color ramp as displayed in the legend. */ title?: RampTitle | string | null; /** * The * individual color stops rendered in the legend that correspond to the color visual variable in the renderer. */ infos: ColorRampStop[]; /** A preview of the element as displayed in the legend. */ preview?: HTMLElement | null; } /** * Describes the schema of the ColorRampStop element. Each ColorRampStop represents a single stop of the * [ColorVariable](https://developers.arcgis.com/javascript/latest/references/core/renderers/visualVariables/ColorVariable/) referenced in the renderer. */ export interface ColorRampStop { /** The value of the color visual variable [stop](https://developers.arcgis.com/javascript/latest/references/core/renderers/visualVariables/ColorVariable/#stops). */ value: number | string | null; /** The color of the visual variable [stop](https://developers.arcgis.com/javascript/latest/references/core/renderers/visualVariables/ColorVariable/#stops). */ color: Color; /** The label in the legend describing features with the given `color` and `value`. */ label: string | null; } /** Describes the schema of the DotDensityTitle element. */ export interface DotDensityTitle { /** The value. */ value: number; /** The unit. */ unit?: string | null; } /** Describes the schema of the HeatmapRampElement used as a [legendElement](https://developers.arcgis.com/javascript/latest/references/core/legend/ActiveLayerInfo/#legendElements). */ export interface HeatmapRampElement { /** The type of this element is always `heatmap-ramp`. */ type: "heatmap-ramp"; /** The title of the heatmap ramp as displayed in the legend. */ title?: RendererTitle | string | null; /** * The * individual color stops rendered in the legend that correspond to the heatmap colorStops in the renderer. */ infos: HeatmapRampStop[]; /** A preview of the element as displayed in the legend. */ preview?: HTMLElement | null; } /** * Describes the schema of the HeatmapRampStop element. Each HeatmapRampStop represents a single `colorStop` of the * [Heatmap color stops](https://developers.arcgis.com/javascript/latest/references/core/renderers/HeatmapRenderer/#colorStops) referenced in the renderer. */ export interface HeatmapRampStop { /** * The color of the pixel corresponding to the appropriate pixel `ratio`. This value is typically * between `0` and `1`. */ color: Color; /** * The ratio of a pixel's intensity value to the minPixelIntensity of the renderer. * The ratio of each pixel is matched to the corresponding color. */ ratio: number; /** * The label of the color stop displayed in the legend. Typically only the first and last * stops have labels. */ label: string; } /** * Properties defining the scheme of an ImageSymbolTableElementInfo. This applies only to * ImageryLayer renderers. */ export interface ImageSymbolTableElementInfo { /** The label of the category corresponding to the given image. */ label?: StretchMultibandTitle | string | null; /** The data URI of the image representing a colored pixel in the renderer. */ src: string; /** A preview of the image as displayed in the legend. */ preview?: HTMLElement | null; /** The aria-label for the preview element. */ previewAriaLabel?: RendererTitle | DotDensityTitle | string | null; /** The opacity of the image (`0` to `1`). */ opacity?: number | null; /** The width of the image in pixels. */ width?: number | null; /** The height of the image in pixels. */ height?: number | null; } /** * An object that defines a layer, optional sublayer IDs, and a custom title for legend display. * Use this to specify which layers and sublayers appear in the legend and how they are labeled with * [layerInfos](https://developers.arcgis.com/javascript/latest/references/core/legend/LegendModel/#layerInfos). */ export interface LayerInfo { /** A layer to display in the legend. */ layer: Layer | Sublayer; /** * Specifies a title for the layer to display above its symbols and descriptions. * If no title is specified the service name is used. */ title: string; /** * The IDs of the sublayers for which to display legend information. * Only applicable if the `layer` is a [MapImageLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/MapImageLayer/), [SubtypeGroupLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/SubtypeGroupLayer/) * or [WMSLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/WMSLayer/). */ sublayerIds?: number[]; } /** The allowed color names used in multilayer stretch legends. */ export type LegendColorName = "red" | "green" | "blue"; /** Represents the allowed values for the [LegendModel.state](https://developers.arcgis.com/javascript/latest/references/core/legend/LegendModel/#state) property. */ export type LegendModelState = "ready" | "disabled"; /** Properties defining the scheme of each supported [legend element](https://developers.arcgis.com/javascript/latest/references/core/legend/ActiveLayerInfo/#legendElements). */ export type LegendElement = SymbolTableElement | ColorRampElement | StretchRampElement | OpacityRampElement | SizeRampElement | HeatmapRampElement | RelationshipRampElement | UnivariateColorSizeRampElement | PieChartRampElement; /** Describes the schema of the OpacityRampElement used as a [legendElement](https://developers.arcgis.com/javascript/latest/references/core/legend/ActiveLayerInfo/#legendElements). */ export interface OpacityRampElement { /** The type of this element is always `opacity-ramp`. */ type: "opacity-ramp"; /** The title of the opacity ramp as displayed in the legend. */ title?: RampTitle | string | null; /** * The * individual opacity stops rendered in the legend that correspond to the opacity visual variable in the renderer. */ infos: OpacityRampStop[]; /** A preview of the element as displayed in the legend. */ preview?: HTMLElement | null; } /** * Describes the schema of the OpacityRampStop element. Each OpacityRampStop represents a single stop of the * [OpacityVariable](https://developers.arcgis.com/javascript/latest/references/core/renderers/visualVariables/OpacityVariable/) referenced in the renderer. The opacity value of * each stop is indicated in the [alpha](https://developers.arcgis.com/javascript/latest/references/core/Color/#a) property of the `color` object. */ export interface OpacityRampStop { /** The value of the opacity visual variable [stop](https://developers.arcgis.com/javascript/latest/references/core/renderers/visualVariables/OpacityVariable/#stops). */ value: number; /** * The color of the visual variable [stop](https://developers.arcgis.com/javascript/latest/references/core/renderers/visualVariables/OpacityVariable/#stops). * The opacity corresponding to the given `value` is indicated in the [alpha](https://developers.arcgis.com/javascript/latest/references/core/Color/#a) property of the color object. */ color: Color; /** The label in the legend describing features with the given `color` and `value`. */ label: string; } /** Describes the schema of the PieChartRampElement used as a [legendElement](https://developers.arcgis.com/javascript/latest/references/core/legend/ActiveLayerInfo/#legendElements). */ export interface PieChartRampElement { /** The type of this element is always `pie-chart-ramp`. */ type: "pie-chart-ramp"; /** The title of the color ramp as displayed in the legend. */ title?: RendererTitle | string | null; /** * The * individual color stops rendered in the legend that correspond to the color visual variable in the renderer. */ infos: SymbolTableElementInfo[]; /** A preview of the element as displayed in the legend. */ preview?: HTMLElement | null; } /** * Describes the schema of the RelationshipLabels element. These labels are rendered in the corners of the square * that represent the relationship renderer in the legend. */ export interface RelationshipLabels { /** * The label corresponding with the top corner of the legend if the focus * is set to `HH`. This * describes values that are considered high in both field 1 and field 2 (HH). */ top: string; /** * The label corresponding with the bottom corner of the legend if the focus is * set to `HH`. This * describes values that are considered low in both field 1 and field 2 (LL). */ bottom: string; /** * The label corresponding with the left corner of the legend (if the focus * is set to `HH`). This describes features where the value of field 1 is high and the value of field 2 is low (HL). */ left: string; /** The label corresponding with the right corner of the legend. */ right: string; } /** Describes the schema of the RelationshipRampElement used as a [legendElement](https://developers.arcgis.com/javascript/latest/references/core/legend/ActiveLayerInfo/#legendElements). */ export interface RelationshipRampElement { /** The type of this element is always `relationship-ramp`. */ type: "relationship-ramp"; /** * The number of classes for each field comprising the renderer. Can either * be 2, 3, or 4. */ numClasses: number; /** Determines the orientation of the Legend. Values can be `HH`, `HL`, `LH`, `LL`. */ focus: RelationshipFocus; /** A 2-dimensional array of colors as displayed in the legend grid. */ colors: Color[][]; /** * The labels for * each corner of the legend. */ labels: RelationshipLabels; /** * The rotation of the legend in degrees (0-360). `0` degrees displays the legend * as a square with the `LL` cell in the bottom left corner of the legend and the `HH` cell in the top right corner. */ rotation: number; /** The title of the renderer as displayed in the legend. */ title?: string | null; /** Info objects associated with the relationship renderer. */ infos?: any[] | null; } /** Describes the schema of the RampTitle element. */ export interface RampTitle { /** * The field name used in a visual variable of a renderer. This is used in the * generated title of the corresponding ramp in the legend. */ field?: string | null; /** * If provided, the normalization field name used in a visual variable of a renderer. * This is used in the generated title of the corresponding ramp in the legend. */ normField?: string | null; /** If `true`, the legend formats to display the field and normalization field as a ratio. */ ratio: boolean; /** If `true`, the legend formats to display the field and normalization field as a percentage. */ ratioPercent: boolean; /** If `true`, the legend formats to display the field and normalization field as a percentage of total. */ ratioPercentTotal: boolean; } /** Describes the schema of the RendererTitle element. */ export interface RendererTitle { /** The title of the renderer as displayed in the legend. */ title?: string | null; /** * The field name used in the renderer. This is used in the * generated title of the renderer in the legend. */ field?: string | null; /** * If a normalization field is provided to the renderer, this field * is also used in the generated title for the renderer in the legend. */ normField?: string | null; /** * Indicates if a percentage is used in the normalization of the * renderer. This is used to create a more readable legend for that scenario. */ normByPct?: boolean | null; } /** Describes the schema of the SizeRampElement used as a [legendElement](https://developers.arcgis.com/javascript/latest/references/core/legend/ActiveLayerInfo/#legendElements). */ export interface SizeRampElement { /** The type of this element is always `size-ramp`. */ type: "size-ramp"; /** The title of the size ramp as displayed in the legend. */ title?: ClusterTitle | RampTitle | string | null; /** * The * individual size stops rendered in the legend that correspond to the size visual variable in the renderer. */ infos: SizeRampStop[]; /** The theme of this element. */ theme?: "spike" | null; } /** * Describes the schema of the SizeRampStop element. Each SizeRampStop represents a single stop of the * [SizeVariable](https://developers.arcgis.com/javascript/latest/references/core/renderers/visualVariables/SizeVariable/) referenced in the renderer. */ export interface SizeRampStop { /** The label in the legend describing features with the given `symbol` and `value`. */ label: string; /** The value of the size visual variable [stop](https://developers.arcgis.com/javascript/latest/references/core/renderers/visualVariables/SizeVariable/#stops). */ value?: any | null; /** The symbol corresponding to the value of the stop in the renderer. */ symbol: SymbolUnion; /** The size of the visual variable [stop](https://developers.arcgis.com/javascript/latest/references/core/renderers/visualVariables/SizeVariable/#stops) in points. */ size?: number | { width: number; height: number; } | null; /** The width of the outline in points. */ outlineSize?: number | null; /** The HTML element rendered in the legend representing features with the given value. */ preview?: HTMLElement | null; } /** Describes the schema of the StretchMultibandTitle element. */ export interface StretchMultibandTitle { /** The color name. */ colorName: string; /** The band name. */ bandName: string; } /** Describes the schema of the StretchRampElement used as a [legendElement](https://developers.arcgis.com/javascript/latest/references/core/legend/ActiveLayerInfo/#legendElements). */ export interface StretchRampElement { /** The type of this element is always `stretch-ramp`. */ type: "stretch-ramp"; /** The title of the color ramp as displayed in the legend. */ title?: RampTitle | string | null; /** * The * individual color stops rendered in the legend that correspond to the color visual variable in the renderer. */ infos: ColorRampStop[]; /** A preview of the element as displayed in the legend. */ preview?: HTMLElement | null; } /** * Describes the schema of the SymbolTableElement used as a [legendElement](https://developers.arcgis.com/javascript/latest/references/core/legend/ActiveLayerInfo/#legendElements). This * legend element is used for [UniqueValueRenderer](https://developers.arcgis.com/javascript/latest/references/core/renderers/UniqueValueRenderer/) and * [ClassBreaksRenderer](https://developers.arcgis.com/javascript/latest/references/core/renderers/ClassBreaksRenderer/). */ export interface SymbolTableElement { /** The type of this element is always `symbol-table`. */ type: "symbol-table"; /** The title of the renderer as displayed in the legend. */ title?: RendererTitle | DotDensityTitle | string | null; /** * An * array of each symbol/category/break rendered for the symbol table. For example, this may be individual * breaks for a ClassBreaksRenderer, or unique values for a UniqueValueRenderer. */ infos: SymbolTableElementType[]; /** * Only used for renderers set to ImageryLayers. Indicates the type of * renderer set on the layer (e.g. `stretched` or `Unique Values`). */ legendType?: string | null; } /** Properties defining the scheme of the SymbolTableElementInfo. */ export interface SymbolTableElementInfo { /** The symbol for the corresponding `value` in the legend. */ symbol: SymbolUnion; /** The label of the symbol element as displayed in the legend. */ label?: RampTitle | string | null; /** The value corresponding with the given `symbol` in the legend. */ value?: any; /** The size of the symbol in points. */ size?: number | null; /** A preview of the symbol element as displayed in the legend. */ preview?: HTMLElement | null; /** The aria-label for the preview element. */ previewAriaLabel?: RendererTitle | DotDensityTitle | string | null; } /** Represents the allowed element types in a [legend element](https://developers.arcgis.com/javascript/latest/references/core/legend/ActiveLayerInfo/#legendElements) symbol table. */ export type SymbolTableElementType = ImageSymbolTableElementInfo | SymbolTableElementInfo | LegendElement; /** Describes the schema of the UnivariateColorSizeRampElement used as a [legendElement](https://developers.arcgis.com/javascript/latest/references/core/legend/ActiveLayerInfo/#legendElements). */ export interface UnivariateColorSizeRampElement { /** The type of this element is `univariate-above-and-below-ramp` or `univariate-color-size-ramp`. */ type: "univariate-above-and-below-ramp" | "univariate-color-size-ramp"; /** The title of the color ramp as displayed in the legend. */ title?: ClusterTitle | RampTitle | string | null; /** * The * individual color stops rendered in the legend that correspond to the color visual variable in the renderer. */ infos: (SizeRampElement | ColorRampElement)[]; /** A preview of the element as displayed in the legend. */ preview?: HTMLElement | null; }