@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 2.77 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
*/
import{_ as e}from"../../chunks/tslib.es6.js";import{watch as r,sync as t}from"../../core/reactiveUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import a from"../support/AggregateField.js";import{featureReductionProperty as o}from"../support/featureReductionUtils.js";import u from"../../renderers/SimpleRenderer.js";import n from"../../renderers/visualVariables/SizeVariable.js";import l from"../../renderers/visualVariables/support/SizeStop.js";import{createInferredClusterRenderer as c}from"../../views/2d/layers/support/clusterUtils.js";const d=d=>{let f=class extends d{constructor(...e){super(...e),this.addHandles(r((()=>this.renderer),(()=>{if(this.featureReduction){const e=this._normalizeFeatureReduction(this.featureReduction);this._set("featureReduction",e)}}),t))}set featureReduction(e){const r=this._normalizeFeatureReduction(e);this._set("featureReduction",r)}set renderer(e){}_withClusterVariable(e,r,t){const s=e.clone();if("visualVariables"in s){s.visualVariables||(s.visualVariables=[]);s.visualVariables.some((e=>"size"===e.type))||s.visualVariables.push(new n({field:"cluster_count",stops:[new l({value:1}),new l({useMinValue:!0,size:r}),new l({useMaxValue:!0,size:t})]}))}return s}_normalizeFeatureReduction(e){if("cluster"!==e?.type)return e;const r=e.clone(),t=[new a({name:"cluster_count",alias:"cluster_count",isAutoGenerated:!0,statisticType:"count"})],s=(r.fields??[]).filter((e=>!e.isAutoGenerated)),i=e.renderer&&!e.renderer.authoringInfo?.isAutoGenerated,{clusterMinSize:o,clusterMaxSize:n}=r;if(i){r.fields=[...t,...s];const e=this._withClusterVariable(r.renderer,o,n);return r.effectiveFeatureRenderer=e,r.effectiveClusterRenderer=e,r}if(e.symbol){if(r.fields=[...t,...s],r.renderer=null,!this.renderer)return r.effectiveFeatureRenderer=null,r.effectiveClusterRenderer=null,r;const i=c(t,this.renderer),a=this._withClusterVariable(i,o,n),l="visualVariables"in a&&a.visualVariables?a.visualVariables:[],d=new u({symbol:e.symbol,visualVariables:l});return r.fields=[...t,...s],r.effectiveFeatureRenderer=a,r.effectiveClusterRenderer=d,r}if(!this.renderer)return e;const l=c(t,this.renderer);r.fields=[...t,...s],r.renderer=l;const d=this._withClusterVariable(l,o,n);return r.effectiveFeatureRenderer=d,r.effectiveClusterRenderer=d,r}};return e([s(o)],f.prototype,"featureReduction",null),f=e([i("esri.layers.mixins.FeatureReductionLayer")],f),f};export{d as FeatureReductionLayer};