@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 3.27 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */
import{__decorate as t}from"tslib";import{throttle as e}from"../../../core/throttle.js";import{formatDecimal as i,formatAngleDegrees as s}from"../../../core/unitFormatUtils.js";import{property as o,subclass as r}from"../../../core/accessorSupport/decorators.js";import a from"../../Widget.js";import{statisticsCss as n}from"../css.js";import{notAvailable as c,getConfig as l}from"../support/constants.js";import{loadCalciteComponents as d}from"../../support/componentsUtils.js";import{messageBundle as p,tsx as m}from"../../support/widget.js";const h=100;let u=class extends a{constructor(t,i){super(t,i),this._updateLayout=t=>{const e=t.parentElement,i=t.style.display;e?.removeChild(t),document.body.appendChild(t),t.style.display="block";let s=80;for(const o of t.childNodes)o instanceof HTMLElement&&(s=Math.max(s,o.offsetWidth));document.body.removeChild(t),e?.appendChild(t),t.style.display=i,t.style.setProperty("--max-width",`${s}px`)},this._updateLayoutThrottled=e(this._updateLayout,h)}loadDependencies(){return d({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 s=l().formatPrecision,o=this._renderValue(t,t=>{const e=this.effectiveUnits.distance;return i(this._messagesUnits,t,e,s)});return this._renderStatistic(e,o)}_renderElevationStatistic(t,e){const s=l().formatPrecision,o=this._renderValue(t,t=>{const e=this.effectiveUnits.elevation;return i(this._messagesUnits,t,e,s)});return this._renderStatistic(e,o)}_renderSlopeStatistic(t,e,i){const o=l().formatPrecision,r=m("div",{class:n.slopeValue,key:"slope-up"},m("calcite-icon",{icon:"arrow-up",scale:"s"}),this._renderValue(t,t=>s(t,"degrees","geographic","geographic",o)),m("calcite-icon",{icon:"arrow-down",scale:"s"}),this._renderValue(e,t=>s(t,"degrees","geographic","geographic",o)));return this._renderStatistic(i,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 i=this.line,s=1===i.progress?i.statistics:null,o=s?.[t];return null!=o?e(o):c}};t([o()],u.prototype,"effectiveUnits",void 0),t([o()],u.prototype,"line",void 0),t([o(),p("esri/widgets/ElevationProfile/t9n/ElevationProfile")],u.prototype,"_messages",void 0),t([o(),p("esri/core/t9n/Units")],u.prototype,"_messagesUnits",void 0),u=t([r("esri.widgets.ElevationProfile.components.Statistics")],u);export{u as Statistics};