UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

318 lines (315 loc) • 19 kB
import type Collection from "../core/Collection.js"; import type Layer from "./Layer.js"; import type KnowledgeGraphSublayer from "./knowledgeGraph/KnowledgeGraphSublayer.js"; import type LayoutSettings from "../linkChart/LayoutSettings.js"; import type EntityType from "../rest/knowledgeGraph/EntityType.js"; import type RelationshipType from "../rest/knowledgeGraph/RelationshipType.js"; import type { MultiOriginJSONSupportMixin } from "../core/MultiOriginJSONSupport.js"; import type { LayoutMode, InclusionModeDefinition } from "./knowledgeGraph/types.js"; import type { BlendLayer, BlendLayerProperties } from "./mixins/BlendLayer.js"; import type { OperationalLayer, OperationalLayerProperties } from "./mixins/OperationalLayer.js"; import type { ScaleRangeLayer, ScaleRangeLayerProperties } from "./mixins/ScaleRangeLayer.js"; import type { LayerProperties } from "./Layer.js"; export interface LinkChartLayerProperties extends LayerProperties, ScaleRangeLayerProperties, BlendLayerProperties, OperationalLayerProperties, Partial<Pick<LinkChartLayer, "initializationInclusionModeDefinition" | "initializationLinkChartConfig" | "memberEntityTypes" | "memberRelationshipTypes" | "url">> { /** An optional title for the LinkChartLayer. */ title?: string | null; } /** Defines the initial layout for the link chart and any layout settings for newly created link chart layers. */ export interface InitializationLinkChartConfig { /** The layout mode to be applied by default. The system default is `organic-standard`. */ layoutMode?: LayoutMode; /** * By default, the layout algorithm always runs on link charts when they are first created. * If all diagram locations are set for every entity in the inclusion definition, this property can be set to `true` which skips the layout algorithm step and increases the performance of larger link charts. */ doNotRecalculateLayout?: boolean; /** Additional layout options for the default layout configuration. */ layoutSettings?: LayoutSettings; } /** * A LinkChartLayer is a composite layer that can be created from a * [knowledge graph service](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraphService/). * The layer contains [sublayers](https://developers.arcgis.com/javascript/latest/references/core/layers/LinkChartLayer/#layers) for each [entity type](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/EntityType/) * and [relationship type](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/RelationshipType/) contained in the LinkChartLayer. * * Entity and relationship types have [geometries](https://developers.arcgis.com/javascript/latest/references/core/geometry/Geometry/) * that allows them to be rendered in a LinkChartView or as a * [Graphic](https://developers.arcgis.com/javascript/latest/references/core/Graphic/) with spatial context. They also contain data * [Graphic.attributes](https://developers.arcgis.com/javascript/latest/references/core/Graphic/#attributes) that provide additional information about * the real-world feature it represents; Attributes may be viewed in [popups](https://developers.arcgis.com/javascript/latest/references/core/layers/knowledgeGraph/KnowledgeGraphSublayer/#popupTemplate) * and used for [rendering](https://developers.arcgis.com/javascript/latest/references/core/renderers/Renderer/) the layer. * Sublayers may be [queried](https://developers.arcgis.com/javascript/latest/references/core/layers/knowledgeGraph/KnowledgeGraphSublayer/#queryFeatures), [analyzed](https://developers.arcgis.com/javascript/latest/spatial-analysis/intro-geometry-operators/), * and [rendered](https://developers.arcgis.com/javascript/latest/references/core/layers/knowledgeGraph/KnowledgeGraphSublayer/#renderer) to visualize data in a spatial context. * * * > [!WARNING] * > * > **Implementation Note** * > * > Link chart layers are not dynamic. If no inclusion definition is specified, the inclusion definition will be defined as all records * > in the graph at the time of layer creation. If a named type is specified with no explicit members, then all records of that named * > type will be defined as the inclusion definition. Any data added to the graph or named type after this point will not be included in * > the link chart. * * * ### Create Link Chart Layer * * To create a LinkChartLayer from [knowledgeGraphService](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraphService/), you must set the [url](https://developers.arcgis.com/javascript/latest/references/core/layers/LinkChartLayer/#url) property * to the REST endpoint of the service. For a layer to be visible in a view, it must be added to the WebLinkChart * referenced by the view. See [WebLinkChart](https://developers.arcgis.com/javascript/latest/references/core/WebLinkChart/) for information about adding layers to a WebLinkChart. * * ```js * const [LinkChartLayer, WebLinkChart, LinkChartView] = await $arcgis.import([ * "@arcgis/core/layers/LinkChartLayer.js", * "@arcgis/core/WebLinkChart.js", * "@arcgis/core/LinkChartView.js" * ]); * const myLinkChartLayer = new LinkChartLayer({ * title: "link chart layer", * url: "https://sampleserver7.arcgisonline.com/arcgis/rest/services/Hosted/SmallBumbleBees/KnowledgeGraphServer" * }); * myLinkChartLayer.load().then(()=>{ * const linkchart = new WebLinkChart({ * layers: [myLinkChartLayer] * }); * }) * ``` * * @since 4.31 * @see [WebLinkChart](https://developers.arcgis.com/javascript/latest/references/core/WebLinkChart/) * @see [KnowledgeGraphSublayer](https://developers.arcgis.com/javascript/latest/references/core/layers/knowledgeGraph/KnowledgeGraphSublayer/) * @see [knowledgeGraphService](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraphService/) * @see [KnowledgeGraphLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/KnowledgeGraphLayer/) */ export default class LinkChartLayer extends LinkChartLayerSuperclass { constructor(properties?: LinkChartLayerProperties); /** * Defines a set of [named types](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/GraphNamedObject/) and/or * [entities](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/Entity/) * and [relationships](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/Relationship/) to be included in the layer. * If only a named type is specified, all instances of that type will be included * in the layer. [Sublayers](https://developers.arcgis.com/javascript/latest/references/core/layers/knowledgeGraph/KnowledgeGraphSublayer/) can be created for all named types * in the graph even if they have no instances specified in the member definition. The inclusion definition is not permanently dynamic. * It captures the data at the time of creation. For example, if `generateAllSublayers` is `true` and a new entity type is added to the knowledge graph, * that new entity type will not be added to the inclusion list. Similarly, if `useAllData` is `true` for a type, and a new record is added to * that type, the newly added record will not be automatically added to the inclusionList. * * > [!IMPORTANT] * > * > **Constructor Only** * > * > This property is only supported when passed to the constructor on the first initialization of a link chart layer. * > Use [WebLinkChart.addRecords()](https://developers.arcgis.com/javascript/latest/references/core/WebLinkChart/#addRecords) and [WebLinkChart.removeRecords()](https://developers.arcgis.com/javascript/latest/references/core/WebLinkChart/#removeRecords) to change the membership of the layer after initialization. * * @example * // constructing an inclusion list: * // The exact record ids of each of the records of a specific named type (entity type or relationship type) * // to include in the layer. In this case the layer will contain one record * const layerInclusionMemberDefinition = new Map(); * layerInclusionMemberDefinition.set("{1A4W8G4-W52G-W89G-1W5G-J1R4S8H52H4S}",{id:"{1A4W8G4-W52G-W89G-1W5G-J1R4S8H52H4S}"}) * * //The layerInclusionDefinition specifies whether to use all of the data in a named type or only the records * // specified in the 'members' list. In this case we only want the records specified. * const layerInclusionDefinition = { * useAllData: false, //only include instances in the member list * members: layerInclusionMemberDefinition * }; * * // The namedTypeDefinition is a map of the typeName of each type to be included. * // In this case we are only including the "Observation" entity type. * // The layerInclusionDefinition specifies exactly which "Observation" entities to include in the layer. * const namedTypeDefinition = new Map(); * namedTypeDefinition.set("Observation", layerInclusionDefinition); * * // Specify if a sublayer should be generated for all named types. * // If true, a sublayer will be created for all named types regardless of * // whether they have a list of instances to include or not. * // If there are no instances the sublayer will be empty. In this case we have set 'generateAllSubLayers' to false so the * // layer will only contain sublayers for the named types (entity types or relationship types) that are specified * // in the namedTypeDefinitions. * // Also defines the collection of named types to include in the layer. * const inclusionListDefinition = { * generateAllSublayers: false, //only create sublayers for the named types in the namedTypeDefinition * namedTypeDefinitions: namedTypeDefinition * } * @example * //examples of the initializationInclusionModeDefinition structure inside the LinkChartLayer * * //the layer will only contain one sublayer (for 'supplier') and that sublayer will consist of one entity. * { * generateAllSublayers: false, * namedTypeDefinition:[{ * key: "supplier", * value:{ * useAllData: false, * members: [{ * key: "{1A4W8G4-W52G-W89G-1W5G-J1R4S8H52H4S}", * value: { * id: "{1A4W8G4-W52G-W89G-1W5G-J1R4S8H52H4S}", * } * }] * } * }] * } * * // this layer will contain a sublayer for all named types in the graph * // ('Observation', 'User', 'Species', "Observed", "Reviewed", "ObservedIn") * // but only the 'Observation' sublayer will contain data. * // The Observation sublayer will contain exactly one entity. * { * generateAllSublayers: true, * namedTypeDefinition:[{ * key: "Observation", * value:{ * useAllData: false, * members: [{ * key: "{32CBD5CB-EE31-4714-B14F-57BFE36AE094}", * value: { * id: "{32CBD5CB-EE31-4714-B14F-57BFE36AE094}", * } * }] * } * }] * } * * // this layer will contain a sublayer for all named types in the graph * // ('Observation', 'User', 'Species', "Observed", "Reviewed", "ObservedIn") * // but only the 'Observation' sublayer will contain data. * // the 'Observation' sublayer will contain all instance of the Observation entity type * { * generateAllSublayers: true, * namedTypeDefinition:[{ * key: "Observation", * value:{ * useAllData: true * } * }] * } * * // A more complex example: * { * //sublayers will only be created for the types listed * generateAllSublayers: false, * namedTypeDefinitions: { * //include all `Species` entities that exist at the time the layer is created * Species: { * useAllData: true * }, * //include all `User` entities that exist at the time the layer is created * User: { * useAllData: true * }, * //include all only the specified `Observation` entities * Observation: { * useAllData:false, * members: { * "{941A7425-C45D-4940-A2E8-F3611973EC8A}": { * id: "{941A7425-C45D-4940-A2E8-F3611973EC8A}" * }, * "{94DC1D53-4043-4D0B-8CF7-18B690414118}": { * id: "{94DC1D53-4043-4D0B-8CF7-18B690414118}" * }, * //This entity has a fixed location so will remain in the same place regardless of the layout applied. * //the other entities will move around it * "{4E1D1ACE-6252-4BA4-B76E-CDEDFE9B0AB1}": { * id: "{4E1D1ACE-6252-4BA4-B76E-CDEDFE9B0AB1}", * }, * "{559312DF-893C-44E2-AD86-BAA73CD49719}": { * id: "{559312DF-893C-44E2-AD86-BAA73CD49719}" * }, * "{158A2D46-3EFF-4479-BC57-E6981FCB80B6}": { * id: "{158A2D46-3EFF-4479-BC57-E6981FCB80B6}" * }, * "{40AD70FC-CD7D-4928-B555-38EA49675944}": { * id: "{40AD70FC-CD7D-4928-B555-38EA49675944}" * }, * "{3A5B8F11-5971-4A46-99AC-F509CA59B517}": { * id: "{3A5B8F11-5971-4A46-99AC-F509CA59B517}" * } * } * }, * //include all `Observed` relationships that exist at the time the layer is created * Observed: { * useAllData: true * }, * //include all `ObservedIn` relationships that exist at the time the layer is created * ObservedIn: { * useAllData: true * } * } * } */ accessor initializationInclusionModeDefinition: InclusionModeDefinition; /** * The default configuration options for a new link chart layer. This includes the layout and any layout settings for * the initial view of the layer. * * > [!IMPORTANT] * > * > **Constructor Only** * > * > This property is only supported when passed to the constructor on the first initialization of a link chart layer. * > Use [WebLinkChart.applyLayout()](https://developers.arcgis.com/javascript/latest/references/core/WebLinkChart/#applyLayout) to update the layout and layout settings after initialization. */ accessor initializationLinkChartConfig: InitializationLinkChartConfig | null | undefined; /** * A collection of operational [sublayers](https://developers.arcgis.com/javascript/latest/references/core/layers/knowledgeGraph/KnowledgeGraphSublayer/). * Each sublayer represents an [entity type](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/EntityType/) or * [relationship type](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/RelationshipType/) in the graph. * * Each feature contained in each sublayer has a [Geometry](https://developers.arcgis.com/javascript/latest/references/core/geometry/Geometry/) * that allows it to be rendered as a [Graphic](https://developers.arcgis.com/javascript/latest/references/core/Graphic/) with spatial context on the [View](https://developers.arcgis.com/javascript/latest/references/core/views/View/). * In `GEOGRAPHIC` layout mode, any spatial entities with [Geometry](https://developers.arcgis.com/javascript/latest/references/core/geometry/Geometry/) will be drawn at their appropriate locations. * All non-spatial entities will be arrayed around the spatial entities they relate to. * In all other layouts, the geometry for each entity is its location on the link chart. * The location of specific instances can be set so that when the layout mode changes or the link chart is reloaded, they remain in the same * spot. * * Features within the layer may also contain data [Graphic.attributes](https://developers.arcgis.com/javascript/latest/references/core/Graphic/#attributes) that provide additional information that may be viewed in a [Popup](https://developers.arcgis.com/javascript/latest/references/core/widgets/Popup/). * These layers can also be [queried](https://developers.arcgis.com/javascript/latest/references/core/layers/knowledgeGraph/KnowledgeGraphSublayer/#queryFeatures) and [analyzed](https://developers.arcgis.com/javascript/latest/spatial-analysis/intro-geometry-operators/). * * @example * //to access individual sublayers to add or modify properties such as the renderer, popups and labels * LinkChartLayer.layers.forEach((sublayer)=>{ * sublayer.popupTemplate = new PopupTemplate({ * title: "{common_name}", * content: [{ * type: "text", * text: "Scientific Name: {name}" * }] * }); * }) */ get layers(): Collection<KnowledgeGraphSublayer>; /** * The [entity types](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/EntityType/) included in the LinkChartLayer. * * @since 4.32 */ accessor memberEntityTypes: EntityType[]; /** * The [relationship types](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/RelationshipType/) included in the LinkChartLayer. * * @since 4.32 */ accessor memberRelationshipTypes: RelationshipType[]; /** * All non-spatial [entity type](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/EntityType/) and [relationship type](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraph/RelationshipType/) * [sublayers](https://developers.arcgis.com/javascript/latest/references/core/layers/knowledgeGraph/KnowledgeGraphSublayer/). They have the same structure as the spatial [sublayers](https://developers.arcgis.com/javascript/latest/references/core/layers/LinkChartLayer/#layers) but the `geometryType` is null. * These layers can also be [queried](https://developers.arcgis.com/javascript/latest/references/core/layers/knowledgeGraph/KnowledgeGraphSublayer/#queryFeatures) and [analyzed](https://developers.arcgis.com/javascript/latest/spatial-analysis/intro-geometry-operators/). * All link chart sublayers are considered spatial because they have a diagram location. */ get tables(): Collection<KnowledgeGraphSublayer>; /** An optional title for the LinkChartLayer. */ accessor title: string | null | undefined; /** The url of the [knowledge graph service](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraphService/). */ accessor url: string; /** Calculates the layout for the link chart and refreshes the link chart with the new layout. */ applyNewLinkChartLayout(): Promise<void>; /** * Loads layer assuming that data for all of the members defined in the [initializationInclusionModeDefinition](https://developers.arcgis.com/javascript/latest/references/core/layers/LinkChartLayer/#initializationInclusionModeDefinition) is already loaded into local storage. * This will optimize layer load times. */ loadLayerAssumingLocalCache(): void; } declare const LinkChartLayerSuperclass: typeof Layer & typeof MultiOriginJSONSupportMixin & typeof ScaleRangeLayer & typeof BlendLayer & typeof OperationalLayer