@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 3.76 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{pt2px as e}from"../../../../core/screenUtils.js";import"../../../../libs/maquette/projection.js";import{createProjector as t}from"../../../../libs/maquette/projector.js";import{isNumber as i}from"../../../../support/guards.js";import{renderColorRampPreviewHTML as o}from"../../../../symbols/support/symbolUtils.js";import"../../../support/widgetUtils.js";import{tsx as l}from"../../../support/jsxFactory.js";const n=t(),r=10,s=20,a=10,c=20,f={univariateAboveAndBelowSymbol:"esri-univariate-above-and-below-ramp__symbol",colorRamp:"esri-legend__color-ramp"};function p(e="vertical"){const t="stroke:rgb(200, 200, 200);stroke-width:1";return"vertical"===e?l("svg",{height:"4",width:"10"},l("line",{style:t,x1:"0",x2:"10",y1:"2",y2:"2"})):l("svg",{height:"10",width:"10"},l("line",{style:t,x1:"5",x2:"5",y1:"0",y2:"10"}))}function m(e,t="vertical"){const i=document.createElement("div");return i.style.height=`${s}px`,i.className=f.univariateAboveAndBelowSymbol,null!=e&&(i.style.opacity=e.toString()),n.append(i,p.bind(null,t)),i}function u(t,o,l="vertical",n){t.infos.forEach(((t,r)=>{if(n&&2===r)t.preview=m(o,l);else{const o=(i(t.size)?e(t.size):0)+("horizontal"===l?c:a),n=t.preview,r="div"===n?.tagName.toLowerCase(),s=r?n:document.createElement("div");s.className=f.univariateAboveAndBelowSymbol,"horizontal"===l?s.style.width=`${o}px`:s.style.height=`${o}px`,!r&&n&&s.appendChild(n),t.preview=s}}))}function v(t,o="classic"){const l=t.infos,n=l.at(0),r=l.at(-1),s=i(n.size)?e(n.size):0,c=i(r.size)?e(r.size):0;return"classic"===o?(s+a)/2:(s-c)/2}function h(e,t){if(!e)return null;const i=e.infos.map((e=>e.color)),l=o("full"===t.type?i:"above"===t.type?i.slice(0,3):i.slice(2,5),{width:t.width,height:t.height,align:t.rampAlignment,effectList:t.effectList,ariaLabel:t.ariaLabel});return l.className=f.colorRamp,null!=t.opacity&&(l.style.opacity=t.opacity.toString()),l}function d(t,o,l,n="vertical"){let f=0;const p=t.infos,m=Math.floor(p.length/2),u="full"===o||"above"===o?0:m,v="full"===o||"below"===o?p.length-1:m;for(let h=u;h<=v;h++)if(l&&h===m)f+="horizontal"===n?r:s;else{const t=p[h].size;f+=(i(t)?e(t):0)+("horizontal"===n?c:a)}return Math.round(f)}function y(t,o,l,n="vertical"){const f=d(t,o,l,n),p=t.infos,m=Math.floor(p.length/2),u="full"===o||"above"===o?0:m,v="full"===o||"below"===o?p.length-1:m,h=i(p[u].size)?p[u].size:0,y=i(p[v].size)?p[v].size:0,b="full"===o?h+y:"above"===o?h:y,g=l?"vertical"===n?s:r:0,z="vertical"===n?a*("full"===o?2:1):c*("full"===o?2:1);return Math.round(f-(e(b)/2+g/2+z/2))}function b(e,t,i="vertical"){const o=e.infos;let l=o.find((({type:e})=>"size-ramp"===e)),n=o.find((({type:e})=>"color-ramp"===e));return l&&(l={...l},l.infos=[...l.infos],u(l,t,i,!0)),n&&(n={...n},n.infos=[...n.infos]),"horizontal"===i&&(l?.infos.reverse(),n?.infos.reverse()),{sizeRampElement:l,colorRampElement:n}}function g(e,t="vertical"){const i=e.infos;let o=i.find((({type:e})=>"size-ramp"===e)),l=i.find((({type:e})=>"color-ramp"===e));return o&&(o={...o},o.infos=[...o.infos],u(o,null,t,!1)),l&&(l={...l},l.infos=[...l.infos]),"horizontal"===t&&(o?.infos.reverse(),l?.infos.reverse()),{sizeRampElement:o,colorRampElement:l}}const z={marginLeft:"3px"},w={display:"table-cell",verticalAlign:"middle"},x={display:"flex",alignItems:"flex-start"};export{b as getUnivariateAboveAndBelowRampElements,v as getUnivariateColorRampMargin,h as getUnivariateColorRampPreview,y as getUnivariateColorRampSize,g as getUnivariateColorSizeRampElements,d as getUnivariateSizeRampSize,z as univariateColorRampContainerStyles,w as univariateColorRampStyles,x as univariateRampContainerStyles};