UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 2.03 kB
import e from"../../../../../../Color.js";import{isSome as t}from"../../../../../../core/maybe.js";import{pt2px as o}from"../../../../../../core/screenUtils.js";import{writeColor as r}from"../../color.js";import{CHART_MAX_FIELDS as a}from"../../definitions.js";import{Technique as n}from"../Technique.js";import{DataType as i}from"../../../../../webgl/enums.js";class l extends n{static getStorageSpec({attributes:e}){return{visualVariables:!0,attributes:e??null}}static _createRendererSchema(){return{type:"pie-chart",colors:new Float32Array(4*a),defaultColor:new Float32Array(4),othersColor:new Float32Array(4),outlineColor:new Float32Array(4),holePercentage:0,sectorThreshold:0,outlineWidth:1,numberOfFields:10}}static createOrUpdateRendererSchema(n,i){const{attributes:l,defaultColor:s,holePercentage:c,othersCategory:m,outline:u}=i,d=t(n)&&"pie-chart"===n.type?n:this._createRendererSchema();for(let t=0;t<a;t++){const o=t>=l.length?new e([0,0,0,0]):l[t].color;r(d.colors,o,4*t)}return r(d.defaultColor,s),r(d.othersColor,m?.color),r(d.outlineColor,u?.color),d.outlineWidth=o(u?.width||0),d.holePercentage=c,d.sectorThreshold=m?.threshold||0,d.numberOfFields=l.length,d}static getVariation(e){return{numberOfFields:e.numberOfFields}}static getVariationHash(e){return e.numberOfFields}}l.type="pie-chart",l.programSpec={shader:"materials/pie",vertexLayout:{geometry:[{location:0,name:"a_pos",count:2,type:i.SHORT},{location:1,name:"a_vertexOffset",count:2,type:i.SHORT},{location:2,name:"a_texCoords",count:2,type:i.UNSIGNED_SHORT},{location:3,name:"a_bitSetAndDistRatio",count:2,type:i.UNSIGNED_SHORT},{location:4,name:"a_id",count:4,type:i.UNSIGNED_BYTE},{location:5,name:"a_color",count:4,type:i.UNSIGNED_BYTE,normalized:!0},{location:6,name:"a_outlineColor",count:4,type:i.UNSIGNED_BYTE,normalized:!0},{location:7,name:"a_sizeAndOutlineWidth",count:4,type:i.UNSIGNED_BYTE},{location:8,name:"a_zoomRange",count:2,type:i.UNSIGNED_SHORT}]},hittestAttributes:["a_vertexOffset","a_texCoords"]};export{l as PieChartTechnique};