UNPKG

@arcgis/core

Version:

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

3 lines (2 loc) 7.11 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.19/LICENSE.txt */ import{__decorate as t}from"tslib";import a from"./Basemap.js";import e from"./WebDocument2D.js";import{deprecated as r}from"./core/deprecate.js";import i from"./core/Error.js";import n from"./core/Logger.js";import o from"./core/Version.js";import{property as s,subclass as h}from"./core/accessorSupport/decorators.js";import l from"./layers/LinkChartLayer.js";import{getInclusionDefinitionFromCypherResults as c,getInclusionDefinitionFromIdTypePairs as y}from"./layers/knowledgeGraph/layerUtils.js";import{getDefaultChronologicalOverlayLayerId as k,getChronologicalOverlay as p}from"./layers/knowledgeGraph/supportUtils.js";import L from"./linkChart/LayoutSettings.js";import d from"./linkChart/LinkChartProperties.js";import C from"./linkChart/NonspatialDataDisplay.js";import u from"./webmap/InitialViewProperties.js";import{currentVersion as w}from"./webmap/utils.js";var m;const f={currentVersion:w,createInitialViewProperties:()=>new u,parseVersion:o.parse,itemType:"Web Link Chart",name:"linkchart",origin:"link-chart"};let g=m=class extends e{constructor(t){super(t),this.mapType="webLinkChart",this.linkChartProperties=new d}get activeLinkChartLayer(){return this.layers.find(({type:t})=>"link-chart"===t)}get context(){return f}async applyLayout(t="organic-standard",e){if(await this.load(),!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");"geographic-organic-standard"!==t||this.basemap?.baseLayers?.length||(this.basemap=a.fromId("topo-vector"),await(this.basemap?.load())),this.linkChartProperties.layoutType=t;const o=e?.layoutSettings??this.linkChartProperties.layoutSettings??new L;this.linkChartProperties.layoutSettings=o;let{lockedNodeLocations:s,lockedEntityLocations:h,...l}=e??{};!h&&s?(r(n.getLogger(this),"WebLinkChart:applyLayout - WebLinkChartApplyLayoutOptions.lockedNodeLocations is deprecated.",{replacement:"Use WebLinkChartApplyLayoutOptions.lockedEntityLocations instead.",version:"5.0"}),h=s):h&&s&&r(n.getLogger(this),"WebLinkChart:applyLayout - both lockedNodeLocations (deprecated in 5.0) and lockedEntityLocations are defined. Use WebLinkChartApplyLayoutOptions.lockedEntityLocations only instead.",{replacement:"Use WebLinkChartApplyLayoutOptions.lockedEntityLocations instead.",version:"5.0"});const c={...l,...h?{lockedEntityLocations:h}:{},layoutSettings:o};return this.activeLinkChartLayer.applyNewLinkChartLayout(t,c)}changeNonspatialDataDisplay(t){if(!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");this.linkChartProperties.nonspatialDataDisplay||(this.linkChartProperties.nonspatialDataDisplay=new C),this.linkChartProperties.nonspatialDataDisplay.mode=t}async addRecords(t,a){if(await this.load(),!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");return this.activeLinkChartLayer.addRecords(t,a)}async createSublayerForNamedType(t){if(await this.load(),!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");return this.activeLinkChartLayer.createSublayerForNamedType(t)}async removeRecords(t){if(await this.load(),!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");return this.activeLinkChartLayer.removeRecords(t)}async expand(t,a){if(await this.load(),!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");const e=await this.activeLinkChartLayer.expand(t,a);return e?.records??[]}async refreshLinkChartData(t){if(await this.load(),!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");return this.activeLinkChartLayer.refreshLinkChartCache(t)}async connectBetweenEntities(t,a){if(await this.load(),!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");const e=await this.activeLinkChartLayer.connectBetweenEntities(t,a);return e?.records??[]}async connectFromEntities(t,a){if(await this.load(),!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");const e=await this.activeLinkChartLayer.connectFromEntities(t,a);return e?.records??[]}getMemberIdsByType(t){if(!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");return Array.from(this.activeLinkChartLayer?.dataManager.sublayerCaches.get(t)?.keys()??[])}get diagramNodesExtent(){if(!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");return this.activeLinkChartLayer.linkChartExtent}get entityCount(){if(!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");return this.activeLinkChartLayer.entityLinkChartDiagramLookup.size}get relationshipCount(){if(!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");return this.activeLinkChartLayer.relationshipLinkChartDiagramLookup.size}get knowledgeGraph(){if(!this.activeLinkChartLayer)throw new i("WebLinkChart:no-link-chart-layer","No link chart layer found");return this.activeLinkChartLayer?.knowledgeGraph}add(t,a){if(this.activeLinkChartLayer&&"type"in t&&"link-chart"===t.type)throw new i("linkchart:one-link-chart-layer","Web Link Charts can only have one Link Chart Layer, another cannot be added");if(super.add(t,a),"type"in t&&"link-chart"===t.type){const a=t.initializationLinkChartConfig?.layoutMode;a&&(this.linkChartProperties.layoutType=a);const e=t.initializationLinkChartConfig?.layoutSettings;e&&(this.linkChartProperties.layoutSettings=e)}}static fromJSON(t){if(t)return new m({resourceInfo:t});throw new i("linkchart:empty-resource","Expected a JSON resource but got nothing")}handleChronologicalOverlay(){if(!this.activeLinkChartLayer)return;const t=this.activeLinkChartLayer,a=this.findLayerById(k());if(a&&this.remove(a),"chronological-mono-timeline"===this.linkChartProperties.layoutType||"chronological-multi-timeline"===this.linkChartProperties.layoutType){const a=p(t);this.add(a,0)}}static async fromCypherQuery(t,a,e,r){const i=await c(t,a,r),n=new m,o=new l({url:t.url,initializationInclusionModeDefinition:i,initializationLinkChartConfig:e});return o.load({signal:r?.signal}),n.add(o),n}static fromIdTypePairs(t,a,e,r){const i=y(t,a),n=new m,o=new l({url:t.url,initializationInclusionModeDefinition:i,initializationLinkChartConfig:e});return o.load({signal:r?.signal}),n.add(o),n}};t([s({readOnly:!0})],g.prototype,"activeLinkChartLayer",null),t([s({json:{write:{ignoreOrigin:!0}}})],g.prototype,"mapType",void 0),t([s({type:d,nonNullable:!0,json:{write:{ignoreOrigin:!0}}})],g.prototype,"linkChartProperties",void 0),t([s({readOnly:!0})],g.prototype,"diagramNodesExtent",null),t([s({readOnly:!0})],g.prototype,"entityCount",null),t([s({readOnly:!0})],g.prototype,"relationshipCount",null),t([s({readOnly:!0})],g.prototype,"knowledgeGraph",null),g=m=t([h("esri.WebLinkChart")],g);const v=g;export{v as default};