UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 3.65 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{_ as t}from"../../../chunks/tslib.es6.js";import{throttle as e}from"../../../core/throttle.js";import{formatDecimal as s,formatAngleDegrees as i}from"../../../core/unitFormatUtils.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as r}from"../../../core/accessorSupport/decorators/subclass.js";import a from"../../Widget.js";import{statisticsCss as n}from"../css.js";import{getConfig as c,notAvailable as l}from"../support/constants.js";import{loadCalciteComponents as p}from"../../support/componentsUtils.js";import"../../support/widgetUtils.js";import{messageBundle as d}from"../../support/decorators/messageBundle.js";import{tsx as m}from"../../support/jsxFactory.js";const h=100;let u=class extends a{constructor(t,s){super(t,s),this._updateLayout=t=>{const e=t.parentElement,s=t.style.display;e?.removeChild(t),document.body.appendChild(t),t.style.display="block";let i=80;for(const o of t.childNodes)o instanceof HTMLElement&&(i=Math.max(i,o.offsetWidth));document.body.removeChild(t),e?.appendChild(t),t.style.display=s,t.style.setProperty("--max-width",`${i}px`)},this._updateLayoutThrottled=e(this._updateLayout,h)}loadDependencies(){return p({icon:()=>import("@esri/calcite-components/dist/components/calcite-icon")})}initialize(){this.addHandles(this._updateLayoutThrottled)}render(){return m("div",{afterCreate:this._updateLayout,afterUpdate:this._updateLayoutThrottled,bind:this,class:n.base},this._renderStatistics())}_renderStatistics(){const t=this._messages?.statistics;return t?[this._renderDistanceStatistic("maxDistance",t.maxDistance),this._renderElevationStatistic("elevationGain",t.gain),this._renderElevationStatistic("elevationLoss",t.loss),this._renderElevationStatistic("minElevation",t.minElevation),this._renderElevationStatistic("maxElevation",t.maxElevation),this._renderElevationStatistic("avgElevation",t.avgElevation),this._renderSlopeStatistic("maxPositiveSlope","maxNegativeSlope",t.maxSlope),this._renderSlopeStatistic("avgPositiveSlope","avgNegativeSlope",t.avgSlope)]:[]}_renderDistanceStatistic(t,e){const i=c().formatPrecision,o=this._renderValue(t,(t=>{const e=this.effectiveUnits.distance;return s(this._messagesUnits,t,e,i)}));return this._renderStatistic(e,o)}_renderElevationStatistic(t,e){const i=c().formatPrecision,o=this._renderValue(t,(t=>{const e=this.effectiveUnits.elevation;return s(this._messagesUnits,t,e,i)}));return this._renderStatistic(e,o)}_renderSlopeStatistic(t,e,s){const o=c().formatPrecision,r=m("div",{class:n.slopeValue,key:"slope-up"},m("calcite-icon",{icon:"arrow-up",scale:"s"}),this._renderValue(t,(t=>i(t,"degrees","geographic","geographic",o))),m("calcite-icon",{icon:"arrow-down",scale:"s"}),this._renderValue(e,(t=>i(t,"degrees","geographic","geographic",o))));return this._renderStatistic(s,r)}_renderStatistic(t,e){return m("div",{class:n.statistic},m("label",{class:n.statisticLabel},t),m("div",{class:n.statisticValue},e))}_renderValue(t,e){const s=this.line,i=1===s.progress?s.statistics:null,o=i?.[t];return null!=o?e(o):l}};t([o()],u.prototype,"effectiveUnits",void 0),t([o()],u.prototype,"line",void 0),t([o(),d("esri/widgets/ElevationProfile/t9n/ElevationProfile")],u.prototype,"_messages",void 0),t([o(),d("esri/core/t9n/Units")],u.prototype,"_messagesUnits",void 0),u=t([r("esri.widgets.ElevationProfile.components.Statistics")],u);export{u as Statistics};