@visactor/vgrammar-plot 0.6.6 → 0.7.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/area.js +3 -3
- package/cjs/area.js.map +1 -1
- package/cjs/cell.js +3 -3
- package/cjs/cell.js.map +1 -1
- package/cjs/circle-packing.js +4 -5
- package/cjs/circle-packing.js.map +1 -1
- package/cjs/image.js +3 -3
- package/cjs/image.js.map +1 -1
- package/cjs/interval.js +3 -3
- package/cjs/interval.js.map +1 -1
- package/cjs/line.js +3 -3
- package/cjs/line.js.map +1 -1
- package/cjs/path.js +4 -1
- package/cjs/path.js.map +1 -1
- package/cjs/plot.d.ts +6 -4
- package/cjs/plot.js +24 -16
- package/cjs/plot.js.map +1 -1
- package/cjs/polygon.js +3 -3
- package/cjs/polygon.js.map +1 -1
- package/cjs/rect-x.js +3 -3
- package/cjs/rect-x.js.map +1 -1
- package/cjs/rect-y.js +3 -3
- package/cjs/rect-y.js.map +1 -1
- package/cjs/rect.js +3 -3
- package/cjs/rect.js.map +1 -1
- package/cjs/rule-x.js +3 -3
- package/cjs/rule-x.js.map +1 -1
- package/cjs/rule-y.d.ts +1 -1
- package/cjs/rule-y.js +14 -8
- package/cjs/rule-y.js.map +1 -1
- package/cjs/rule.js +3 -3
- package/cjs/rule.js.map +1 -1
- package/cjs/sankey.js +6 -8
- package/cjs/sankey.js.map +1 -1
- package/cjs/semantic-mark.d.ts +9 -4
- package/cjs/semantic-mark.js +113 -77
- package/cjs/semantic-mark.js.map +1 -1
- package/cjs/sunburst.js +4 -5
- package/cjs/sunburst.js.map +1 -1
- package/cjs/symbol.d.ts +3 -1
- package/cjs/symbol.js +25 -3
- package/cjs/symbol.js.map +1 -1
- package/cjs/text.js +5 -3
- package/cjs/text.js.map +1 -1
- package/cjs/tree.js +4 -5
- package/cjs/tree.js.map +1 -1
- package/cjs/treemap.js +4 -5
- package/cjs/treemap.js.map +1 -1
- package/cjs/wordcloud-shape.d.ts +1 -0
- package/cjs/wordcloud-shape.js +12 -7
- package/cjs/wordcloud-shape.js.map +1 -1
- package/cjs/wordcloud.js +4 -5
- package/cjs/wordcloud.js.map +1 -1
- package/dist/index.js +274 -117
- package/dist/index.min.js +1 -1
- package/es/area.js +3 -3
- package/es/area.js.map +1 -1
- package/es/cell.js +3 -3
- package/es/cell.js.map +1 -1
- package/es/circle-packing.js +5 -5
- package/es/circle-packing.js.map +1 -1
- package/es/image.js +3 -3
- package/es/image.js.map +1 -1
- package/es/interval.js +4 -4
- package/es/interval.js.map +1 -1
- package/es/line.js +3 -3
- package/es/line.js.map +1 -1
- package/es/path.js +4 -1
- package/es/path.js.map +1 -1
- package/es/plot.d.ts +6 -4
- package/es/plot.js +25 -17
- package/es/plot.js.map +1 -1
- package/es/polygon.js +3 -3
- package/es/polygon.js.map +1 -1
- package/es/rect-x.js +3 -3
- package/es/rect-x.js.map +1 -1
- package/es/rect-y.js +3 -3
- package/es/rect-y.js.map +1 -1
- package/es/rect.js +3 -3
- package/es/rect.js.map +1 -1
- package/es/rule-x.js +3 -3
- package/es/rule-x.js.map +1 -1
- package/es/rule-y.d.ts +1 -1
- package/es/rule-y.js +15 -7
- package/es/rule-y.js.map +1 -1
- package/es/rule.js +3 -3
- package/es/rule.js.map +1 -1
- package/es/sankey.js +7 -7
- package/es/sankey.js.map +1 -1
- package/es/semantic-mark.d.ts +9 -4
- package/es/semantic-mark.js +111 -77
- package/es/semantic-mark.js.map +1 -1
- package/es/sunburst.js +5 -5
- package/es/sunburst.js.map +1 -1
- package/es/symbol.d.ts +3 -1
- package/es/symbol.js +25 -3
- package/es/symbol.js.map +1 -1
- package/es/text.js +5 -3
- package/es/text.js.map +1 -1
- package/es/tree.js +5 -5
- package/es/tree.js.map +1 -1
- package/es/treemap.js +5 -5
- package/es/treemap.js.map +1 -1
- package/es/wordcloud-shape.d.ts +1 -0
- package/es/wordcloud-shape.js +14 -6
- package/es/wordcloud-shape.js.map +1 -1
- package/es/wordcloud.js +5 -5
- package/es/wordcloud.js.map +1 -1
- package/package.json +8 -8
package/dist/index.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@visactor/vgrammar-util"),require("@visactor/vutils"),require("@visactor/vgrammar")):"function"==typeof define&&define.amd?define(["exports","@visactor/vgrammar-util","@visactor/vutils","@visactor/vgrammar"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).VGrammar=e.VGrammar||{},e.VGrammar.Projection={}),e.VGrammar.Util,e.VUtils,e.VGrammar)}(this,(function(e,t,i,r){"use strict";var o;function a(e){switch(e){case o.Ordinal:case o.Point:case o.Band:return!0;default:return!1}}!function(e){e.Identity="identity",e.Linear="linear",e.Log="log",e.Pow="pow",e.Sqrt="sqrt",e.Symlog="symlog",e.Time="time",e.Quantile="quantile",e.Quantize="quantize",e.Threshold="threshold",e.Ordinal="ordinal",e.Point="point",e.Band="band"}(o||(o={}));const l=r.getTheme("default");let s=-1;class n{constructor(e,t){this.type=e,this.uid=++s,this._logger=i.Logger.getInstance(),this.spec={id:null!=t?t:`${this.type}-${this.uid}`}}parseSpec(e){return i.isNil(e.id)&&(e.id=this.spec.id),this.spec=e,this}coordinate(e){return this._coordinate=e,this}data(e,t,r){return i.isNil(e)||(this.spec.data={values:e,transform:t,id:r}),this}encode(e,t){return this.spec.encode||(this.spec.encode={}),this.spec.encode[e]=t,this}scale(e,t){return this.spec.scale||(this.spec.scale={}),this.spec.scale[e]=t,this}style(e){return this.spec.style=e,this}transform(e){return this.spec.transform=i.array(e),this}state(e,t){if(![r.BuiltInEncodeNames.enter,r.BuiltInEncodeNames.update,r.BuiltInEncodeNames.exit,r.BuiltInEncodeNames.group].includes(e))return this.spec.state||(this.spec.state={}),this.spec.state[e]=t,this;this._logger.warn(`[VGrammar]: ${e} is a reserved keyword to specify the encode of different data state, \n don't use this keyword`)}animate(e,t){return"state"===e?(this._logger.warn(`[VGrammar]: ${e} is a keyword use to specify state animation config, don't use this keyword`),this):(this.spec.animation||(this.spec.animation={}),this.spec.animation[e]=t,this)}axis(e,t=!0,i){return this.spec.axis||(this.spec.axis={}),this.spec.axis[e]={option:t,layout:i},this}legend(e,t=!0,i){return this.spec.legend||(this.spec.legend={}),this.spec.legend[e]={option:t,layout:i},this}crosshair(e,t){return this.spec.crosshair||(this.spec.crosshair={}),this.spec.crosshair[e]=t,this}tooltip(e){return this.spec.tooltip=e,this}slider(e,t,i){return this.spec.slider||(this.spec.slider={}),this.spec.slider[e]={option:t,layout:i},this}datazoom(e,t,i){return this.spec.datazoom||(this.spec.datazoom={}),this.spec.datazoom[e]={option:t,layout:i},this}label(e,t){return this.spec.label||(this.spec.label={}),this.spec.label[e]=t,this}player(e,t,i){return this.spec.player={data:e,option:t,layout:i},this}setDefaultDataTransform(){return[]}setMultipleData(){return null}setDefaultMarkTransform(){return[]}convertMarkTransform(e,t=[]){if(t&&t.length){if(e&&e.length){let i=[];const r=[];for(let o=0,a=e.length;o<a;o++){const a=e[o],l=t.findIndex((e=>e.type===a.type));l>=0?(i.push(Object.assign({},t[l],a)),r.push(l)):i.push(a)}for(let e=0,o=t.length;e<o;e++)r.includes(e)||(i=[t[e]].concat(i));return i}return t}return e}convertMarkAnimation(){return this.spec.animation?this.spec.animation:null}convertSimpleMarkEncode(e){if(!e)return{};const t={};return Object.keys(e).map((i=>{t[i]={field:e[i],scale:this.getScaleId(i)}})),t}getDataIdOfFiltered(){var e,t;return`${null!==(t=null===(e=this.spec.data)||void 0===e?void 0:e.id)&&void 0!==t?t:this.spec.id}-data-filtered`}getDataIdOfMain(){var e,t;return`${null!==(t=null===(e=this.spec.data)||void 0===e?void 0:e.id)&&void 0!==t?t:this.spec.id}-data`}getDataIdOfPlayer(){var e,t;return`${null!==(t=null===(e=this.spec.data)||void 0===e?void 0:e.id)&&void 0!==t?t:this.spec.id}-player`}getDataZoomScaleId(e){return{x:`datazoom-scale-${e}-x`,y:`datazoom-scale-${e}-y`}}getScaleId(e){var t,i,r;return null!==(r=null===(i=null===(t=this.spec.scale)||void 0===t?void 0:t[e])||void 0===i?void 0:i.id)&&void 0!==r?r:`scale-${e}`}getMarkId(){return`${this.spec.id}-mark`}getScaleSpec(e){var t,i,r;return null===(r=null===(i=null===(t=this.viewSpec)||void 0===t?void 0:t.scales)||void 0===i?void 0:i.find)||void 0===r?void 0:r.call(i,(t=>t.id===e))}parseScaleOfEncodeX(e){return{type:"band",id:this.getScaleId("x"),dependency:[r.SIGNAL_VIEW_BOX],domain:{data:this.getDataIdOfFiltered(),field:e},range:this._coordinate?{coordinate:this._coordinate.id,dimension:"x"}:(e,t)=>[0,t.viewBox.width()]}}parseScaleOfEncodeY(e){return{type:"linear",dependency:[r.SIGNAL_VIEW_BOX],id:this.getScaleId("y"),domain:{data:this.getDataIdOfFiltered(),field:e},range:this._coordinate?{coordinate:this._coordinate.id,dimension:"y"}:(e,t)=>[t.viewBox.height(),0]}}parseScaleOfEncodeColor(e){return{type:"ordinal",id:this.getScaleId("color"),domain:{data:this.getDataIdOfMain(),field:e},range:r.getPalette()}}parseScaleOfEncodeGroup(e){return{type:"ordinal",id:this.getScaleId("group"),domain:{data:this.getDataIdOfMain(),field:e},range:r.getPalette()}}parseScaleOfCommonEncode(e,t){return"x"===e?this.parseScaleOfEncodeX(t):"y"===e?this.parseScaleOfEncodeY(t):"color"===e?this.parseScaleOfEncodeColor(t):"group"===e?this.parseScaleOfEncodeGroup(t):null}setDefaultAxis(){return{}}parseAxisSpec(){const e=this.spec.axis,t=[];return e&&Object.keys(e).forEach((o=>{const{option:a,layout:l}=this.parseOption(e[o]);if(a){const e={type:"component",componentType:r.ComponentEnum.axis,scale:this.getScaleId(o),dependency:[r.SIGNAL_VIEW_BOX],tickCount:a.tickCount,encode:{update:(e,t,r)=>{const l=this._coordinate?{}:"x"===o?{x:0,y:r.viewBox.height(),start:{x:0,y:0},end:{x:r.viewBox.width(),y:0}}:{x:0,y:r.viewBox.height(),start:{x:0,y:0},verticalFactor:-1,end:{x:0,y:-r.viewBox.height()}};return i.isPlainObject(a)?Object.assign(l,a):l}}};e.layout=null!=l?l:{position:this._coordinate?"auto":i.isPlainObject(l)&&!i.isNil(l.orient)?l.orient:"x"===o?"bottom":"left"},t.push(e)}})),t}parseOption(e){let t,r;return i.isPlainObject(e)?i.isNil(e.option)?t=e:(t=e.option,r=e.layout):t=e,{option:t,layout:r}}setDefaultLegend(){return{}}parseLegendSpec(){const e=this.spec.legend,t=[];return e&&Object.keys(e).forEach((o=>{var a;const{option:l,layout:s}=this.parseOption(e[o]);if(l){const e=null!=s?s:i.isPlainObject(l)&&!i.isNil(l.layout)?"horizontal"===l.layout?{position:"top",align:"center"}:"vertical"===l.layout?{position:"right",align:"middle"}:{position:"top",align:"center"}:{position:"top",align:"center"},n={type:"component",componentType:r.ComponentEnum.legend,scale:this.getScaleId(o),dependency:[r.SIGNAL_VIEW_BOX],target:{data:this.getDataIdOfFiltered(),filter:null===(a=this.spec.encode)||void 0===a?void 0:a[o]},encode:{update:(t,r,o)=>{var a,s,n,d,c,u,p,h,v,y,f,g,m,k,x,S,M,b,w,P,O,E,I,_;const T="left"===e.position?{layout:"vertical",x:null!==(n=null===(s=null===(a=r.mark)||void 0===a?void 0:a.relativePosition)||void 0===s?void 0:s.left)&&void 0!==n?n:0,y:null!==(u=null===(c=null===(d=r.mark)||void 0===d?void 0:d.relativePosition)||void 0===c?void 0:c.top)&&void 0!==u?u:0}:"right"===e.position?{layout:"vertical",x:null!==(v=null===(h=null===(p=r.mark)||void 0===p?void 0:p.relativePosition)||void 0===h?void 0:h.left)&&void 0!==v?v:o.viewBox.width(),y:null!==(g=null===(f=null===(y=r.mark)||void 0===y?void 0:y.relativePosition)||void 0===f?void 0:f.top)&&void 0!==g?g:0}:"bottom"===e.position?{layout:"horizontal",x:null!==(x=null===(k=null===(m=r.mark)||void 0===m?void 0:m.relativePosition)||void 0===k?void 0:k.left)&&void 0!==x?x:0,y:null!==(b=null===(M=null===(S=r.mark)||void 0===S?void 0:S.relativePosition)||void 0===M?void 0:M.top)&&void 0!==b?b:o.viewBox.height()}:{layout:"horizontal",x:null!==(O=null===(P=null===(w=r.mark)||void 0===w?void 0:w.relativePosition)||void 0===P?void 0:P.left)&&void 0!==O?O:0,y:null!==(_=null===(I=null===(E=r.mark)||void 0===E?void 0:E.relativePosition)||void 0===I?void 0:I.top)&&void 0!==_?_:0};return i.isPlainObject(l)?Object.assign({},T,l):T}}};n.layout=e,t.push(n)}})),t}setDefaultCrosshair(){return{}}getVisualChannel(e){var t,i;return"polar"===(null===(t=this._coordinate)||void 0===t?void 0:t.type)?this._coordinate.transpose?"x"===e?"radius":"angle":"x"===e?"angle":"radius":(null===(i=this._coordinate)||void 0===i?void 0:i.transpose)?"x"===e?"y":"x":e}parseCrosshairSpec(){const e=this.setDefaultCrosshair(),t=Object.keys(e),o=this.spec.crosshair?Object.keys(this.spec.crosshair).reduce(((e,t)=>(e.includes(t)||e.push(t),e)),t):t,l=[];return o.length&&o.forEach((t=>{var o,s;const n=null===(o=this.spec.crosshair)||void 0===o?void 0:o[t],d=null!=n?n:e[t];if(d){const e=this.getScaleId(t),o=this.getScaleSpec(e),c={type:"component",componentType:r.ComponentEnum.crosshair,scale:this.getScaleId(t),dependency:[r.SIGNAL_VIEW_BOX],crosshairShape:i.isBoolean(d)?"band"===(null==o?void 0:o.type)?"rect":"line":null!==(s=d.crosshairShape)&&void 0!==s?s:"band"===(null==o?void 0:o.type)?"rect":"line",crosshairType:this.getVisualChannel(t)};if(i.isPlainObject(n)&&(c.encode={update:n},"polygon"===n.type)){c.crosshairType="radius-polygon";const e=this.getScaleId("x"===t?"y":"x");c.dependency.push(e),c.encode.update.sides=(t,i,r)=>{const o=r[e];return o&&a(o.type)?o.domain().length:void 0},c.encode.update.startAngle=(t,i,r)=>{var o,l;const s=r[e];return s&&a(s.type)?s.range()[0]+(null!==(l=null===(o=null==s?void 0:s.bandwidth)||void 0===o?void 0:o.call(s))&&void 0!==l?l:0)/2:void 0},c.encode.update.endAngle=(t,i,r)=>{var o,l;const s=r[e];return s&&a(s.type)?s.range()[1]+(null!==(l=null===(o=null==s?void 0:s.bandwidth)||void 0===o?void 0:o.call(s))&&void 0!==l?l:0)/2:void 0}}l.push(c)}})),l}setDefaultTooltip(){return null}parseTooltipSpec(){var e;const o=this.setDefaultTooltip(),a=this.spec.tooltip;if(!1!==a&&null!==a&&null!==o){const l=[],s=Object.assign({},o,!0===a?{}:a),n=i.isNil(this.spec.encode.color)?"group":"color",d=this.spec.encode[n],c=d?[this.getScaleId(n)]:[],u=d?t.field(d):null,p={visible:!!s.title||!!s.staticTitle,key:"title",value:i.isNil(s.staticTitle)?{field:(e,i,r)=>s.title&&(null==e?void 0:e.length)?t.field(s.title)(e[0]):void 0}:s.staticTitle},h=i.isArray(s.content)&&s.content.length?s.content.map(((e,o)=>({key:e.key?{field:e.key}:i.isNil(s.staticContentKey)?(e,t,i)=>u?u(e):void 0:i.isArray(s.staticContentKey)?s.staticContentKey[o]:s.staticContentKey,value:{field:e.value},symbol:(i,o,a)=>{var l;const s=a[this.getScaleId(n)];return{symbolType:e.symbol&&null!==(l=t.field(e.symbol)(i))&&void 0!==l?l:"circle",fill:s&&u?s.scale(u(i)):r.getPalette()[0]}}}))):null;return!0!==s.disableGraphicTooltip&&l.push({type:"component",componentType:r.ComponentEnum.tooltip,target:this.getMarkId(),dependency:c,title:p,content:h,zIndex:1e3}),!0!==s.disableDimensionTooltip&&l.push({type:"component",componentType:r.ComponentEnum.dimensionTooltip,tooltipType:this.getVisualChannel("x"),scale:this.getScaleId("x"),dependency:c,target:{data:this.getDataIdOfFiltered(),filter:null===(e=this.spec.encode)||void 0===e?void 0:e.x},title:p,content:h,avoidMark:s.disableGraphicTooltip?[]:[this.getMarkId()],zIndex:1e3}),l}return[]}setDefaultSlider(){return{}}parseSliderSpec(){const e=this.spec.slider,a=[];return e&&Object.keys(e).forEach((s=>{var n,d;const{option:c,layout:u}=this.parseOption(e[s]);if(c){const e=this.getScaleId(s),p=this.getScaleSpec(e),h=this.getDataIdOfMain();if(!p||!function(e){switch(e){case o.Linear:case o.Log:case o.Pow:case o.Sqrt:case o.Symlog:case o.Time:return!0;default:return!1}}(p.type))return void this._logger.warn(`[VGrammar]: Don't use slider in a channel which has scale type = ${null==p?void 0:p.type}`);const v=t.field(null===(n=this.spec.encode)||void 0===n?void 0:n[s]),y=null!=u?u:i.isPlainObject(c)&&!i.isNil(c.layout)?"horizontal"===c.layout?{position:"top",align:"center"}:"vertical"===c.layout?{position:"right",align:"middle"}:{position:"top",align:"center"}:{position:"top",align:"center"},f={type:"component",componentType:r.ComponentEnum.slider,dependency:[r.SIGNAL_VIEW_BOX,h],min:(e,t,i)=>{const r=i[h];return Math.min.apply(null,r.map(v))},max:(e,t,i)=>{const r=i[h];return Math.max.apply(null,r.map(v))},target:{data:this.getDataIdOfFiltered(),filter:null===(d=this.spec.encode)||void 0===d?void 0:d[s]},encode:{update:(e,t,r)=>{var o,a,s,n,d,u,p,h,v,f,g,m,k,x,S,M,b,w,P,O,E,I,_,T;const D="left"===y.position?{layout:"vertical",x:null!==(s=null===(a=null===(o=t.mark)||void 0===o?void 0:o.relativePosition)||void 0===a?void 0:a.left)&&void 0!==s?s:0,y:null!==(u=null===(d=null===(n=t.mark)||void 0===n?void 0:n.relativePosition)||void 0===d?void 0:d.top)&&void 0!==u?u:0,railWidth:l.slider.railHeight,railHeight:r.viewBox.height()}:"right"===y.position?{layout:"vertical",x:null!==(v=null===(h=null===(p=t.mark)||void 0===p?void 0:p.relativePosition)||void 0===h?void 0:h.left)&&void 0!==v?v:r.viewBox.width(),y:null!==(m=null===(g=null===(f=t.mark)||void 0===f?void 0:f.relativePosition)||void 0===g?void 0:g.top)&&void 0!==m?m:0,railWidth:l.slider.railHeight,railHeight:r.viewBox.height()}:"bottom"===y.position?{layout:"horizontal",x:null!==(S=null===(x=null===(k=t.mark)||void 0===k?void 0:k.relativePosition)||void 0===x?void 0:x.left)&&void 0!==S?S:0,y:null!==(w=null===(b=null===(M=t.mark)||void 0===M?void 0:M.relativePosition)||void 0===b?void 0:b.top)&&void 0!==w?w:r.viewBox.height(),railHeight:l.slider.railHeight,railWidth:r.viewBox.width()}:{layout:"horizontal",x:null!==(E=null===(O=null===(P=t.mark)||void 0===P?void 0:P.relativePosition)||void 0===O?void 0:O.left)&&void 0!==E?E:0,y:null!==(T=null===(_=null===(I=t.mark)||void 0===I?void 0:I.relativePosition)||void 0===_?void 0:_.top)&&void 0!==T?T:0,railHeight:l.slider.railHeight,railWidth:r.viewBox.width()};return i.isPlainObject(c)?Object.assign({},D,c):D}}};f.layout=y,a.push(f)}})),a}setDefaultDataZoom(){return{}}getVisiualPositionByDimension(e){return"y"===e?"left":"bottom"}parseDataZoomSpec(){const e=this.spec.datazoom,t=[];return e&&Object.keys(e).forEach((o=>{var a,s,n,d,c;const{option:u,layout:p}=this.parseOption(e[o]);if(u){const e=this.getDataIdOfMain(),h=null!=p?p:i.isPlainObject(u)&&!i.isNil(u.orient)?{position:u.orient}:{position:this.getVisiualPositionByDimension(o)},v={data:e},{x:y,y:f}=this.getDataZoomScaleId(o);"x"===o?(v.x={scale:y,field:null===(a=this.spec.encode)||void 0===a?void 0:a[o]},v.y={scale:f,field:null===(s=this.spec.encode)||void 0===s?void 0:s.y}):v["top"===h.position||"bottom"===h.position?"x":"y"]={scale:y,field:null!==(d=null===(n=this.spec.encode)||void 0===n?void 0:n[o])&&void 0!==d?d:o};const g={type:"component",componentType:r.ComponentEnum.datazoom,dependency:[r.SIGNAL_VIEW_BOX,e],target:{data:this.getDataIdOfFiltered(),filter:null===(c=this.spec.encode)||void 0===c?void 0:c[o]},preview:v,encode:{update:(e,t,r)=>{var o,a,s,n,d,c,p,v,y,f,g,m,k,x,S,M,b,w,P,O,E,I,_,T;const D="left"===h.position?{orient:h.position,x:null!==(s=null===(a=null===(o=t.mark)||void 0===o?void 0:o.relativePosition)||void 0===a?void 0:a.left)&&void 0!==s?s:0,y:null!==(c=null===(d=null===(n=t.mark)||void 0===n?void 0:n.relativePosition)||void 0===d?void 0:d.top)&&void 0!==c?c:0,size:{height:r.viewBox.height(),width:l.datazoom.size.height}}:"right"===h.position?{orient:h.position,x:null!==(y=null===(v=null===(p=t.mark)||void 0===p?void 0:p.relativePosition)||void 0===v?void 0:v.left)&&void 0!==y?y:r.viewBox.width(),y:null!==(m=null===(g=null===(f=t.mark)||void 0===f?void 0:f.relativePosition)||void 0===g?void 0:g.top)&&void 0!==m?m:0,size:{height:r.viewBox.height(),width:l.datazoom.size.height}}:"bottom"===h.position?{orient:h.position,x:null!==(S=null===(x=null===(k=t.mark)||void 0===k?void 0:k.relativePosition)||void 0===x?void 0:x.left)&&void 0!==S?S:0,y:null!==(w=null===(b=null===(M=t.mark)||void 0===M?void 0:M.relativePosition)||void 0===b?void 0:b.top)&&void 0!==w?w:r.viewBox.height(),size:{width:r.viewBox.width(),height:l.datazoom.size.height}}:{orient:h.position,x:null!==(E=null===(O=null===(P=t.mark)||void 0===P?void 0:P.relativePosition)||void 0===O?void 0:O.left)&&void 0!==E?E:0,y:null!==(T=null===(_=null===(I=t.mark)||void 0===I?void 0:I.relativePosition)||void 0===_?void 0:_.top)&&void 0!==T?T:0,size:{width:r.viewBox.width(),height:l.datazoom.size.height}};return i.isPlainObject(u)?Object.assign({},D,u):D}}};g.layout=h,t.push(g)}})),t}setDefaultLabel(){return{}}getLabelPosition(){var e,t;return"polar"===(null===(e=this._coordinate)||void 0===e?void 0:e.type)?this._coordinate.transpose?"endAngle":"outer":(null===(t=this._coordinate)||void 0===t?void 0:t.transpose)?"right":"top"}setLabelTextGetter(e,t){return null}parseLabelSpec(){const e=this.spec.label,t=[];return e&&Object.keys(e).forEach((o=>{const a=e[o];if(a){const e={type:"component",componentType:r.ComponentEnum.label,target:this.getMarkId(),layout:{position:"content",skipBeforeLayouted:!0},labelStyle:i.isPlainObject(a)?Object.assign({position:this.getLabelPosition()},a):{position:this.getLabelPosition()},encode:{update:{text:this.spec.encode[o]?{field:this.spec.encode[o]}:this.setLabelTextGetter(o,a)}}};t.push(e)}})),t}setDefaultPlayer(){return{}}parsePlayerSpec(){var e;const t=this.spec.player,o=[];if(t){const a=null==t?void 0:t.option,l=null==t?void 0:t.layout;if(a){const t=null!=l?l:i.isPlainObject(a)&&!i.isNil(a.orient)?{position:a.orient}:{position:"bottom"},s={type:"component",componentType:r.ComponentEnum.player,dependency:[r.SIGNAL_VIEW_BOX],target:{data:this.getDataIdOfMain(),source:this.getDataIdOfPlayer()},playerType:i.isPlainObject(a)&&null!==(e=a.type)&&void 0!==e?e:"auto",encode:{update:(e,r,o)=>{var l,s,n,d,c,u,p,h,v,y,f,g,m,k,x,S,M,b,w,P,O,E,I,_;const T="left"===t.position?{x:null!==(n=null===(s=null===(l=r.mark)||void 0===l?void 0:l.relativePosition)||void 0===s?void 0:s.left)&&void 0!==n?n:0,y:null!==(u=null===(c=null===(d=r.mark)||void 0===d?void 0:d.relativePosition)||void 0===c?void 0:c.top)&&void 0!==u?u:0,size:{height:o.viewBox.height(),width:20}}:"right"===t.position?{x:null!==(v=null===(h=null===(p=r.mark)||void 0===p?void 0:p.relativePosition)||void 0===h?void 0:h.left)&&void 0!==v?v:o.viewBox.width(),y:null!==(g=null===(f=null===(y=r.mark)||void 0===y?void 0:y.relativePosition)||void 0===f?void 0:f.top)&&void 0!==g?g:0,size:{height:o.viewBox.height(),width:20}}:"bottom"===t.position?{x:null!==(x=null===(k=null===(m=r.mark)||void 0===m?void 0:m.relativePosition)||void 0===k?void 0:k.left)&&void 0!==x?x:0,y:null!==(b=null===(M=null===(S=r.mark)||void 0===S?void 0:S.relativePosition)||void 0===M?void 0:M.top)&&void 0!==b?b:o.viewBox.height(),size:{width:o.viewBox.width(),height:20}}:{x:null!==(O=null===(P=null===(w=r.mark)||void 0===w?void 0:w.relativePosition)||void 0===P?void 0:P.left)&&void 0!==O?O:0,y:null!==(_=null===(I=null===(E=r.mark)||void 0===E?void 0:E.relativePosition)||void 0===I?void 0:I.top)&&void 0!==_?_:0,size:{width:o.viewBox.width(),height:20}};return i.isPlainObject(a)?Object.assign({},T,a):T}}};s.layout=t,o.push(s)}}return o}parseDataSpec(){var e;const{data:t,player:i}=this.spec,r=[];if(null==i?void 0:i.data)r.push({id:this.getDataIdOfPlayer(),values:i.data}),r.push({id:this.getDataIdOfMain(),values:null===(e=i.data)||void 0===e?void 0:e[0]}),r.push({id:this.getDataIdOfFiltered(),source:this.getDataIdOfMain()});else if(t){const e=this.getDataIdOfMain(),i=t.transform,o=this.convertMarkTransform(i,this.setDefaultDataTransform());r.push({id:e,values:t.values,transform:o}),r.push({id:this.getDataIdOfFiltered(),source:e})}const o=this.setMultipleData();return o&&o.forEach((e=>{e.id&&(e.id===this.getDataIdOfFiltered()&&r.length?r[r.length-1].transform=e.transform:r.push(e))})),r}parseScaleSpec(){const{encode:e,scale:t,datazoom:o}=this.spec,a={};return e&&Object.keys(e).forEach((t=>{var i;const r=e[t],o=this.getScaleId(t);a[o]=Object.assign({id:o},this.parseScaleByEncode(t,r),null===(i=this.spec.scale)||void 0===i?void 0:i[t])})),t&&Object.keys(t).forEach((e=>{const i=this.getScaleId(e);a[i]||(a[i]=t[e])})),o&&Object.keys(o).forEach((t=>{var s,n,d,c;const u=this.getScaleId(t),{x:p,y:h}=this.getDataZoomScaleId(t);"x"===t&&e[t]?(a[p]={type:a[u].type,id:p,domain:{data:this.getDataIdOfMain(),field:e[t]},dependency:[r.SIGNAL_VIEW_BOX],range:(e,t)=>[0,t.viewBox.width()]},e.y&&(a[h]={type:null!==(n=null===(s=a[this.getScaleId("y")])||void 0===s?void 0:s.type)&&void 0!==n?n:"linear",id:h,domain:{data:this.getDataIdOfMain(),field:null==e?void 0:e.y},range:(e,r)=>{var a,s;const n=this.parseOption(o[t]).option;return[0,i.isPlainObject(n)&&null!==(s=null===(a=n.size)||void 0===a?void 0:a.height)&&void 0!==s?s:l.datazoom.size.height]}})):a[p]={type:null!==(d=a[u].type)&&void 0!==d?d:"band",id:p,domain:{data:this.getDataIdOfMain(),field:null!==(c=null==e?void 0:e[t])&&void 0!==c?c:t}}})),Array.from(Object.values(a))}parseCoordinateSpec(){var e;if(!this._coordinate)return[];const i={type:null!==(e=this._coordinate.type)&&void 0!==e?e:"cartesian",transpose:this._coordinate.transpose,id:this._coordinate.id,dependency:[r.SIGNAL_VIEW_BOX],start:[0,0],end:(e,t)=>[t.viewBox.width(),t.viewBox.height()]};return"polar"===this._coordinate.type&&this._coordinate.origin&&(i.origin=(e,i)=>[t.toPercent(this._coordinate.origin[0],i.viewBox.width()),t.toPercent(this._coordinate.origin[1],i.viewBox.height())]),[i]}setMainMarkEnterEncode(){return this.spec.style}setMainMarkSpec(){return{}}setMultiMarksSpec(){return null}toViewSpec(){var e,t;this.viewSpec={};const i=this.getDataIdOfFiltered();this.viewSpec.data=this.parseDataSpec(),this.viewSpec.scales=this.parseScaleSpec(),this.viewSpec.coordinates=this.parseCoordinateSpec();let o=[];o=o.concat(this.parseLegendSpec()),o=o.concat(this.parseAxisSpec()),o=o.concat(this.parseCrosshairSpec()),o=o.concat(this.parseSliderSpec()),o=o.concat(this.parseDataZoomSpec()),o=o.concat(this.parsePlayerSpec()),o.push(Object.assign({id:this.getMarkId(),type:this.setMarkType(),coordinate:null===(e=this._coordinate)||void 0===e?void 0:e.id,from:{data:i},groupBy:null===(t=this.spec.encode)||void 0===t?void 0:t.group,layout:{position:"content",skipBeforeLayouted:!0},dependency:this.viewSpec.scales.map((e=>e.id)).concat(r.SIGNAL_VIEW_BOX),transform:this.convertMarkTransform(this.spec.transform,this.setDefaultMarkTransform()),animation:this.convertMarkAnimation(),encode:Object.assign({},this.spec.state,{enter:this.setMainMarkEnterEncode(),update:this.convertMarkEncode(this.spec.encode)})},this.setMainMarkSpec()));const a=this.setMultiMarksSpec();return a&&(o=o.concat(a)),o=o.concat(this.parseLabelSpec()),o=o.concat(this.parseTooltipSpec()),this.viewSpec.marks=o,this.viewSpec}clear(){this.spec={id:this.spec.id}}}var d;!function(e){e.area="area",e.cell="cell",e.image="image",e.interval="interval",e.line="line",e.path="path",e.polygon="polygon",e.rectX="rectX",e.rectY="rectY",e.rect="rect",e.ruleX="ruleX",e.ruleY="ruleY",e.rule="rule",e.symbol="symbol",e.text="text",e.tree="tree",e.circlePacking="circlePacking",e.sunburst="sunburst",e.treemap="treemap",e.sankey="sankey",e.wordcloud="wordcloud",e.wordcloudShape="wordcloudShape"}(d||(d={}));class c extends n{constructor(e){super(d.interval,e)}setMarkType(){var e;return"polar"===(null===(e=this._coordinate)||void 0===e?void 0:e.type)?r.GrammarMarkType.arc:r.GrammarMarkType.rect}parseScaleByEncode(e,t){return this.parseScaleOfCommonEncode(e,t)}setDefaultMarkTransform(){var e,t,i,r;return[{type:"dodge",minWidth:null===(e=this.spec.style)||void 0===e?void 0:e.minWidth,maxWidth:null===(t=this.spec.style)||void 0===t?void 0:t.maxWidth,innerGap:null===(i=this.spec.style)||void 0===i?void 0:i.innerGap,categoryGap:null===(r=this.spec.style)||void 0===r?void 0:r.categoryGap}]}setDefaultCrosshair(){return{x:{crosshairShape:"rect"}}}setDefaultTooltip(){var e;const t=null===(e=this.spec.encode)||void 0===e?void 0:e.y;return{content:i.isArray(t)?t.map((e=>({value:e}))):[{value:t}]}}setMainMarkSpec(){var e;return"polar"===(null===(e=this._coordinate)||void 0===e?void 0:e.type)?{attributeTransforms:[{channels:["x","y","x1","y1","cx","cy"],transform:(e,t,i)=>{e.x=i.cx,e.y=i.cy,this._coordinate.transpose?(e.startAngle=i.y,e.endAngle=i.y1,e.innerRadius=i.x,e.outerRadius=i.x1):(e.startAngle=i.x,e.endAngle=i.x1,e.innerRadius=i.y,e.outerRadius=i.y1)},storedAttrs:"sizeAttrs"}]}:{}}convertMarkEncode(e){var o,a,l,s,n;const d=this.convertSimpleMarkEncode(e),c=this.getScaleId("x"),u=this.getScaleId("y"),p=t.field(d.x.field),h={x:(e,t,i)=>{const r=i[c],o=r.bandwidth();return r.scale(p(e))+o/4},x1:(e,t,i)=>{const r=i[c],o=r.bandwidth();return r.scale(p(e))+3*o/4}};if(i.isArray(null===(o=d.y)||void 0===o?void 0:o.field))h.y={field:d.y.field[0],scale:d.y.scale},h.y1={field:d.y.field[1],scale:d.y.scale};else{const e=t.field(d.y.field);h.y=(t,r,o)=>{const a=e(t),l=o[u];return i.isArray(a)?l.scale(a[0]):l.scale(a)},h.y1=(t,r,o)=>{const a=o[u],l=e(t);if(i.isArray(l)&&l.length>1)return a.scale(l[1]);const s=a.domain(),n=Math.min.apply(null,s),d=Math.max.apply(null,s),c=n>0?n:d<0?d:0;return a.scale(c)}}return d.color||d.group?h.fill=null!==(a=d.color)&&void 0!==a?a:d.group:h.fill=null!==(s=null===(l=this.spec.style)||void 0===l?void 0:l.fill)&&void 0!==s?s:r.getPalette()[0],"polar"===(null===(n=this._coordinate)||void 0===n?void 0:n.type)&&(h.cx=(e,t,i)=>i[this._coordinate.id].origin().x,h.cy=(e,t,i)=>i[this._coordinate.id].origin().y),h}}c.type=d.interval;class u extends n{constructor(e){super(d.line,e)}setMarkType(){return r.GrammarMarkType.line}parseScaleOfEncodeX(e){const t=super.parseScaleOfEncodeX(e);return t.type="point",t}parseScaleByEncode(e,t){return this.parseScaleOfCommonEncode(e,t)}setDefaultCrosshair(){return{x:{crosshairShape:"line"}}}setDefaultTooltip(){var e,t;return{disableGraphicTooltip:!0,title:null===(e=this.spec.encode)||void 0===e?void 0:e.x,content:[{value:null===(t=this.spec.encode)||void 0===t?void 0:t.y}]}}convertMarkEncode(e){var t,i,o;const a=this.convertSimpleMarkEncode(e),l={y:a.y,x:a.x};return a.color||a.group?l.stroke=null!==(t=a.color)&&void 0!==t?t:a.group:l.stroke=null!==(o=null===(i=this.spec.style)||void 0===i?void 0:i.stroke)&&void 0!==o?o:r.getPalette()[0],l}}u.type=d.line;class p extends n{constructor(e){super(d.cell,e)}setMarkType(){return r.GrammarMarkType.cell}parseScaleOfEncodeX(e){const t=super.parseScaleOfEncodeX(e);return t.type="point",t}parseScaleByEncode(e,t){return this.parseScaleOfCommonEncode(e,t)}setDefaultCrosshair(){return{x:{crosshairShape:"line"}}}setDefaultTooltip(){var e,t;return{title:null===(e=this.spec.encode)||void 0===e?void 0:e.x,content:[{value:null===(t=this.spec.encode)||void 0===t?void 0:t.y}]}}convertMarkEncode(e){var t,i,o;const a=this.convertSimpleMarkEncode(e),l={y:a.y,x:a.x};return a.color||a.group?l.stroke=null!==(t=a.color)&&void 0!==t?t:a.group:l.stroke=null!==(o=null===(i=this.spec.style)||void 0===i?void 0:i.fill)&&void 0!==o?o:r.getPalette()[0],l}}p.type=d.cell;class h extends n{constructor(e){super(d.ruleX,e)}setMarkType(){return r.GrammarMarkType.rule}parseScaleOfEncodeX(e){const t=super.parseScaleOfEncodeX(e);return t.type="point",t}parseScaleByEncode(e,t){return this.parseScaleOfCommonEncode(e,t)}convertMarkEncode(e){var t,i,o;const a=this.convertSimpleMarkEncode(e),l={x:a.x,x1:a.x,y:(e,t,i)=>0,y1:(e,t,i)=>i.viewBox.height()};return a.color||a.group?l.stroke=null!==(t=a.color)&&void 0!==t?t:a.group:l.stroke=null!==(o=null===(i=this.spec.style)||void 0===i?void 0:i.stroke)&&void 0!==o?o:r.getPalette()[0],l}}h.type=d.ruleX;class v extends n{constructor(e){super(d.ruleX,e)}setMarkType(){return r.GrammarMarkType.rule}parseScaleOfEncodeX(e){const t=super.parseScaleOfEncodeX(e);return t.type="point",t}parseScaleByEncode(e,t){return this.parseScaleOfCommonEncode(e,t)}convertMarkEncode(e){var t,i,o;const a=this.convertSimpleMarkEncode(e),l={y:a.y,y1:a.y,x:(e,t,i)=>0,x1:(e,t,i)=>i.viewBox.width()};return a.color||a.group?l.stroke=null!==(t=a.color)&&void 0!==t?t:a.group:l.stroke=null!==(o=null===(i=this.spec.style)||void 0===i?void 0:i.stroke)&&void 0!==o?o:r.getPalette()[0],l}}v.type=d.ruleX;class y extends n{constructor(e){super(d.area,e)}setMarkType(){return r.GrammarMarkType.area}parseScaleOfEncodeX(e){const t=super.parseScaleOfEncodeX(e);return t.type="point",t}parseScaleByEncode(e,t){return this.parseScaleOfCommonEncode(e,t)}setDefaultCrosshair(){return{x:{crosshairShape:"line"}}}setDefaultTooltip(){var e,t;const r=null===(e=this.spec.encode)||void 0===e?void 0:e.x,o=null===(t=this.spec.encode)||void 0===t?void 0:t.y;return{disableGraphicTooltip:!0,title:i.isArray(r)?r[0]:r,content:i.isArray(o)?o.map((e=>({value:e}))):[{value:o}]}}convertMarkEncode(e){var t,o,a,l,s;const n=this.convertSimpleMarkEncode(e);let d;if(i.isArray(null===(t=n.x)||void 0===t?void 0:t.field))d={y:n.y,x:{field:n.x.field[0],scale:n.x.scale},x1:{field:n.x.field[1],scale:n.x.scale}};else if(i.isArray(null===(o=n.y)||void 0===o?void 0:o.field))d={y:{field:n.y.field[0],scale:n.y.scale},y1:{field:n.y.field[1],scale:n.y.scale},x:n.x};else{const e=this.getScaleId("y");d={x:n.x,y:n.y,y1:(t,i,r)=>{const o=r[e],a=o.domain(),l=Math.min.apply(null,a),s=Math.max.apply(null,a),n=l>0?l:s<0?s:0;return o.scale(n)}}}return n.color||n.group?d.fill=null!==(a=n.color)&&void 0!==a?a:n.group:d.fill=null!==(s=null===(l=this.spec.style)||void 0===l?void 0:l.fill)&&void 0!==s?s:r.getPalette()[0],d}}function f(e,t,i,r){return new(i||(i=Promise))((function(o,a){function l(e){try{n(r.next(e))}catch(e){a(e)}}function s(e){try{n(r.throw(e))}catch(e){a(e)}}function n(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(l,s)}n((r=r.apply(e,t||[])).next())}))}y.type=d.area,"function"==typeof SuppressedError&&SuppressedError;const g=(e,t)=>e.reduce(((e,t)=>(t.id&&!e.some((e=>e.id===t.id))&&e.push(t),e)),t);class m{static useMarks(e){e.forEach((e=>{r.Factory.registerPlotMarks(e.type,e)}))}constructor(e){this._view=new r.View(e),this._semanticMarks=[],this._logger=i.Logger.getInstance()}_mergeScales(e,t){return e.reduce(((e,t)=>{if(t.id){const r=e.find((e=>e.id===t.id));if(r){if(t.domain.data&&t.domain.field)if(r.domain.data&&r.domain.field)t.domain.data===r.domain.data&&t.domain.field!==r.domain.field?r.domain.field=[].concat(r.domain.field).concat(t.domain.field):t.domain.data!==r.domain.data&&(r.domain={datas:[{data:r.domain.data,field:r.domain.field},{data:t.domain.data,field:t.domain.field}],sort:r.domain.sort}),i.isNil(t.domain.sort)||(r.domain.sort=t.domain.sort);else if(r.domain.datas){const e=r.domain.datas.find((e=>e.data!==t.domain.data));e&&t.domain.field!==e.field?e.field=[].concat(e.field).concat(t.domain.field):e||r.domain.datas.push({data:t.domain.data,field:t.domain.field}),i.isNil(t.domain.sort)||(r.domain.sort=t.domain.sort)}}else e.push(t)}return e}),t)}parseViewSpec(){const e={data:[],marks:[],scales:[],coordinates:[],signals:[],projections:[],events:[]};return this._semanticMarks.forEach((t=>{this._coordinate&&t.coordinate(this._coordinate);const{data:i,marks:r,scales:o,coordinates:a,signals:l,projections:s,events:n}=t.toViewSpec();i&&i.length&&(e.data=g(i,e.data)),r&&r.length&&(e.marks=e.marks.concat(r)),o&&o.length&&(e.scales=this._mergeScales(o,e.scales)),a&&a.length&&(e.coordinates=g(a,e.coordinates)),l&&l.length&&(e.signals=e.signals.concat(l)),s&&s.length&&(e.projections=e.projections.concat(s)),n&&n.length&&(e.events=e.events.concat(n))})),e.marks=[{type:"group",layout:{display:"relative",updateViewSignals:!0},dependency:[r.SIGNAL_VIEW_BOX],encode:{update:(e,t,i)=>({x:i.viewBox.x1,y:i.viewBox.y1,width:i.viewBox.width(),height:i.viewBox.height()})},marks:e.marks}],e}run(e){return this._view&&(this._hasInited||this._view.parseSpec(this.parseViewSpec()),this._hasInited=!0,this._view.runSync(e)),this}runAsync(e){return f(this,void 0,void 0,(function*(){return this._view&&(this._hasInited||this._view.parseSpec(this.parseViewSpec()),this._hasInited=!0,yield this._view.runAsync(e)),this}))}release(){return this._view&&this._view.release(),this}updateSpec(e){return this.parseSpec(e,!0),this}parseSpec(e,t){var i;e.coordinate&&this.coordinate(e.coordinate.type,e.coordinate),(null===(i=null==e?void 0:e.marks)||void 0===i?void 0:i.length)&&e.marks.forEach((e=>{const t=r.Factory.createPlotMark(e.type);t.parseSpec(e),this._semanticMarks.push(t)}));const o=this.parseViewSpec();return o.width=e.width,o.height=e.height,o.background=e.background,o.padding=e.padding,t?this._view.updateSpec(o):this._view.parseSpec(o),this._hasInited=!0,this}getImageBuffer(){var e,t;return null===(t=null===(e=this._view)||void 0===e?void 0:e.getImageBuffer)||void 0===t?void 0:t.call(e)}on(e,t){return this._view&&this._view.addEventListener(e,t),this}off(e,t){return this._view&&this._view.removeEventListener(e,t),this}getCoordinateId(e="0"){return`coordinate-${e}`}coordinate(e,t){return this._coordinate=Object.assign({type:e,id:this.getCoordinateId()},t),this}interval(){const e=r.Factory.createPlotMark(d.interval);return e?this._semanticMarks.push(e):this._logger.error(`Please register ${d.interval} before use it`),e}line(){const e=r.Factory.createPlotMark(d.line);return e?this._semanticMarks.push(e):this._logger.error(`Please register ${d.line} before use it`),e}area(){const e=r.Factory.createPlotMark(d.area);return e?this._semanticMarks.push(e):this._logger.error(`Please register ${d.area} before use it`),e}cell(){const e=r.Factory.createPlotMark(d.cell);return e?this._semanticMarks.push(e):this._logger.error(`Please register ${d.cell} before use it`),e}ruleX(){const e=r.Factory.createPlotMark(d.ruleX);return e?this._semanticMarks.push(e):this._logger.error(`Please register ${this.ruleX} before use it`),e}ruleY(){const e=r.Factory.createPlotMark(d.ruleY);return e?this._semanticMarks.push(e):this._logger.error(`Please register ${d.ruleY} before use it`),e}image(){const e=r.Factory.createPlotMark(d.image);return e?this._semanticMarks.push(e):this._logger.error(`Please register ${d.image} before use it`),e}path(){const e=r.Factory.createPlotMark(d.path);return e?this._semanticMarks.push(e):this._logger.error(`Please register ${d.path} before use it`),e}polygon(){const e=r.Factory.createPlotMark(d.polygon);return e?this._semanticMarks.push(e):this._logger.error(`Please register ${d.polygon} before use it`),e}rectX(){const e=r.Factory.createPlotMark(d.rectX);return e?this._semanticMarks.push(e):this._logger.error(`Please register ${d.rectX} before use it`),e}rectY(){const e=r.Factory.createPlotMark(d.rectY);return e?this._semanticMarks.push(e):this._logger.error(`Please register ${d.rectY} before use it`),e}rect(){const e=r.Factory.createPlotMark(d.rect);return e?this._semanticMarks.push(e):this._logger.error(`Please register ${d.rect} before use it`),e}rule(){const e=r.Factory.createPlotMark(d.rule);return e?this._semanticMarks.push(e):this._logger.error(`Please register ${d.rule} before use it`),e}symbol(){const e=r.Factory.createPlotMark(d.symbol);return e?this._semanticMarks.push(e):this._logger.error(`Please register ${d.symbol} before use it`),e}text(){const e=r.Factory.createPlotMark(d.text);return e?this._semanticMarks.push(e):this._logger.error(`Please register ${d.text} before use it`),e}sankey(){const e=r.Factory.createPlotMark(d.sankey);return e?this._semanticMarks.push(e):this._logger.error(`Please register ${d.sankey} before use it`),e}sunburst(){const e=r.Factory.createPlotMark(d.sunburst);return e?this._semanticMarks.push(e):this._logger.error(`Please register ${d.sunburst} before use it`),e}tree(){const e=r.Factory.createPlotMark(d.tree);return e?this._semanticMarks.push(e):this._logger.error(`Please register ${d.tree} before use it`),e}treemap(){const e=r.Factory.createPlotMark(d.treemap);return e?this._semanticMarks.push(e):this._logger.error(`Please register ${d.treemap} before use it`),e}circlePacking(){const e=r.Factory.createPlotMark(d.circlePacking);return e?this._semanticMarks.push(e):this._logger.error(`Please register ${d.circlePacking} before use it`),e}wordcloud(){const e=r.Factory.createPlotMark(d.wordcloud);return e?this._semanticMarks.push(e):this._logger.error(`Please register ${d.wordcloud} before use it`),e}wordcloudShape(){const e=r.Factory.createPlotMark(d.wordcloudShape);return e?this._semanticMarks.push(e):this._logger.error(`Please register ${d.wordcloudShape} before use it`),e}}class k extends n{constructor(e){super(d.image,e)}setMarkType(){return r.GrammarMarkType.image}parseScaleOfEncodeX(e){const t=super.parseScaleOfEncodeX(e);return t.type="point",t}parseScaleByEncode(e,t){return"src"===e?{type:"ordinal",id:this.getScaleId("src"),domain:{data:this.getDataIdOfMain(),field:t}}:this.parseScaleOfCommonEncode(e,t)}convertMarkEncode(e){var o,a,l,s,n,d,c,u,p;const h=this.convertSimpleMarkEncode(e),v=this.getScaleId("x"),y=this.getScaleId("y"),f={image:h.src};if(h.src&&(f.image=h.src),i.isArray(null===(o=h.x)||void 0===o?void 0:o.field)){const e=t.field(h.x.field[0]),i=t.field(h.x.field[1]);f.x=(t,r,o)=>{const a=o[v];return Math.min(a.scale(e(t)),a.scale(i(t)))},f.width=(t,r,o)=>{const a=o[v];return Math.abs(a.scale(e(t))-a.scale(i(t)))}}else{const e=null!==(l=null===(a=this.spec.style)||void 0===a?void 0:a.width)&&void 0!==l?l:k.defaultSpec.width,i=t.field(h.x.field);f.x=(t,r,o)=>o[v].scale(i(t))-e/2,f.width=e}if(i.isArray(null===(s=h.y)||void 0===s?void 0:s.field)){const e=t.field(h.y.field[0]),i=t.field(h.y.field[1]);f.y=(t,r,o)=>{const a=o[y];return Math.min(a.scale(e(t)),a.scale(i(t)))},f.height=(t,r,o)=>{const a=o[y];return Math.abs(a.scale(e(t))-a.scale(i(t)))}}else{const e=null!==(d=null===(n=this.spec.style)||void 0===n?void 0:n.height)&&void 0!==d?d:k.defaultSpec.height,i=t.field(h.y.field);f.y=(t,r,o)=>o[v].scale(i(t))-e/2,f.height=e}return h.color||h.group?f.fill=null!==(c=h.color)&&void 0!==c?c:h.group:f.fill=null!==(p=null===(u=this.spec.style)||void 0===u?void 0:u.fill)&&void 0!==p?p:r.getPalette()[0],f}}k.type=d.image,k.defaultSpec={width:10,height:10};class x extends n{constructor(e){super(d.path,e)}setMarkType(){return r.GrammarMarkType.path}parseScaleByEncode(e,t){return null}convertMarkEncode(e){return null}}x.type=d.path;class S extends n{constructor(e){super(d.polygon,e)}setMarkType(){return r.GrammarMarkType.polygon}parseScaleOfEncodeX(e){const t=super.parseScaleOfEncodeX(e);return t.type="point",t}parseScaleByEncode(e,t){return this.parseScaleOfCommonEncode(e,t)}convertMarkEncode(e){var i,o,a,l,s,n,d;const c=this.convertSimpleMarkEncode(e),u=this.getScaleId("x"),p=this.getScaleId("y"),h={};if((null===(o=null===(i=c.x)||void 0===i?void 0:i.field)||void 0===o?void 0:o.length)&&(null===(l=null===(a=c.y)||void 0===a?void 0:a.field)||void 0===l?void 0:l.length)){const e=c.x.field.map((e=>t.field(e))),i=c.y.field.map((e=>t.field(e)));h.points=(t,r,o)=>{const a=o[u],l=o[p],s=Math.min(e.length,i.length),n=[];for(let r=0;r<s;r++)n.push({x:a.scale(e[r](t)),y:l.scale(i[r](t))});return n}}return c.color||c.group?h.fill=null!==(s=c.color)&&void 0!==s?s:c.group:h.fill=null!==(d=null===(n=this.spec.style)||void 0===n?void 0:n.fill)&&void 0!==d?d:r.getPalette()[0],h}}S.type=d.polygon;class M extends n{constructor(e){super(d.rectX,e)}setMarkType(){return r.GrammarMarkType.rect}parseScaleByEncode(e,t){return this.parseScaleOfCommonEncode(e,t)}setDefaultCrosshair(){return{x:{crosshairShape:"rect"}}}setDefaultTooltip(){var e;const t=null===(e=this.spec.encode)||void 0===e?void 0:e.x;return{content:i.isArray(t)?t.map((e=>({value:e}))):[{value:t}]}}convertMarkEncode(e){var o,a,l,s;const n=this.convertSimpleMarkEncode(e),d=this.getScaleId("x"),c={y:(e,t,i)=>0,y1:(e,t,i)=>i.viewBox.height()};if(i.isArray(null===(o=n.x)||void 0===o?void 0:o.field))c.x={field:n.x.field[0],scale:n.x.scale},c.x1={field:n.x.field[1],scale:n.x.scale};else{const e=t.field(n.x.field);c.x=(t,r,o)=>{const a=e(t),l=o[d];return i.isArray(a)?l.scale(a[0]):l.scale(a)},c.x1=(t,r,o)=>{const a=o[d],l=e(t);if(i.isArray(l)&&l.length>1)return a.scale(l[1]);const s=a.domain(),n=Math.min.apply(null,s),c=Math.max.apply(null,s),u=n>0?n:c<0?c:0;return a.scale(u)}}return n.color||n.group?c.fill=null!==(a=n.color)&&void 0!==a?a:n.group:c.fill=null!==(s=null===(l=this.spec.style)||void 0===l?void 0:l.fill)&&void 0!==s?s:r.getPalette()[0],c}}M.type=d.rectX;class b extends n{constructor(e){super(d.rectY,e)}setMarkType(){return r.GrammarMarkType.rect}parseScaleByEncode(e,t){return this.parseScaleOfCommonEncode(e,t)}setDefaultCrosshair(){return{x:{crosshairShape:"rect"}}}setDefaultTooltip(){var e;const t=null===(e=this.spec.encode)||void 0===e?void 0:e.y;return{content:i.isArray(t)?t.map((e=>({value:e}))):[{value:t}]}}convertMarkEncode(e){var o,a,l,s;const n=this.convertSimpleMarkEncode(e),d=this.getScaleId("y"),c={x:(e,t,i)=>0,x1:(e,t,i)=>i.viewBox.width()};if(i.isArray(null===(o=n.y)||void 0===o?void 0:o.field))c.y={field:n.y.field[0],scale:n.y.scale},c.y1={field:n.y.field[1],scale:n.y.scale};else{const e=t.field(n.y.field);c.y=(t,r,o)=>{const a=e(t),l=o[d];return i.isArray(a)?l.scale(a[0]):l.scale(a)},c.y1=(t,r,o)=>{const a=o[d],l=e(t);if(i.isArray(l)&&l.length>1)return a.scale(l[1]);const s=a.domain(),n=Math.min.apply(null,s),c=Math.max.apply(null,s),u=n>0?n:c<0?c:0;return a.scale(u)}}return n.color||n.group?c.fill=null!==(a=n.color)&&void 0!==a?a:n.group:c.fill=null!==(s=null===(l=this.spec.style)||void 0===l?void 0:l.fill)&&void 0!==s?s:r.getPalette()[0],c}}b.type=d.rectY;class w extends n{constructor(e){super(d.rect,e)}setMarkType(){return r.GrammarMarkType.rect}parseScaleByEncode(e,t){return this.parseScaleOfCommonEncode(e,t)}setDefaultCrosshair(){return{x:{crosshairShape:"rect"}}}setDefaultTooltip(){var e;const t=null===(e=this.spec.encode)||void 0===e?void 0:e.y;return{content:i.isArray(t)?t.map((e=>({value:e}))):[{value:t}]}}convertMarkEncode(e){var o,a,l,s,n;const d=this.convertSimpleMarkEncode(e),c=this.getScaleId("x"),u=this.getScaleId("y"),p={};if(i.isArray(null===(o=d.x)||void 0===o?void 0:o.field))p.x={field:d.x.field[0],scale:d.x.scale},p.x1={field:d.x.field[1],scale:d.x.scale};else{const e=t.field(d.x.field);p.x=(t,r,o)=>{const a=e(t),l=o[c];return i.isArray(a)?l.scale(a[0]):l.scale(a)},p.x1=(t,r,o)=>{const a=o[c],l=e(t);if(i.isArray(l)&&l.length>1)return a.scale(l[1]);const s=a.domain(),n=Math.min.apply(null,s),d=Math.max.apply(null,s),u=n>0?n:d<0?d:0;return a.scale(u)}}if(i.isArray(null===(a=d.y)||void 0===a?void 0:a.field))p.y={field:d.y.field[0],scale:d.y.scale},p.y1={field:d.y.field[1],scale:d.y.scale};else{const e=t.field(d.y.field);p.y=(t,r,o)=>{const a=e(t),l=o[u];return i.isArray(a)?l.scale(a[0]):l.scale(a)},p.y1=(t,r,o)=>{const a=o[u],l=e(t);if(i.isArray(l)&&l.length>1)return a.scale(l[1]);const s=a.domain(),n=Math.min.apply(null,s),d=Math.max.apply(null,s),c=n>0?n:d<0?d:0;return a.scale(c)}}return d.color||d.group?p.fill=null!==(l=d.color)&&void 0!==l?l:d.group:p.fill=null!==(n=null===(s=this.spec.style)||void 0===s?void 0:s.fill)&&void 0!==n?n:r.getPalette()[0],p}}w.type=d.rect;class P extends n{constructor(e){super(d.rule,e)}setMarkType(){return r.GrammarMarkType.rule}parseScaleOfEncodeX(e){const t=super.parseScaleOfEncodeX(e);return t.type="point",t}parseScaleByEncode(e,t){return this.parseScaleOfCommonEncode(e,t)}convertMarkEncode(e){var t,o,a,l,s;const n=this.convertSimpleMarkEncode(e);let d;return i.isArray(null===(t=n.x)||void 0===t?void 0:t.field)?(d.x={field:n.x.field[0],scale:n.x.scale},d.x1={field:n.x.field[1],scale:n.x.scale}):d.x=d.x1=n.x,i.isArray(null===(o=n.y)||void 0===o?void 0:o.field)?(d.y={field:n.y.field[0],scale:n.y.scale},d.y1={field:n.y.field[1],scale:n.y.scale}):d.y=d.y1=n.y,n.color||n.group?d.stroke=null!==(a=n.color)&&void 0!==a?a:n.group:d.stroke=null!==(s=null===(l=this.spec.style)||void 0===l?void 0:l.stroke)&&void 0!==s?s:r.getPalette()[0],d}}P.type=d.rule;class O extends n{constructor(e){super(d.symbol,e)}setMarkType(){return r.GrammarMarkType.symbol}parseScaleOfEncodeX(e){const t=super.parseScaleOfEncodeX(e);return t.type="point",t}parseScaleByEncode(e,t){return"size"===e?{type:"linear",id:this.getScaleId("size"),domain:{data:this.getDataIdOfFiltered(),field:t},range:[O.defaultSpec.size,O.defaultSpec.size]}:"shape"===e?{type:"ordinal",id:this.getScaleId("shape"),domain:{data:this.getDataIdOfMain(),field:t}}:this.parseScaleOfCommonEncode(e,t)}convertMarkEncode(e){var t,i,o;const a=this.convertSimpleMarkEncode(e),l={x:a.x,y:a.y};return a.shape&&(l.symbolType=a.shape),a.size&&(l.size=a.size),a.color||a.group?l.fill=null!==(t=a.color)&&void 0!==t?t:a.group:l.fill=null!==(o=null===(i=this.spec.style)||void 0===i?void 0:i.fill)&&void 0!==o?o:r.getPalette()[0],l}}O.defaultSpec={size:10},O.type=d.symbol;class E extends n{constructor(e){super(d.text,e)}setMarkType(){return r.GrammarMarkType.text}parseScaleOfEncodeX(e){const t=super.parseScaleOfEncodeX(e);return t.type="point",t}parseScaleByEncode(e,t){return this.parseScaleOfCommonEncode(e,t)}convertMarkEncode(e){var t,i,o;const a=this.convertSimpleMarkEncode(e),l=a;return a.color||a.group?l.fill=null!==(t=a.color)&&void 0!==t?t:a.group:l.fill=null!==(o=null===(i=this.spec.style)||void 0===i?void 0:i.fill)&&void 0!==o?o:r.getPalette()[0],l}}E.type=d.text;class I extends n{constructor(e){super(d.sankey,e),r.getTransform(d.sankey)||this._logger.error("Please add this line of code: import { registerSankeyTransforms } from '@visactor/vgrammar-sankey'; \n and run registerSankeyTransforms() before use sankey"),r.getGlyph("linkPath")||this._logger.error("\n Please add this line of code: import { registerLinkPathGlyph } from '@visactor/vgrammar';\n add run registerLinkPathGlyph() before use sankey\n ")}setMarkType(){return r.GrammarMarkType.rect}setDefaultDataTransform(){var e;return[{type:"sankey",width:{signal:"viewWidth"},height:{signal:"viewHeight"},nodeKey:null===(e=this.spec.encode)||void 0===e?void 0:e.node}]}getDataIdOfLink(){var e,t;return`${null!==(t=null===(e=this.spec.data)||void 0===e?void 0:e.id)&&void 0!==t?t:this.spec.id}-data-link`}setMultipleData(){return[{id:this.getDataIdOfFiltered(),transform:[{type:"map",all:!0,callback:e=>e[0].nodes}]},{source:this.getDataIdOfMain(),id:this.getDataIdOfLink(),transform:[{type:"map",all:!0,callback:e=>e[0].links}]}]}parseScaleByEncode(e,t){return"color"===e?{type:"ordinal",id:this.getScaleId("color"),domain:{data:this.getDataIdOfFiltered(),field:t},range:r.getPalette()}:null}convertMarkEncode(e){var i,o,a;const l=this.convertSimpleMarkEncode(e),s={x:{field:"x0"},x1:{field:"x1"},y:{field:"y0"},y1:{field:"y1"}};if(l.color){const e=this.getScaleId("color"),i=t.field(l.color.field);s.fill=(t,r,o)=>o[e].scale(i(null==t?void 0:t.datum))}else s.fill=null!==(a=null===(o=null===(i=this.spec.style)||void 0===i?void 0:i.nodeStyle)||void 0===o?void 0:o.fill)&&void 0!==a?a:r.getPalette()[0];return s}setMainMarkSpec(){return{key:"key"}}setLabelTextGetter(e,i){const r=t.field(e);return(e,t,i)=>r(e.datum)}setMultiMarksSpec(){var e;return[{id:`${this.getMarkId()}-link`,type:"glyph",glyphType:"linkPath",from:{data:this.getDataIdOfLink()},layout:{position:"content",skipBeforeLayouted:!0},key:"index",dependency:this.viewSpec.scales.map((e=>e.id)).concat(r.SIGNAL_VIEW_BOX),animation:this.convertMarkAnimation(),encode:Object.assign({},this.spec.state,{enter:Object.assign({backgroundStyle:{fillColor:"#ccc",fillOpacity:.2},fillOpacity:.8,round:!0},null===(e=this.spec.style)||void 0===e?void 0:e.linkStyle),update:(e,t,i)=>{var o,a,l;return{direction:e.vertical?"vertical":"horizontal",x0:e.x0,x1:e.x1,y0:e.y0,y1:e.y1,thickness:e.thickness,fill:null!==(l=null===(a=null===(o=this.spec.style)||void 0===o?void 0:o.linkStyle)||void 0===a?void 0:a.fill)&&void 0!==l?l:r.getPalette()[0]}}})}]}}I.type=d.sankey;class _ extends n{constructor(e){super(d.sunburst,e),r.getTransform("sunburst")||this._logger.error("Please add this line of code: import { registerSunburstTransforms } from 'vgrammar-hierarchy': \n and run registerSunburstTransforms() before use sunburst chart")}setMarkType(){return r.GrammarMarkType.arc}setDefaultDataTransform(){var e;return[{type:"sunburst",width:{signal:"viewWidth"},height:{signal:"viewHeight"},nodeKey:null===(e=this.spec.encode)||void 0===e?void 0:e.node,flatten:!0}]}getDataIdOfLabel(){var e,t;return`${null!==(t=null===(e=this.spec.data)||void 0===e?void 0:e.id)&&void 0!==t?t:this.spec.id}-data-link`}setMultipleData(){return this.spec.label?[{source:this.getDataIdOfFiltered(),id:this.getDataIdOfLabel(),transform:[{type:"filter",callback:e=>!!e.label}]}]:null}parseScaleByEncode(e,t){return"color"===e?{type:"ordinal",id:this.getScaleId("color"),domain:{data:this.getDataIdOfFiltered(),field:t},range:r.getPalette()}:null}convertMarkEncode(e){var i,o;const a=this.convertSimpleMarkEncode(e),l={x:{field:"x"},y:{field:"y"},innerRadius:{field:"innerRadius"},outerRadius:{field:"outerRadius"},startAngle:{field:"startAngle"},endAngle:{field:"endAngle"}};if(a.color){const e=this.getScaleId("color"),i=t.field(a.color.field);l.fill=(t,r,o)=>{const a=o[e];return(null==t?void 0:t.datum)?a.scale(i(t.datum[t.datum.length-1])):void 0}}else l.fill=null!==(o=null===(i=this.spec.style)||void 0===i?void 0:i.fill)&&void 0!==o?o:r.getPalette()[0];return l}setMainMarkEnterEncode(){var e;return null===(e=this.spec.style)||void 0===e?void 0:e.nodeStyle}setMainMarkSpec(){return{key:"key"}}parseLabelSpec(){return[]}setMultiMarksSpec(){const e=this.spec.label;return e?Object.keys(e).map((i=>{const o=t.field(i);return{id:`${this.getMarkId()}-text-${i}`,type:"text",from:{data:this.getDataIdOfLabel()},layout:{position:"content",skipBeforeLayouted:!0},key:"flattenIndex",dependency:this.viewSpec.scales.map((e=>e.id)).concat(r.SIGNAL_VIEW_BOX),animation:this.convertMarkAnimation(),encode:{enter:e[i].textStyle,update:(e,t,i)=>({x:e.label.x,y:e.label.y,textAlign:e.label.textAlign,textBaseline:e.label.textBaseline,text:o(e.datum[e.datum.length-1]),angle:e.label.angle,maxLineWidth:e.label.maxLineWidth})}}})):null}}_.type=d.sunburst;class T extends n{constructor(e){super(d.treemap,e),r.getTransform("treemap")||this._logger.error("Please add this line of code: import { registerTreemapTransforms } from 'vgrammar-hierarchy'; \n and run registerTreemapTransforms() before use treemap")}setMarkType(){return r.GrammarMarkType.rect}setDefaultDataTransform(){var e;return[{type:"treemap",width:{signal:"viewWidth"},height:{signal:"viewHeight"},nodeKey:null===(e=this.spec.encode)||void 0===e?void 0:e.node,flatten:!0}]}parseScaleByEncode(e,t){return"color"===e?{type:"ordinal",id:this.getScaleId("color"),domain:{data:this.getDataIdOfFiltered(),field:t},range:r.getPalette()}:null}convertMarkEncode(e){var i,o;const a=this.convertSimpleMarkEncode(e),l={x:{field:"x0"},x1:{field:"x1"},y:{field:"y0"},y1:{field:"y1"}};if(a.color){const e=this.getScaleId("color"),i=t.field(a.color.field);l.fill=(t,r,o)=>{const a=o[e];return(null==t?void 0:t.datum)?a.scale(i(t.datum[t.datum.length-1])):void 0}}else l.fill=null!==(o=null===(i=this.spec.style)||void 0===i?void 0:i.fill)&&void 0!==o?o:r.getPalette()[0];return l}setMainMarkSpec(){return{key:"key"}}parseLabelSpec(){return[]}setMultiMarksSpec(){const e=this.spec.label;return e?Object.keys(e).map((i=>{const o=t.field(i);return{id:`${this.getMarkId()}-text-${i}`,type:"text",from:{data:this.getDataIdOfFiltered()},layout:{position:"content",skipBeforeLayouted:!0},key:"flattenIndex",dependency:this.viewSpec.scales.map((e=>e.id)).concat(r.SIGNAL_VIEW_BOX),animation:this.convertMarkAnimation(),encode:{enter:Object.assign({textAlign:"center",textBaseline:"middle"},e[i].textStyle),update:(e,t,i)=>({x:e.labelRect?(e.labelRect.x0+e.labelRect.x1)/2:(e.x0+e.x1)/2,y:e.labelRect?(e.labelRect.y0+e.labelRect.y1)/2:(e.y0+e.y1)/2,text:o(e.datum[e.datum.length-1])})}}})):null}}T.type=d.treemap;class D extends n{constructor(e){super(d.circlePacking,e),r.getTransform(d.circlePacking)||this._logger.error("Please add this line of code: import { registerCirclePackingTransforms } from '@visactor/vgrammar-hierarchy'; \n and run registerCirclePackingTransforms() before use treemap chart")}setMarkType(){return r.GrammarMarkType.circle}setDefaultDataTransform(){var e;return[{type:d.circlePacking,width:{signal:"viewWidth"},height:{signal:"viewHeight"},nodeKey:null===(e=this.spec.encode)||void 0===e?void 0:e.node,flatten:!0}]}parseScaleByEncode(e,t){return"color"===e?{type:"ordinal",id:this.getScaleId("color"),domain:{data:this.getDataIdOfFiltered(),field:t},range:r.getPalette()}:null}convertMarkEncode(e){var i,o;const a=this.convertSimpleMarkEncode(e),l={x:{field:"x"},y:{field:"y"},radius:{field:"radius"}};if(a.color){const e=this.getScaleId("color"),i=t.field(a.color.field);l.fill=(t,r,o)=>{const a=o[e];return(null==t?void 0:t.datum)?a.scale(i(t.datum[t.datum.length-1])):void 0}}else l.fill=null!==(o=null===(i=this.spec.style)||void 0===i?void 0:i.fill)&&void 0!==o?o:r.getPalette()[0];return l}setMainMarkSpec(){return{key:"key"}}setLabelTextGetter(e,i){const r=t.field(e);return(e,t,i)=>r(e.datum[e.datum.length-1])}}D.type=d.circlePacking;class B extends n{constructor(e){super(d.tree,e),r.getTransform(d.tree)||this._logger.error("Please add this line of code: import { registerTreeTransforms } from 'vgrammar-hierarchy', \n and run registerTreeTransforms() before use tree"),r.getGlyph("treePath")||this._logger.error("Please add this line of code: import { registerTreePathGlyph } from '@visactor/vgrammar';\n and run registerTreePathGlyph() before use tree")}setMarkType(){return r.GrammarMarkType.symbol}setDefaultDataTransform(){var e;return[{type:"tree",width:{signal:"viewWidth"},height:{signal:"viewHeight"},nodeKey:null===(e=this.spec.encode)||void 0===e?void 0:e.node,flatten:!0}]}getDataIdOfLink(){var e,t;return`${null!==(t=null===(e=this.spec.data)||void 0===e?void 0:e.id)&&void 0!==t?t:this.spec.id}-data-link`}setMultipleData(){return[{id:this.getDataIdOfFiltered(),transform:[{type:"map",all:!0,callback:e=>e[0].nodes}]},{source:this.getDataIdOfMain(),id:this.getDataIdOfLink(),transform:[{type:"map",all:!0,callback:e=>e[0].links}]}]}parseScaleByEncode(e,t){return"color"===e?{type:"ordinal",id:this.getScaleId("color"),domain:{data:this.getDataIdOfFiltered(),field:t},range:r.getPalette()}:null}convertMarkEncode(e){var i,o;const a=this.convertSimpleMarkEncode(e),l={x:{field:"x"},y:{field:"y"}};if(a.color){const e=this.getScaleId("color"),i=t.field(a.color.field);l.fill=(t,r,o)=>{const a=o[e];return(null==t?void 0:t.datum)?a.scale(i(t.datum[t.datum.length-1])):void 0}}else l.fill=null!==(o=null===(i=this.spec.style)||void 0===i?void 0:i.fill)&&void 0!==o?o:r.getPalette()[0];return l}setLabelTextGetter(e,i){const r=t.field(e);return(e,t,i)=>r(e.datum[e.datum.length-1])}setMainMarkSpec(){return{key:"key"}}setMultiMarksSpec(){if(!this.spec.label)return null;const e=[];return e.push({type:"glyph",glyphType:"treePath",from:{data:this.getDataIdOfLink()},key:"key",zIndex:-1,encode:{update:{x0:{field:"x0"},x1:{field:"x1"},y0:{field:"y0"},y1:{field:"y1"},thickness:1,round:!0,stroke:"#333"}}}),e}}B.type=d.tree;class A extends n{constructor(e){super(d.wordcloud,e),r.getTransform(d.wordcloud)||this._logger.error("Please add this line of code:\n 'import { registerWordCloudTransforms } from '@visactor/vgrammar-wordcloud'; \n and run registerWordCloudTransforms() before use wordcloud")}setMarkType(){return r.GrammarMarkType.text}setDefaultMarkTransform(){var e;return[{type:"wordcloud",size:{callback:e=>[e.viewBox.width(),e.viewBox.height()],dependency:["viewBox"]},text:{field:null===(e=this.spec.encode)||void 0===e?void 0:e.text}}]}parseScaleByEncode(e,t){return"color"===e?{type:"ordinal",id:this.getScaleId("color"),domain:{data:this.getDataIdOfFiltered(),field:t},range:r.getPalette()}:null}convertMarkEncode(e){var i,o,a;const l=this.convertSimpleMarkEncode(e),s={x:{field:"x"},y:{field:"y"},angle:{field:"angle"},fontSize:{field:"fontSize"},fontStyle:{field:"fontStyle"},fontFamily:{field:"fontFamily"},fontWeight:{field:"fontWeight"},text:{field:null===(i=this.spec.encode)||void 0===i?void 0:i.text}};if(l.color){const e=this.getScaleId("color"),i=t.field(l.color.field);s.fill=(t,r,o)=>o[e].scale(i(t))}else s.fill=null!==(a=null===(o=this.spec.style)||void 0===o?void 0:o.fill)&&void 0!==a?a:r.getPalette()[0];return s}parseLabelSpec(){return[]}}A.type=d.wordcloud;class G extends n{constructor(e){super(d.wordcloudShape,e),r.getTransform(d.wordcloudShape)||this._logger.error("Please add this line of code:\n import { registerWordCloudShapeTransforms } from '@visactor/vgrammar-wordcloud-shape'; \n and run registerWordCloudShapeTransforms() before use wordcloud-shape")}setMarkType(){return r.GrammarMarkType.text}setDefaultDataTransform(){var e;return[{type:"wordcloudShape",size:{callback:e=>[e.viewBox.width(),e.viewBox.height()],dependency:["viewBox"]},colorList:r.getPalette(),text:{field:null===(e=this.spec.encode)||void 0===e?void 0:e.text}}]}parseScaleByEncode(e,t){return"color"===e?{type:"ordinal",id:this.getScaleId("color"),domain:{data:this.getDataIdOfFiltered(),field:t},range:r.getPalette()}:null}convertMarkEncode(e){var i,o,a;const l=this.convertSimpleMarkEncode(e),s={x:{field:"x"},y:{field:"y"},angle:{field:"angle"},fontSize:{field:"fontSize"},fontStyle:{field:"fontStyle"},fontFamily:{field:"fontFamily"},fontWeight:{field:"fontWeight"},fillOpacity:{field:"opacity"},text:{field:null===(i=this.spec.encode)||void 0===i?void 0:i.text}};if(l.color){const e=this.getScaleId("color"),i=t.field(l.color.field);s.fill=(t,r,o)=>o[e].scale(i(t))}else s.fill=null!==(a=null===(o=this.spec.style)||void 0===o?void 0:o.fill)&&void 0!==a?a:r.getPalette()[0];return s}parseLabelSpec(){return[]}}G.type=d.wordcloudShape,m.useMarks([c,u,p,h,v,y,k,x,S,w,M,b,P,O,E,I,_,T,D,B,A,G]),e.Plot=m}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@visactor/vgrammar-util"),require("@visactor/vutils"),require("@visactor/vgrammar")):"function"==typeof define&&define.amd?define(["exports","@visactor/vgrammar-util","@visactor/vutils","@visactor/vgrammar"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).VGrammar=e.VGrammar||{},e.VGrammar.Projection={}),e.VGrammar.Util,e.VUtils,e.VGrammar)}(this,(function(e,t,i,o){"use strict";var r;function l(e){switch(e){case r.Ordinal:case r.Point:case r.Band:return!0;default:return!1}}!function(e){e.Identity="identity",e.Linear="linear",e.Log="log",e.Pow="pow",e.Sqrt="sqrt",e.Symlog="symlog",e.Time="time",e.Quantile="quantile",e.Quantize="quantize",e.Threshold="threshold",e.Ordinal="ordinal",e.Point="point",e.Band="band"}(r||(r={}));let a=-1;class s{constructor(e,t,o){this.type=e,this.uid=++a,this._logger=i.Logger.getInstance(),this.plot=o,this.spec={id:null!=t?t:`${this.type}-${this.uid}`}}parseSpec(e){return i.isNil(e.id)&&(e.id=this.spec.id),this.spec=e,this}coordinate(e){return this._coordinate=e,this}data(e,t,o){return i.isNil(e)||(this.spec.data={values:e,transform:t,id:o}),this}encode(e,t){return this.spec.encode||(this.spec.encode={}),this.spec.encode[e]=t,this}scale(e,t){return this.spec.scale||(this.spec.scale={}),this.spec.scale[e]=t,this}style(e){return this.spec.style=e,this}transform(e){return this.spec.transform=i.array(e),this}state(e,t){if(![o.BuiltInEncodeNames.enter,o.BuiltInEncodeNames.update,o.BuiltInEncodeNames.exit,o.BuiltInEncodeNames.group].includes(e))return this.spec.state||(this.spec.state={}),this.spec.state[e]=t,this;this._logger.warn(`[VGrammar]: ${e} is a reserved keyword to specify the encode of different data state, \n don't use this keyword`)}animate(e,t){return"state"===e?(this._logger.warn(`[VGrammar]: ${e} is a keyword use to specify state animation config, don't use this keyword`),this):(this.spec.animation||(this.spec.animation={}),this.spec.animation[e]=t,this)}axis(e,t=!0,i){return this.spec.axis||(this.spec.axis={}),this.spec.axis[e]={option:t,layout:i},this}legend(e,t=!0,i){return this.spec.legend||(this.spec.legend={}),this.spec.legend[e]={option:t,layout:i},this}crosshair(e,t){return this.spec.crosshair||(this.spec.crosshair={}),this.spec.crosshair[e]=t,this}tooltip(e){return this.spec.tooltip=e,this}slider(e,t,i){return this.spec.slider||(this.spec.slider={}),this.spec.slider[e]={option:t,layout:i},this}datazoom(e,t,i){return this.spec.datazoom||(this.spec.datazoom={}),this.spec.datazoom[e]={option:t,layout:i},this}label(e,t){return this.spec.label||(this.spec.label={}),this.spec.label[e]=t,this}player(e,t,i){return this.spec.player={data:e,option:t,layout:i},this}getPalette(){var e;return null===(e=(this.plot?this.plot.view.getCurrentTheme():o.ThemeManager.getDefaultTheme()).palette)||void 0===e?void 0:e.default}setDefaultDataTransform(){return[]}setMultipleData(){return null}setDefaultMarkTransform(){return[]}convertMarkTransform(e,t=[]){if(t&&t.length){if(e&&e.length){let o=[];const r=[];for(let l=0,a=e.length;l<a;l++){const a=e[l],s=t.findIndex((e=>e.type===a.type));s>=0?(o.push(i.merge({},t[s],a)),r.push(s)):o.push(a)}for(let e=0,i=t.length;e<i;e++)r.includes(e)||(o=[t[e]].concat(o));return o}return t}return e}convertMarkAnimation(){return this.spec.animation?this.spec.animation:null}convertSimpleMarkEncode(e){if(!e)return{};const t={};return Object.keys(e).map((i=>{t[i]={field:e[i],scale:this.getScaleId(i),band:.5}})),t}getDataIdOfFiltered(){var e,t;return`${null!==(t=null===(e=this.spec.data)||void 0===e?void 0:e.id)&&void 0!==t?t:this.spec.id}-data-filtered`}getDataIdOfMain(){var e,t;return`${null!==(t=null===(e=this.spec.data)||void 0===e?void 0:e.id)&&void 0!==t?t:this.spec.id}-data`}getDataIdOfPlayer(){var e,t;return`${null!==(t=null===(e=this.spec.data)||void 0===e?void 0:e.id)&&void 0!==t?t:this.spec.id}-player`}getDataZoomScaleId(e){return{x:`datazoom-scale-${e}-x`,y:`datazoom-scale-${e}-y`}}getScaleId(e){var t,i,o;return null!==(o=null===(i=null===(t=this.spec.scale)||void 0===t?void 0:t[e])||void 0===i?void 0:i.id)&&void 0!==o?o:`scale-${e}`}getMarkId(){return`${this.spec.id}-mark`}getScaleSpec(e){var t,i,o;return null===(o=null===(i=null===(t=this.viewSpec)||void 0===t?void 0:t.scales)||void 0===i?void 0:i.find)||void 0===o?void 0:o.call(i,(t=>t.id===e))}parseScaleOfEncodeX(e){return{type:"band",id:this.getScaleId("x"),dependency:[o.SIGNAL_VIEW_BOX],domain:{data:this.getDataIdOfFiltered(),field:e},range:this._coordinate?{coordinate:this._coordinate.id,dimension:"x"}:(e,t)=>[0,t.viewBox.width()]}}parseScaleOfEncodeY(e){return{type:"linear",dependency:[o.SIGNAL_VIEW_BOX],id:this.getScaleId("y"),domain:{data:this.getDataIdOfFiltered(),field:e},range:this._coordinate?{coordinate:this._coordinate.id,dimension:"y"}:(e,t)=>[t.viewBox.height(),0]}}parseScaleOfEncodeColor(e){return{type:"ordinal",id:this.getScaleId("color"),domain:{data:this.getDataIdOfMain(),field:e},range:this.getPalette()}}parseScaleOfEncodeStroke(e){return{type:"ordinal",id:this.getScaleId("stroke"),domain:{data:this.getDataIdOfMain(),field:e},range:this.getPalette()}}parseScaleOfEncodeGroup(e){return{type:"ordinal",id:this.getScaleId("group"),domain:{data:this.getDataIdOfMain(),field:e},range:this.getPalette()}}parseScaleOfCommonEncode(e,t){return"x"===e?this.parseScaleOfEncodeX(t):"y"===e?this.parseScaleOfEncodeY(t):"color"===e?this.parseScaleOfEncodeColor(t):"group"===e?this.parseScaleOfEncodeGroup(t):"stroke"===e?this.parseScaleOfEncodeStroke(t):null}setDefaultAxis(){return{}}parseAxisSpec(){const e=this.spec.axis,t=[];return e&&Object.keys(e).forEach((r=>{const{option:l,layout:a}=this.parseOption(e[r]);if(l){const e={type:"component",componentType:o.ComponentEnum.axis,scale:this.getScaleId(r),dependency:[o.SIGNAL_VIEW_BOX],tickCount:l.tickCount,encode:{update:(e,t,o)=>{const a=this._coordinate?{}:"x"===r?{x:0,y:o.viewBox.height(),start:{x:0,y:0},end:{x:o.viewBox.width(),y:0}}:{x:0,y:o.viewBox.height(),start:{x:0,y:0},verticalFactor:-1,end:{x:0,y:-o.viewBox.height()}};return i.isPlainObject(l)?i.merge(a,l):a}}};e.layout=null!=a?a:{position:this._coordinate?"auto":i.isPlainObject(a)&&!i.isNil(a.orient)?a.orient:"x"===r?"bottom":"left"},t.push(e)}})),t}parseOption(e){let t,o;return i.isPlainObject(e)?i.isNil(e.option)?t=e:(t=e.option,o=e.layout):t=e,{option:t,layout:o}}setDefaultLegend(){return{}}parseLegendSpec(){const e=this.spec.legend,t=[];return e&&Object.keys(e).forEach((r=>{var l;const{option:a,layout:s}=this.parseOption(e[r]);if(a){const e=null!=s?s:i.isPlainObject(a)&&!i.isNil(a.layout)?"horizontal"===a.layout?{position:"top",align:"center"}:"vertical"===a.layout?{position:"right",align:"middle"}:{position:"top",align:"center"}:{position:"top",align:"center"},n={type:"component",componentType:o.ComponentEnum.legend,scale:this.getScaleId(r),shapeScale:this.getScaleId("shape"),dependency:[o.SIGNAL_VIEW_BOX],target:{data:this.getDataIdOfFiltered(),filter:null===(l=this.spec.encode)||void 0===l?void 0:l[r]},encode:{update:(t,o,r)=>{var l,s,n,d,c,u,p,h,v,y,f,g,m,k,x,S,M,w,b,P,E,I,O,T;const _="left"===e.position?{layout:"vertical",x:null!==(n=null===(s=null===(l=o.mark)||void 0===l?void 0:l.relativePosition)||void 0===s?void 0:s.left)&&void 0!==n?n:0,y:null!==(u=null===(c=null===(d=o.mark)||void 0===d?void 0:d.relativePosition)||void 0===c?void 0:c.top)&&void 0!==u?u:0}:"right"===e.position?{layout:"vertical",x:null!==(v=null===(h=null===(p=o.mark)||void 0===p?void 0:p.relativePosition)||void 0===h?void 0:h.left)&&void 0!==v?v:r.viewBox.width(),y:null!==(g=null===(f=null===(y=o.mark)||void 0===y?void 0:y.relativePosition)||void 0===f?void 0:f.top)&&void 0!==g?g:0}:"bottom"===e.position?{layout:"horizontal",x:null!==(x=null===(k=null===(m=o.mark)||void 0===m?void 0:m.relativePosition)||void 0===k?void 0:k.left)&&void 0!==x?x:0,y:null!==(w=null===(M=null===(S=o.mark)||void 0===S?void 0:S.relativePosition)||void 0===M?void 0:M.top)&&void 0!==w?w:r.viewBox.height()}:{layout:"horizontal",x:null!==(E=null===(P=null===(b=o.mark)||void 0===b?void 0:b.relativePosition)||void 0===P?void 0:P.left)&&void 0!==E?E:0,y:null!==(T=null===(O=null===(I=o.mark)||void 0===I?void 0:I.relativePosition)||void 0===O?void 0:O.top)&&void 0!==T?T:0};return i.isPlainObject(a)?i.merge({},_,a):_}}};n.layout=e,t.push(n)}})),t}setDefaultCrosshair(){return{}}getVisualChannel(e){var t,i;return"polar"===(null===(t=this._coordinate)||void 0===t?void 0:t.type)?this._coordinate.transpose?"x"===e?"radius":"angle":"x"===e?"angle":"radius":(null===(i=this._coordinate)||void 0===i?void 0:i.transpose)?"x"===e?"y":"x":e}parseCrosshairSpec(){const e=this.setDefaultCrosshair(),t=Object.keys(e),r=this.spec.crosshair?Object.keys(this.spec.crosshair).reduce(((e,t)=>(e.includes(t)||e.push(t),e)),t):t,a=[];return r.length&&r.forEach((t=>{var r,s;const n=null===(r=this.spec.crosshair)||void 0===r?void 0:r[t],d=null!=n?n:e[t];if(d){const e=this.getScaleId(t),r=this.getScaleSpec(e),c={type:"component",componentType:o.ComponentEnum.crosshair,scale:this.getScaleId(t),dependency:[o.SIGNAL_VIEW_BOX],crosshairShape:i.isBoolean(d)?"band"===(null==r?void 0:r.type)?"rect":"line":null!==(s=d.crosshairShape)&&void 0!==s?s:"band"===(null==r?void 0:r.type)?"rect":"line",crosshairType:this.getVisualChannel(t)};if(i.isPlainObject(n)&&(c.encode={update:n},"polygon"===n.type)){c.crosshairType="radius-polygon";const e=this.getScaleId("x"===t?"y":"x");c.dependency.push(e),c.encode.update.sides=(t,i,o)=>{const r=o[e];return r&&l(r.type)?r.domain().length:void 0},c.encode.update.startAngle=(t,i,o)=>{var r,a;const s=o[e];return s&&l(s.type)?s.range()[0]+(null!==(a=null===(r=null==s?void 0:s.bandwidth)||void 0===r?void 0:r.call(s))&&void 0!==a?a:0)/2:void 0},c.encode.update.endAngle=(t,i,o)=>{var r,a;const s=o[e];return s&&l(s.type)?s.range()[1]+(null!==(a=null===(r=null==s?void 0:s.bandwidth)||void 0===r?void 0:r.call(s))&&void 0!==a?a:0)/2:void 0}}a.push(c)}})),a}setDefaultTooltip(){return null}parseTooltipSpec(){var e,r;const l=this.setDefaultTooltip(),a=this.spec.tooltip;if(!1!==a&&null!==a&&null!==l){const s=[],n=i.merge({},l,!0===a?{}:a),d=i.isNil(this.spec.encode.color)?i.isNil(this.spec.encode.group)?"stroke":"group":"color",c=this.spec.encode[d],u=c?[this.getScaleId(d)]:[],p=c?t.field(c):null,h={visible:!!n.title||!!n.staticTitle,key:"title",value:i.isNil(n.staticTitle)?{field:(e,o,r)=>n.title?t.field(n.title)(i.isArray(e)?e[0]:e):void 0}:n.staticTitle};this.spec.encode.shape&&u.push(this.getScaleId("shape"));const v=i.isArray(n.content)&&n.content.length?n.content.map(((e,o)=>({key:e.key?{field:e.key}:i.isNil(n.staticContentKey)?(e,t,i)=>p?p(e):void 0:i.isArray(n.staticContentKey)?n.staticContentKey[o]:n.staticContentKey,value:{field:e.value},symbol:(i,o,r)=>{var l;const a=r[this.getScaleId(d)],s=r[this.getScaleId("shape")];let n="circle";return s&&e.symbol?n=s.scale(t.field(e.symbol)(i)):e.symbol&&(n=t.field(e.symbol)(i)),{fill:a&&p?a.scale(p(i)):null===(l=this.getPalette())||void 0===l?void 0:l[0],symbolType:n}}}))):null;if(!0!==n.disableGraphicTooltip&&s.push({type:"component",componentType:o.ComponentEnum.tooltip,target:this.getMarkId(),dependency:u,title:h,content:v,zIndex:1e3}),!0!==n.disableDimensionTooltip){const t=null!==(e=n.dimensionTooltipChannel)&&void 0!==e?e:"x";s.push({type:"component",componentType:o.ComponentEnum.dimensionTooltip,tooltipType:this.getVisualChannel(t),scale:this.getScaleId(t),dependency:u,target:{data:this.getDataIdOfFiltered(),filter:null===(r=this.spec.encode)||void 0===r?void 0:r[t]},title:h,content:v,avoidMark:n.disableGraphicTooltip?[]:[this.getMarkId()],zIndex:1e3})}return s}return[]}setDefaultSlider(){return{}}parseSliderSpec(){const e=this.spec.slider,l=[];return e&&Object.keys(e).forEach((a=>{var s,n;const{option:d,layout:c}=this.parseOption(e[a]);if(d){const e=this.getScaleId(a),u=this.getScaleSpec(e),p=this.getDataIdOfMain();if(!u||!function(e){switch(e){case r.Linear:case r.Log:case r.Pow:case r.Sqrt:case r.Symlog:case r.Time:return!0;default:return!1}}(u.type))return void this._logger.warn(`[VGrammar]: Don't use slider in a channel which has scale type = ${null==u?void 0:u.type}`);const h=this.plot?this.plot.view.getCurrentTheme():o.ThemeManager.getDefaultTheme(),v=t.field(null===(s=this.spec.encode)||void 0===s?void 0:s[a]),y=null!=c?c:i.isPlainObject(d)&&!i.isNil(d.layout)?"horizontal"===d.layout?{position:"top",align:"center"}:"vertical"===d.layout?{position:"right",align:"middle"}:{position:"top",align:"center"}:{position:"top",align:"center"},f={type:"component",componentType:o.ComponentEnum.slider,dependency:[o.SIGNAL_VIEW_BOX,p],min:(e,t,i)=>{const o=i[p];return Math.min.apply(null,o.map(v))},max:(e,t,i)=>{const o=i[p];return Math.max.apply(null,o.map(v))},target:{data:this.getDataIdOfFiltered(),filter:null===(n=this.spec.encode)||void 0===n?void 0:n[a]},encode:{update:(e,t,o)=>{var r,l,a,s,n,c,u,p,v,f,g,m,k,x,S,M,w,b,P,E,I,O,T,_;const D="left"===y.position?{layout:"vertical",x:null!==(a=null===(l=null===(r=t.mark)||void 0===r?void 0:r.relativePosition)||void 0===l?void 0:l.left)&&void 0!==a?a:0,y:null!==(c=null===(n=null===(s=t.mark)||void 0===s?void 0:s.relativePosition)||void 0===n?void 0:n.top)&&void 0!==c?c:0,railWidth:h.components.slider.railHeight,railHeight:o.viewBox.height()}:"right"===y.position?{layout:"vertical",x:null!==(v=null===(p=null===(u=t.mark)||void 0===u?void 0:u.relativePosition)||void 0===p?void 0:p.left)&&void 0!==v?v:o.viewBox.width(),y:null!==(m=null===(g=null===(f=t.mark)||void 0===f?void 0:f.relativePosition)||void 0===g?void 0:g.top)&&void 0!==m?m:0,railWidth:h.components.slider.railHeight,railHeight:o.viewBox.height()}:"bottom"===y.position?{layout:"horizontal",x:null!==(S=null===(x=null===(k=t.mark)||void 0===k?void 0:k.relativePosition)||void 0===x?void 0:x.left)&&void 0!==S?S:0,y:null!==(b=null===(w=null===(M=t.mark)||void 0===M?void 0:M.relativePosition)||void 0===w?void 0:w.top)&&void 0!==b?b:o.viewBox.height(),railHeight:h.components.slider.railHeight,railWidth:o.viewBox.width()}:{layout:"horizontal",x:null!==(I=null===(E=null===(P=t.mark)||void 0===P?void 0:P.relativePosition)||void 0===E?void 0:E.left)&&void 0!==I?I:0,y:null!==(_=null===(T=null===(O=t.mark)||void 0===O?void 0:O.relativePosition)||void 0===T?void 0:T.top)&&void 0!==_?_:0,railHeight:h.components.slider.railHeight,railWidth:o.viewBox.width()};return i.isPlainObject(d)?i.merge({},D,d):D}}};f.layout=y,l.push(f)}})),l}setDefaultDataZoom(){return{}}getVisiualPositionByDimension(e){return"y"===e?"left":"bottom"}parseDataZoomSpec(){const e=this.spec.datazoom,t=[];return e&&Object.keys(e).forEach((r=>{var l,a,s,n,d;const{option:c,layout:u}=this.parseOption(e[r]);if(c){const e=this.getDataIdOfMain(),p=null!=u?u:i.isPlainObject(c)&&!i.isNil(c.orient)?{position:c.orient}:{position:this.getVisiualPositionByDimension(r)},h={data:e},{x:v,y:y}=this.getDataZoomScaleId(r);"x"===r?(h.x={scale:v,field:null===(l=this.spec.encode)||void 0===l?void 0:l[r]},h.y={scale:y,field:null===(a=this.spec.encode)||void 0===a?void 0:a.y}):h["top"===p.position||"bottom"===p.position?"x":"y"]={scale:v,field:null!==(n=null===(s=this.spec.encode)||void 0===s?void 0:s[r])&&void 0!==n?n:r};const f=this.plot?this.plot.view.getCurrentTheme():o.ThemeManager.getDefaultTheme(),g={type:"component",componentType:o.ComponentEnum.datazoom,dependency:[o.SIGNAL_VIEW_BOX,e],target:{data:this.getDataIdOfFiltered(),filter:null===(d=this.spec.encode)||void 0===d?void 0:d[r]},preview:h,encode:{update:(e,t,o)=>{var r,l,a,s,n,d,u,h,v,y,g,m,k,x,S,M,w,b,P,E,I,O,T,_;const D="left"===p.position?{orient:p.position,x:null!==(a=null===(l=null===(r=t.mark)||void 0===r?void 0:r.relativePosition)||void 0===l?void 0:l.left)&&void 0!==a?a:0,y:null!==(d=null===(n=null===(s=t.mark)||void 0===s?void 0:s.relativePosition)||void 0===n?void 0:n.top)&&void 0!==d?d:0,size:{height:o.viewBox.height(),width:f.components.datazoom.size.height}}:"right"===p.position?{orient:p.position,x:null!==(v=null===(h=null===(u=t.mark)||void 0===u?void 0:u.relativePosition)||void 0===h?void 0:h.left)&&void 0!==v?v:o.viewBox.width(),y:null!==(m=null===(g=null===(y=t.mark)||void 0===y?void 0:y.relativePosition)||void 0===g?void 0:g.top)&&void 0!==m?m:0,size:{height:o.viewBox.height(),width:f.components.datazoom.size.height}}:"bottom"===p.position?{orient:p.position,x:null!==(S=null===(x=null===(k=t.mark)||void 0===k?void 0:k.relativePosition)||void 0===x?void 0:x.left)&&void 0!==S?S:0,y:null!==(b=null===(w=null===(M=t.mark)||void 0===M?void 0:M.relativePosition)||void 0===w?void 0:w.top)&&void 0!==b?b:o.viewBox.height(),size:{width:o.viewBox.width(),height:f.components.datazoom.size.height}}:{orient:p.position,x:null!==(I=null===(E=null===(P=t.mark)||void 0===P?void 0:P.relativePosition)||void 0===E?void 0:E.left)&&void 0!==I?I:0,y:null!==(_=null===(T=null===(O=t.mark)||void 0===O?void 0:O.relativePosition)||void 0===T?void 0:T.top)&&void 0!==_?_:0,size:{width:o.viewBox.width(),height:f.components.datazoom.size.height}};return i.isPlainObject(c)?i.merge({},D,c):D}}};g.layout=p,t.push(g)}})),t}setDefaultLabel(){return{}}getLabelPosition(){var e,t;return"polar"===(null===(e=this._coordinate)||void 0===e?void 0:e.type)?this._coordinate.transpose?"endAngle":"outer":(null===(t=this._coordinate)||void 0===t?void 0:t.transpose)?"right":"top"}setLabelTextGetter(e,t){return{field:e}}parseLabelSpec(){const e=this.spec.label,t=[];return e&&Object.keys(e).forEach((r=>{const l=e[r];if(l){const e={type:"component",componentType:o.ComponentEnum.label,target:this.getMarkId(),layout:{position:"content",skipBeforeLayouted:!0},labelStyle:i.isPlainObject(l)?i.merge({position:this.getLabelPosition()},l):{position:this.getLabelPosition()},encode:{update:{text:this.spec.encode[r]?{field:this.spec.encode[r]}:this.setLabelTextGetter(r,l)}}};t.push(e)}})),t}setDefaultPlayer(){return{}}parsePlayerSpec(){var e;const t=this.spec.player,r=[];if(t){const l=null==t?void 0:t.option,a=null==t?void 0:t.layout;if(l){const t=null!=a?a:i.isPlainObject(l)&&!i.isNil(l.orient)?{position:l.orient}:{position:"bottom"},s={type:"component",componentType:o.ComponentEnum.player,dependency:[o.SIGNAL_VIEW_BOX],target:{data:this.getDataIdOfMain(),source:this.getDataIdOfPlayer()},playerType:i.isPlainObject(l)&&null!==(e=l.type)&&void 0!==e?e:"auto",encode:{update:(e,o,r)=>{var a,s,n,d,c,u,p,h,v,y,f,g,m,k,x,S,M,w,b,P,E,I,O,T;const _="left"===t.position?{x:null!==(n=null===(s=null===(a=o.mark)||void 0===a?void 0:a.relativePosition)||void 0===s?void 0:s.left)&&void 0!==n?n:0,y:null!==(u=null===(c=null===(d=o.mark)||void 0===d?void 0:d.relativePosition)||void 0===c?void 0:c.top)&&void 0!==u?u:0,size:{height:r.viewBox.height(),width:20}}:"right"===t.position?{x:null!==(v=null===(h=null===(p=o.mark)||void 0===p?void 0:p.relativePosition)||void 0===h?void 0:h.left)&&void 0!==v?v:r.viewBox.width(),y:null!==(g=null===(f=null===(y=o.mark)||void 0===y?void 0:y.relativePosition)||void 0===f?void 0:f.top)&&void 0!==g?g:0,size:{height:r.viewBox.height(),width:20}}:"bottom"===t.position?{x:null!==(x=null===(k=null===(m=o.mark)||void 0===m?void 0:m.relativePosition)||void 0===k?void 0:k.left)&&void 0!==x?x:0,y:null!==(w=null===(M=null===(S=o.mark)||void 0===S?void 0:S.relativePosition)||void 0===M?void 0:M.top)&&void 0!==w?w:r.viewBox.height(),size:{width:r.viewBox.width(),height:20}}:{x:null!==(E=null===(P=null===(b=o.mark)||void 0===b?void 0:b.relativePosition)||void 0===P?void 0:P.left)&&void 0!==E?E:0,y:null!==(T=null===(O=null===(I=o.mark)||void 0===I?void 0:I.relativePosition)||void 0===O?void 0:O.top)&&void 0!==T?T:0,size:{width:r.viewBox.width(),height:20}};return i.isPlainObject(l)?i.merge({},_,l):_}}};s.layout=t,r.push(s)}}return r}parseDataSpec(){var e;const{data:t,player:i}=this.spec,o=[];if(null==i?void 0:i.data)o.push({id:this.getDataIdOfPlayer(),values:i.data}),o.push({id:this.getDataIdOfMain(),values:null===(e=i.data)||void 0===e?void 0:e[0]}),o.push({id:this.getDataIdOfFiltered(),source:this.getDataIdOfMain()});else if(t){const e=this.getDataIdOfMain(),i=t.transform,r=this.convertMarkTransform(i,this.setDefaultDataTransform());o.push({id:e,values:t.values,transform:r}),o.push({id:this.getDataIdOfFiltered(),source:e})}const r=this.setMultipleData();return r&&r.forEach((e=>{e.id&&(e.id===this.getDataIdOfFiltered()&&o.length?o[o.length-1].transform=e.transform:o.push(e))})),o}parseScaleSpec(){const{encode:e,scale:t,datazoom:r}=this.spec,l={};return e&&Object.keys(e).forEach((t=>{var i;const o=e[t],r=this.getScaleId(t),a=null===(i=this.spec.scale)||void 0===i?void 0:i[t];l[r]=a?Object.assign({id:r},this.parseScaleByEncode(t,o),a,{userScale:a}):Object.assign({id:r},this.parseScaleByEncode(t,o))})),t&&Object.keys(t).forEach((e=>{const i=this.getScaleId(e);l[i]||(l[i]=t[e],l[i].userScale=t[e])})),r&&Object.keys(r).forEach((t=>{var a,s,n,d;const c=this.getScaleId(t),{x:u,y:p}=this.getDataZoomScaleId(t);if("x"===t&&e[t]){if(l[u]={type:l[c].type,id:u,domain:{data:this.getDataIdOfMain(),field:e[t]},dependency:[o.SIGNAL_VIEW_BOX],range:(e,t)=>[0,t.viewBox.width()]},e.y){const n=this.plot?this.plot.view.getCurrentTheme():o.ThemeManager.getDefaultTheme();l[p]={type:null!==(s=null===(a=l[this.getScaleId("y")])||void 0===a?void 0:a.type)&&void 0!==s?s:"linear",id:p,domain:{data:this.getDataIdOfMain(),field:null==e?void 0:e.y},range:(e,o)=>{var l,a;const s=this.parseOption(r[t]).option;return[0,i.isPlainObject(s)&&null!==(a=null===(l=s.size)||void 0===l?void 0:l.height)&&void 0!==a?a:n.components.datazoom.size.height]}}}}else l[u]={type:null!==(n=l[c].type)&&void 0!==n?n:"band",id:u,domain:{data:this.getDataIdOfMain(),field:null!==(d=null==e?void 0:e[t])&&void 0!==d?d:t}}})),Array.from(Object.values(l))}parseCoordinateSpec(){var e;if(!this._coordinate)return[];const i={type:null!==(e=this._coordinate.type)&&void 0!==e?e:"cartesian",transpose:this._coordinate.transpose,id:this._coordinate.id,dependency:[o.SIGNAL_VIEW_BOX],start:[0,0],end:(e,t)=>[t.viewBox.width(),t.viewBox.height()]};return"polar"===this._coordinate.type&&this._coordinate.origin&&(i.origin=(e,i)=>[t.toPercent(this._coordinate.origin[0],i.viewBox.width()),t.toPercent(this._coordinate.origin[1],i.viewBox.height())]),[i]}setMainMarkEnterEncode(){return this.spec.style}setMainMarkSpec(){return{}}setMultiMarksSpec(){return null}toViewSpec(){var e,t;this.viewSpec={};const i=this.getDataIdOfFiltered();this.viewSpec.data=this.parseDataSpec(),this.viewSpec.scales=this.parseScaleSpec(),this.viewSpec.coordinates=this.parseCoordinateSpec();let r=[];r=r.concat(this.parseLegendSpec()),r=r.concat(this.parseAxisSpec()),r=r.concat(this.parseCrosshairSpec()),r=r.concat(this.parseSliderSpec()),r=r.concat(this.parseDataZoomSpec()),r=r.concat(this.parsePlayerSpec()),r.push(Object.assign({id:this.getMarkId(),type:this.setMarkType(),coordinate:null===(e=this._coordinate)||void 0===e?void 0:e.id,from:{data:i},groupBy:null===(t=this.spec.encode)||void 0===t?void 0:t.group,layout:{position:"content",skipBeforeLayouted:!0},dependency:this.viewSpec.scales.map((e=>e.id)).concat(o.SIGNAL_VIEW_BOX),transform:this.convertMarkTransform(this.spec.transform,this.setDefaultMarkTransform()),animation:this.convertMarkAnimation(),encode:Object.assign({},this.spec.state,{enter:this.setMainMarkEnterEncode(),update:this.convertMarkEncode(this.spec.encode)})},this.setMainMarkSpec()));const l=this.setMultiMarksSpec();return l&&(r=r.concat(l)),r=r.concat(this.parseLabelSpec()),r=r.concat(this.parseTooltipSpec()),this.viewSpec.marks=r,this.viewSpec}clear(){this.spec={id:this.spec.id}}}var n;!function(e){e.area="area",e.cell="cell",e.image="image",e.interval="interval",e.line="line",e.path="path",e.polygon="polygon",e.rectX="rectX",e.rectY="rectY",e.rect="rect",e.ruleX="ruleX",e.ruleY="ruleY",e.rule="rule",e.symbol="symbol",e.text="text",e.tree="tree",e.circlePacking="circlePacking",e.sunburst="sunburst",e.treemap="treemap",e.sankey="sankey",e.wordcloud="wordcloud",e.wordcloudShape="wordcloudShape"}(n||(n={}));class d extends s{constructor(e){super(n.interval,e)}setMarkType(){var e;return"polar"===(null===(e=this._coordinate)||void 0===e?void 0:e.type)?o.GrammarMarkType.arc:o.GrammarMarkType.rect}parseScaleByEncode(e,t){return this.parseScaleOfCommonEncode(e,t)}setDefaultMarkTransform(){var e,t,i,o;return[{type:"dodge",minWidth:null===(e=this.spec.style)||void 0===e?void 0:e.minWidth,maxWidth:null===(t=this.spec.style)||void 0===t?void 0:t.maxWidth,innerGap:null===(i=this.spec.style)||void 0===i?void 0:i.innerGap,categoryGap:null===(o=this.spec.style)||void 0===o?void 0:o.categoryGap}]}setDefaultCrosshair(){return{x:{crosshairShape:"rect"}}}setDefaultTooltip(){var e;const t=null===(e=this.spec.encode)||void 0===e?void 0:e.y;return{content:i.isArray(t)?t.map((e=>({value:e}))):[{value:t}]}}setMainMarkSpec(){var e;return"polar"===(null===(e=this._coordinate)||void 0===e?void 0:e.type)?{attributeTransforms:[{channels:["x","y","x1","y1","cx","cy"],transform:(e,t,i)=>{e.x=i.cx,e.y=i.cy,this._coordinate.transpose?(e.startAngle=i.y,e.endAngle=i.y1,e.innerRadius=i.x,e.outerRadius=i.x1):(e.startAngle=i.x,e.endAngle=i.x1,e.innerRadius=i.y,e.outerRadius=i.y1)},storedAttrs:"sizeAttrs"}]}:{}}convertMarkEncode(e){var o,r,l,a,s,n;const d=this.convertSimpleMarkEncode(e),c=this.getScaleId("x"),u=this.getScaleId("y"),p=t.field(d.x.field),h={x:(e,t,i)=>{const o=i[c],r=o.bandwidth();return o.scale(p(e))+r/4},x1:(e,t,i)=>{const o=i[c],r=o.bandwidth();return o.scale(p(e))+3*r/4}};if(i.isArray(null===(o=d.y)||void 0===o?void 0:o.field))h.y={field:d.y.field[0],scale:d.y.scale},h.y1={field:d.y.field[1],scale:d.y.scale};else{const e=t.field(d.y.field);h.y=(t,o,r)=>{const l=e(t),a=r[u];return i.isArray(l)?a.scale(l[0]):a.scale(l)},h.y1=(t,o,r)=>{const l=r[u],a=e(t);if(i.isArray(a)&&a.length>1)return l.scale(a[1]);const s=l.domain(),n=Math.min.apply(null,s),d=Math.max.apply(null,s),c=n>0?n:d<0?d:0;return l.scale(c)}}return d.stroke&&(h.stroke=d.stroke),d.color||d.group?h.fill=null!==(r=d.color)&&void 0!==r?r:d.group:h.fill=null!==(a=null===(l=this.spec.style)||void 0===l?void 0:l.fill)&&void 0!==a?a:null===(s=this.getPalette())||void 0===s?void 0:s[0],"polar"===(null===(n=this._coordinate)||void 0===n?void 0:n.type)&&(h.cx=(e,t,i)=>i[this._coordinate.id].origin().x,h.cy=(e,t,i)=>i[this._coordinate.id].origin().y),h}}d.type=n.interval;class c extends s{constructor(e){super(n.line,e)}setMarkType(){return o.GrammarMarkType.line}parseScaleOfEncodeX(e){const t=super.parseScaleOfEncodeX(e);return t.type="point",t}parseScaleByEncode(e,t){return this.parseScaleOfCommonEncode(e,t)}setDefaultCrosshair(){return{x:{crosshairShape:"line"}}}setDefaultTooltip(){var e,t;return{disableGraphicTooltip:!0,title:null===(e=this.spec.encode)||void 0===e?void 0:e.x,content:[{value:null===(t=this.spec.encode)||void 0===t?void 0:t.y}]}}convertMarkEncode(e){var t,i,o,r;const l=this.convertSimpleMarkEncode(e),a={y:l.y,x:l.x};return l.color||l.group?a.stroke=null!==(t=l.color)&&void 0!==t?t:l.group:a.stroke=null!==(o=null===(i=this.spec.style)||void 0===i?void 0:i.stroke)&&void 0!==o?o:null===(r=this.getPalette())||void 0===r?void 0:r[0],a}}c.type=n.line;class u extends s{constructor(e){super(n.cell,e)}setMarkType(){return o.GrammarMarkType.cell}parseScaleOfEncodeX(e){const t=super.parseScaleOfEncodeX(e);return t.type="point",t}parseScaleByEncode(e,t){return this.parseScaleOfCommonEncode(e,t)}setDefaultCrosshair(){return{x:{crosshairShape:"line"}}}setDefaultTooltip(){var e,t;return{title:null===(e=this.spec.encode)||void 0===e?void 0:e.x,content:[{value:null===(t=this.spec.encode)||void 0===t?void 0:t.y}]}}convertMarkEncode(e){var t,i,o,r;const l=this.convertSimpleMarkEncode(e),a={y:l.y,x:l.x};return l.stroke&&(a.stroke=l.stroke),l.color||l.group?a.fill=null!==(t=l.color)&&void 0!==t?t:l.group:a.fill=null!==(o=null===(i=this.spec.style)||void 0===i?void 0:i.fill)&&void 0!==o?o:null===(r=this.getPalette())||void 0===r?void 0:r[0],a}}u.type=n.cell;class p extends s{constructor(e){super(n.ruleX,e)}setMarkType(){return o.GrammarMarkType.rule}parseScaleOfEncodeX(e){const t=super.parseScaleOfEncodeX(e);return t.type="point",t}parseScaleByEncode(e,t){return this.parseScaleOfCommonEncode(e,t)}convertMarkEncode(e){var t,i,o,r;const l=this.convertSimpleMarkEncode(e),a={x:l.x,x1:l.x,y:(e,t,i)=>0,y1:(e,t,i)=>i.viewBox.height()};return l.color||l.group?a.stroke=null!==(t=l.color)&&void 0!==t?t:l.group:a.stroke=null!==(o=null===(i=this.spec.style)||void 0===i?void 0:i.stroke)&&void 0!==o?o:null===(r=this.getPalette())||void 0===r?void 0:r[0],a}}p.type=n.ruleX;class h extends s{constructor(e){super(n.ruleY,e)}setMarkType(){return o.GrammarMarkType.rule}parseScaleOfEncodeX(e){const t=super.parseScaleOfEncodeX(e);return t.type="point",t}parseScaleByEncode(e,t){return this.parseScaleOfCommonEncode(e,t)}convertMarkEncode(e){var t,o,r,l,a,s;const n=this.convertSimpleMarkEncode(e),d={y:n.y,y1:n.y,x:i.isArray(null===(t=n.x)||void 0===t?void 0:t.field)?{field:n.x.field[0],scale:n.x.scale}:(e,t,i)=>0,x1:i.isArray(null===(o=n.x)||void 0===o?void 0:o.field)?{field:n.x.field[1],scale:n.x.scale}:(e,t,i)=>i.viewBox.width()};return n.color||n.group?d.stroke=null!==(r=n.color)&&void 0!==r?r:n.group:d.stroke=null!==(a=null===(l=this.spec.style)||void 0===l?void 0:l.stroke)&&void 0!==a?a:null===(s=this.getPalette())||void 0===s?void 0:s[0],d}}h.type=n.ruleY;class v extends s{constructor(e){super(n.area,e)}setMarkType(){return o.GrammarMarkType.area}parseScaleOfEncodeX(e){const t=super.parseScaleOfEncodeX(e);return t.type="point",t}parseScaleByEncode(e,t){return this.parseScaleOfCommonEncode(e,t)}setDefaultCrosshair(){return{x:{crosshairShape:"line"}}}setDefaultTooltip(){var e,t;const o=null===(e=this.spec.encode)||void 0===e?void 0:e.x,r=null===(t=this.spec.encode)||void 0===t?void 0:t.y;return{disableGraphicTooltip:!0,title:i.isArray(o)?o[0]:o,content:i.isArray(r)?r.map((e=>({value:e}))):[{value:r}]}}convertMarkEncode(e){var t,o,r,l,a,s;const n=this.convertSimpleMarkEncode(e);let d;if(i.isArray(null===(t=n.x)||void 0===t?void 0:t.field))d={y:n.y,x:{field:n.x.field[0],scale:n.x.scale},x1:{field:n.x.field[1],scale:n.x.scale}};else if(i.isArray(null===(o=n.y)||void 0===o?void 0:o.field))d={y:{field:n.y.field[0],scale:n.y.scale},y1:{field:n.y.field[1],scale:n.y.scale},x:n.x};else{const e=this.getScaleId("y");d={x:n.x,y:n.y,y1:(t,i,o)=>{const r=o[e],l=r.domain(),a=Math.min.apply(null,l),s=Math.max.apply(null,l),n=a>0?a:s<0?s:0;return r.scale(n)}}}return n.stroke&&(d.stroke=n.stroke),n.color||n.group?d.fill=null!==(r=n.color)&&void 0!==r?r:n.group:d.fill=null!==(a=null===(l=this.spec.style)||void 0===l?void 0:l.fill)&&void 0!==a?a:null===(s=this.getPalette())||void 0===s?void 0:s[0],d}}function y(e,t,i,o){return new(i||(i=Promise))((function(r,l){function a(e){try{n(o.next(e))}catch(e){l(e)}}function s(e){try{n(o.throw(e))}catch(e){l(e)}}function n(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,s)}n((o=o.apply(e,t||[])).next())}))}v.type=n.area,"function"==typeof SuppressedError&&SuppressedError;const f=(e,t)=>e.reduce(((e,t)=>(t.id&&!e.some((e=>e.id===t.id))&&e.push(t),e)),t);class g{static useMarks(e){e.forEach((e=>{o.Factory.registerPlotMarks(e.type,e)}))}constructor(e){this.view=new o.View(e),this._semanticMarks=[],this._logger=i.Logger.getInstance()}theme(e){return this._theme=e,this.view.parseSpec({theme:e}),this}_mergeScales(e,t){return e.reduce(((e,t)=>{if(t.id){const o=e.findIndex((e=>e.id===t.id));if(o>=0){const r=e[o];if(t.domain.data&&t.domain.field)if(r.domain.data&&r.domain.field)t.domain.data===r.domain.data&&t.domain.field!==r.domain.field?r.domain.field=[].concat(r.domain.field).concat(t.domain.field):t.domain.data!==r.domain.data&&(r.domain={datas:[{data:r.domain.data,field:r.domain.field},{data:t.domain.data,field:t.domain.field}],sort:r.domain.sort}),i.isNil(t.domain.sort)||(r.domain.sort=t.domain.sort);else if(r.domain.datas){const e=r.domain.datas.find((e=>e.data===t.domain.data));e&&t.domain.field!==e.field?e.field=[].concat(e.field).concat(t.domain.field):e||r.domain.datas.push({data:t.domain.data,field:t.domain.field}),i.isNil(t.domain.sort)||(r.domain.sort=t.domain.sort)}t.userScale&&(e[o]=i.merge(r,t.userScale))}else t.userScale=null,e.push(t)}return e}),t)}parseViewSpec(){const e={theme:this._theme,data:[],marks:[],scales:[],coordinates:[],signals:[],projections:[],events:[]};return this._semanticMarks.forEach((t=>{this._coordinate&&t.coordinate(this._coordinate);const{data:i,marks:o,scales:r,coordinates:l,signals:a,projections:s,events:n}=t.toViewSpec();i&&i.length&&(e.data=f(i,e.data)),o&&o.length&&(e.marks=e.marks.concat(o)),r&&r.length&&(e.scales=this._mergeScales(r,e.scales)),l&&l.length&&(e.coordinates=f(l,e.coordinates)),a&&a.length&&(e.signals=e.signals.concat(a)),s&&s.length&&(e.projections=e.projections.concat(s)),n&&n.length&&(e.events=e.events.concat(n))})),e.marks=[{type:"group",layout:{display:"relative",updateViewSignals:!0},dependency:[o.SIGNAL_VIEW_BOX],encode:{update:(e,t,i)=>({x:i.viewBox.x1,y:i.viewBox.y1,width:i.viewBox.width(),height:i.viewBox.height()})},marks:e.marks}],e}run(e){return this.view&&(this._hasInited?this.view.updateSpec(this.parseViewSpec()):this.view.parseSpec(this.parseViewSpec()),this._hasInited=!0,this.view.runSync(e)),this}runAsync(e){return y(this,void 0,void 0,(function*(){return this.view&&(this._hasInited?this.view.updateSpec(this.parseViewSpec()):this.view.parseSpec(this.parseViewSpec()),this._hasInited=!0,yield this.view.runAsync(e)),this}))}release(){return this.view&&this.view.release(),this}updateSpec(e){return this.parseSpec(e,!0),this}parseSpec(e,t){var i;e.coordinate&&this.coordinate(e.coordinate.type,e.coordinate),(null===(i=null==e?void 0:e.marks)||void 0===i?void 0:i.length)&&e.marks.forEach((e=>{const t=o.Factory.createPlotMark(e.type);t.parseSpec(e),this._semanticMarks.push(t)}));const r=this.parseViewSpec();return r.width=e.width,r.height=e.height,r.background=e.background,r.padding=e.padding,t?this.view.updateSpec(r):this.view.parseSpec(r),this._hasInited=!0,this}getImageBuffer(){var e,t;return null===(t=null===(e=this.view)||void 0===e?void 0:e.getImageBuffer)||void 0===t?void 0:t.call(e)}on(e,t){return this.view&&this.view.addEventListener(e,t),this}off(e,t){return this.view&&this.view.removeEventListener(e,t),this}getCoordinateId(e="0"){return`coordinate-${e}`}coordinate(e,t){return this._coordinate=Object.assign({type:e,id:this.getCoordinateId()},t),this}interval(){const e=o.Factory.createPlotMark(n.interval);return e?this._semanticMarks.push(e):this._logger.error(`Please register ${n.interval} before use it`),e}line(){const e=o.Factory.createPlotMark(n.line);return e?this._semanticMarks.push(e):this._logger.error(`Please register ${n.line} before use it`),e}area(){const e=o.Factory.createPlotMark(n.area);return e?this._semanticMarks.push(e):this._logger.error(`Please register ${n.area} before use it`),e}cell(){const e=o.Factory.createPlotMark(n.cell);return e?this._semanticMarks.push(e):this._logger.error(`Please register ${n.cell} before use it`),e}ruleX(){const e=o.Factory.createPlotMark(n.ruleX);return e?this._semanticMarks.push(e):this._logger.error(`Please register ${this.ruleX} before use it`),e}ruleY(){const e=o.Factory.createPlotMark(n.ruleY);return e?this._semanticMarks.push(e):this._logger.error(`Please register ${n.ruleY} before use it`),e}image(){const e=o.Factory.createPlotMark(n.image);return e?this._semanticMarks.push(e):this._logger.error(`Please register ${n.image} before use it`),e}path(){const e=o.Factory.createPlotMark(n.path);return e?this._semanticMarks.push(e):this._logger.error(`Please register ${n.path} before use it`),e}polygon(){const e=o.Factory.createPlotMark(n.polygon);return e?this._semanticMarks.push(e):this._logger.error(`Please register ${n.polygon} before use it`),e}rectX(){const e=o.Factory.createPlotMark(n.rectX);return e?this._semanticMarks.push(e):this._logger.error(`Please register ${n.rectX} before use it`),e}rectY(){const e=o.Factory.createPlotMark(n.rectY);return e?this._semanticMarks.push(e):this._logger.error(`Please register ${n.rectY} before use it`),e}rect(){const e=o.Factory.createPlotMark(n.rect);return e?this._semanticMarks.push(e):this._logger.error(`Please register ${n.rect} before use it`),e}rule(){const e=o.Factory.createPlotMark(n.rule);return e?this._semanticMarks.push(e):this._logger.error(`Please register ${n.rule} before use it`),e}symbol(){const e=o.Factory.createPlotMark(n.symbol);return e?this._semanticMarks.push(e):this._logger.error(`Please register ${n.symbol} before use it`),e}text(){const e=o.Factory.createPlotMark(n.text);return e?this._semanticMarks.push(e):this._logger.error(`Please register ${n.text} before use it`),e}sankey(){const e=o.Factory.createPlotMark(n.sankey);return e?this._semanticMarks.push(e):this._logger.error(`Please register ${n.sankey} before use it`),e}sunburst(){const e=o.Factory.createPlotMark(n.sunburst);return e?this._semanticMarks.push(e):this._logger.error(`Please register ${n.sunburst} before use it`),e}tree(){const e=o.Factory.createPlotMark(n.tree);return e?this._semanticMarks.push(e):this._logger.error(`Please register ${n.tree} before use it`),e}treemap(){const e=o.Factory.createPlotMark(n.treemap);return e?this._semanticMarks.push(e):this._logger.error(`Please register ${n.treemap} before use it`),e}circlePacking(){const e=o.Factory.createPlotMark(n.circlePacking);return e?this._semanticMarks.push(e):this._logger.error(`Please register ${n.circlePacking} before use it`),e}wordcloud(){const e=o.Factory.createPlotMark(n.wordcloud);return e?this._semanticMarks.push(e):this._logger.error(`Please register ${n.wordcloud} before use it`),e}wordcloudShape(){const e=o.Factory.createPlotMark(n.wordcloudShape);return e?this._semanticMarks.push(e):this._logger.error(`Please register ${n.wordcloudShape} before use it`),e}}class m extends s{constructor(e){super(n.image,e)}setMarkType(){return o.GrammarMarkType.image}parseScaleOfEncodeX(e){const t=super.parseScaleOfEncodeX(e);return t.type="point",t}parseScaleByEncode(e,t){return"src"===e?{type:"ordinal",id:this.getScaleId("src"),domain:{data:this.getDataIdOfMain(),field:t}}:this.parseScaleOfCommonEncode(e,t)}convertMarkEncode(e){var o,r,l,a,s,n,d,c,u,p;const h=this.convertSimpleMarkEncode(e),v=this.getScaleId("x"),y=this.getScaleId("y"),f={image:h.src};if(h.src&&(f.image=h.src),i.isArray(null===(o=h.x)||void 0===o?void 0:o.field)){const e=t.field(h.x.field[0]),i=t.field(h.x.field[1]);f.x=(t,o,r)=>{const l=r[v];return Math.min(l.scale(e(t)),l.scale(i(t)))},f.width=(t,o,r)=>{const l=r[v];return Math.abs(l.scale(e(t))-l.scale(i(t)))}}else{const e=null!==(l=null===(r=this.spec.style)||void 0===r?void 0:r.width)&&void 0!==l?l:m.defaultSpec.width,i=t.field(h.x.field);f.x=(t,o,r)=>r[v].scale(i(t))-e/2,f.width=e}if(i.isArray(null===(a=h.y)||void 0===a?void 0:a.field)){const e=t.field(h.y.field[0]),i=t.field(h.y.field[1]);f.y=(t,o,r)=>{const l=r[y];return Math.min(l.scale(e(t)),l.scale(i(t)))},f.height=(t,o,r)=>{const l=r[y];return Math.abs(l.scale(e(t))-l.scale(i(t)))}}else{const e=null!==(n=null===(s=this.spec.style)||void 0===s?void 0:s.height)&&void 0!==n?n:m.defaultSpec.height,i=t.field(h.y.field);f.y=(t,o,r)=>r[v].scale(i(t))-e/2,f.height=e}return h.stroke&&(f.stroke=h.stroke),h.color||h.group?f.fill=null!==(d=h.color)&&void 0!==d?d:h.group:f.fill=null!==(u=null===(c=this.spec.style)||void 0===c?void 0:c.fill)&&void 0!==u?u:null===(p=this.getPalette())||void 0===p?void 0:p[0],f}}m.type=n.image,m.defaultSpec={width:10,height:10};class k extends s{constructor(e){super(n.path,e)}setMarkType(){return o.GrammarMarkType.path}parseScaleByEncode(e,t){return null}convertMarkEncode(e){var t,i,o,r;const l=this.convertSimpleMarkEncode(e);return l.stroke&&l.stroke,null!==(o=null!==(t=l.color)&&void 0!==t?t:null===(i=this.spec.style)||void 0===i?void 0:i.fill)&&void 0!==o||null===(r=this.getPalette())||void 0===r||r[0],null}}k.type=n.path;class x extends s{constructor(e){super(n.polygon,e)}setMarkType(){return o.GrammarMarkType.polygon}parseScaleOfEncodeX(e){const t=super.parseScaleOfEncodeX(e);return t.type="point",t}parseScaleByEncode(e,t){return this.parseScaleOfCommonEncode(e,t)}convertMarkEncode(e){var i,o,r,l,a,s,n,d;const c=this.convertSimpleMarkEncode(e),u=this.getScaleId("x"),p=this.getScaleId("y"),h={};if((null===(o=null===(i=c.x)||void 0===i?void 0:i.field)||void 0===o?void 0:o.length)&&(null===(l=null===(r=c.y)||void 0===r?void 0:r.field)||void 0===l?void 0:l.length)){const e=c.x.field.map((e=>t.field(e))),i=c.y.field.map((e=>t.field(e)));h.points=(t,o,r)=>{const l=r[u],a=r[p],s=Math.min(e.length,i.length),n=[];for(let o=0;o<s;o++)n.push({x:l.scale(e[o](t)),y:a.scale(i[o](t))});return n}}return c.stroke&&(h.stroke=c.stroke),c.color||c.group?h.fill=null!==(a=c.color)&&void 0!==a?a:c.group:h.fill=null!==(n=null===(s=this.spec.style)||void 0===s?void 0:s.fill)&&void 0!==n?n:null===(d=this.getPalette())||void 0===d?void 0:d[0],h}}x.type=n.polygon;class S extends s{constructor(e){super(n.rectX,e)}setMarkType(){return o.GrammarMarkType.rect}parseScaleByEncode(e,t){return this.parseScaleOfCommonEncode(e,t)}setDefaultCrosshair(){return{x:{crosshairShape:"rect"}}}setDefaultTooltip(){var e;const t=null===(e=this.spec.encode)||void 0===e?void 0:e.x;return{content:i.isArray(t)?t.map((e=>({value:e}))):[{value:t}]}}convertMarkEncode(e){var o,r,l,a,s;const n=this.convertSimpleMarkEncode(e),d=this.getScaleId("x"),c={y:(e,t,i)=>0,y1:(e,t,i)=>i.viewBox.height()};if(i.isArray(null===(o=n.x)||void 0===o?void 0:o.field))c.x={field:n.x.field[0],scale:n.x.scale},c.x1={field:n.x.field[1],scale:n.x.scale};else{const e=t.field(n.x.field);c.x=(t,o,r)=>{const l=e(t),a=r[d];return i.isArray(l)?a.scale(l[0]):a.scale(l)},c.x1=(t,o,r)=>{const l=r[d],a=e(t);if(i.isArray(a)&&a.length>1)return l.scale(a[1]);const s=l.domain(),n=Math.min.apply(null,s),c=Math.max.apply(null,s),u=n>0?n:c<0?c:0;return l.scale(u)}}return n.stroke&&(c.stroke=n.stroke),n.color||n.group?c.fill=null!==(r=n.color)&&void 0!==r?r:n.group:c.fill=null!==(a=null===(l=this.spec.style)||void 0===l?void 0:l.fill)&&void 0!==a?a:null===(s=this.getPalette())||void 0===s?void 0:s[0],c}}S.type=n.rectX;class M extends s{constructor(e){super(n.rectY,e)}setMarkType(){return o.GrammarMarkType.rect}parseScaleByEncode(e,t){return this.parseScaleOfCommonEncode(e,t)}setDefaultCrosshair(){return{x:{crosshairShape:"rect"}}}setDefaultTooltip(){var e;const t=null===(e=this.spec.encode)||void 0===e?void 0:e.y;return{content:i.isArray(t)?t.map((e=>({value:e}))):[{value:t}]}}convertMarkEncode(e){var o,r,l,a,s;const n=this.convertSimpleMarkEncode(e),d=this.getScaleId("y"),c={x:(e,t,i)=>0,x1:(e,t,i)=>i.viewBox.width()};if(i.isArray(null===(o=n.y)||void 0===o?void 0:o.field))c.y={field:n.y.field[0],scale:n.y.scale},c.y1={field:n.y.field[1],scale:n.y.scale};else{const e=t.field(n.y.field);c.y=(t,o,r)=>{const l=e(t),a=r[d];return i.isArray(l)?a.scale(l[0]):a.scale(l)},c.y1=(t,o,r)=>{const l=r[d],a=e(t);if(i.isArray(a)&&a.length>1)return l.scale(a[1]);const s=l.domain(),n=Math.min.apply(null,s),c=Math.max.apply(null,s),u=n>0?n:c<0?c:0;return l.scale(u)}}return n.stroke&&(c.stroke=n.stroke),n.color||n.group?c.fill=null!==(r=n.color)&&void 0!==r?r:n.group:c.fill=null!==(a=null===(l=this.spec.style)||void 0===l?void 0:l.fill)&&void 0!==a?a:null===(s=this.getPalette())||void 0===s?void 0:s[0],c}}M.type=n.rectY;class w extends s{constructor(e){super(n.rect,e)}setMarkType(){return o.GrammarMarkType.rect}parseScaleByEncode(e,t){return this.parseScaleOfCommonEncode(e,t)}setDefaultCrosshair(){return{x:{crosshairShape:"rect"}}}setDefaultTooltip(){var e;const t=null===(e=this.spec.encode)||void 0===e?void 0:e.y;return{content:i.isArray(t)?t.map((e=>({value:e}))):[{value:t}]}}convertMarkEncode(e){var o,r,l,a,s,n;const d=this.convertSimpleMarkEncode(e),c=this.getScaleId("x"),u=this.getScaleId("y"),p={};if(i.isArray(null===(o=d.x)||void 0===o?void 0:o.field))p.x={field:d.x.field[0],scale:d.x.scale},p.x1={field:d.x.field[1],scale:d.x.scale};else{const e=t.field(d.x.field);p.x=(t,o,r)=>{const l=e(t),a=r[c];return i.isArray(l)?a.scale(l[0]):a.scale(l)},p.x1=(t,o,r)=>{const l=r[c],a=e(t);if(i.isArray(a)&&a.length>1)return l.scale(a[1]);const s=l.domain(),n=Math.min.apply(null,s),d=Math.max.apply(null,s),u=n>0?n:d<0?d:0;return l.scale(u)}}if(i.isArray(null===(r=d.y)||void 0===r?void 0:r.field))p.y={field:d.y.field[0],scale:d.y.scale},p.y1={field:d.y.field[1],scale:d.y.scale};else{const e=t.field(d.y.field);p.y=(t,o,r)=>{const l=e(t),a=r[u];return i.isArray(l)?a.scale(l[0]):a.scale(l)},p.y1=(t,o,r)=>{const l=r[u],a=e(t);if(i.isArray(a)&&a.length>1)return l.scale(a[1]);const s=l.domain(),n=Math.min.apply(null,s),d=Math.max.apply(null,s),c=n>0?n:d<0?d:0;return l.scale(c)}}return d.stroke&&(p.stroke=d.stroke),d.color||d.group?p.fill=null!==(l=d.color)&&void 0!==l?l:d.group:p.fill=null!==(s=null===(a=this.spec.style)||void 0===a?void 0:a.fill)&&void 0!==s?s:null===(n=this.getPalette())||void 0===n?void 0:n[0],p}}w.type=n.rect;class b extends s{constructor(e){super(n.rule,e)}setMarkType(){return o.GrammarMarkType.rule}parseScaleOfEncodeX(e){const t=super.parseScaleOfEncodeX(e);return t.type="point",t}parseScaleByEncode(e,t){return this.parseScaleOfCommonEncode(e,t)}convertMarkEncode(e){var t,o,r,l,a,s;const n=this.convertSimpleMarkEncode(e);let d;return i.isArray(null===(t=n.x)||void 0===t?void 0:t.field)?(d.x={field:n.x.field[0],scale:n.x.scale},d.x1={field:n.x.field[1],scale:n.x.scale}):d.x=d.x1=n.x,i.isArray(null===(o=n.y)||void 0===o?void 0:o.field)?(d.y={field:n.y.field[0],scale:n.y.scale},d.y1={field:n.y.field[1],scale:n.y.scale}):d.y=d.y1=n.y,n.color||n.group?d.stroke=null!==(r=n.color)&&void 0!==r?r:n.group:d.stroke=null!==(a=null===(l=this.spec.style)||void 0===l?void 0:l.stroke)&&void 0!==a?a:null===(s=this.getPalette())||void 0===s?void 0:s[0],d}}b.type=n.rule;class P extends s{constructor(e){super(n.symbol,e)}setMarkType(){return o.GrammarMarkType.symbol}parseScaleOfEncodeX(e){const t=super.parseScaleOfEncodeX(e);return t.type="point",t}setDefaultCrosshair(){return{x:{crosshairShape:"line"},y:{crosshairShape:"line"}}}setDefaultTooltip(){var e,t,i;return{disableDimensionTooltip:!0,title:null===(e=this.spec.encode)||void 0===e?void 0:e.group,content:[{value:null===(t=this.spec.encode)||void 0===t?void 0:t.x},{value:null===(i=this.spec.encode)||void 0===i?void 0:i.y}]}}parseScaleByEncode(e,t){return"size"===e?{type:"linear",id:this.getScaleId("size"),domain:{data:this.getDataIdOfFiltered(),field:t},range:[P.defaultSpec.size,P.defaultSpec.size]}:"shape"===e?{type:"ordinal",id:this.getScaleId("shape"),domain:{data:this.getDataIdOfMain(),field:t}}:this.parseScaleOfCommonEncode(e,t)}convertMarkEncode(e){var t,i,o,r;const l=this.convertSimpleMarkEncode(e),a={x:l.x,y:l.y};return l.shape&&(a.symbolType=l.shape),l.size&&(a.size=l.size),l.stroke&&(a.stroke=l.stroke),l.color||l.group?a.fill=null!==(t=l.color)&&void 0!==t?t:l.group:a.fill=null!==(o=null===(i=this.spec.style)||void 0===i?void 0:i.fill)&&void 0!==o?o:null===(r=this.getPalette())||void 0===r?void 0:r[0],a}}P.defaultSpec={size:10},P.type=n.symbol;class E extends s{constructor(e){super(n.text,e)}setMarkType(){return o.GrammarMarkType.text}parseScaleOfEncodeX(e){const t=super.parseScaleOfEncodeX(e);return t.type="point",t}parseScaleByEncode(e,t){return this.parseScaleOfCommonEncode(e,t)}convertMarkEncode(e){var t,i,o,r;const l=this.convertSimpleMarkEncode(e),a=l;return a.text&&(a.text={field:a.text.field}),l.stroke&&(a.stroke=l.stroke),l.color||l.group?a.fill=null!==(t=l.color)&&void 0!==t?t:l.group:a.fill=null!==(o=null===(i=this.spec.style)||void 0===i?void 0:i.fill)&&void 0!==o?o:null===(r=this.getPalette())||void 0===r?void 0:r[0],a}}E.type=n.text;class I extends s{constructor(e){super(n.sankey,e),o.getTransform(n.sankey)||this._logger.error("Please add this line of code: import { registerSankeyTransforms } from '@visactor/vgrammar-sankey'; \n and run registerSankeyTransforms() before use sankey"),o.getGlyph("linkPath")||this._logger.error("\n Please add this line of code: import { registerLinkPathGlyph } from '@visactor/vgrammar';\n add run registerLinkPathGlyph() before use sankey\n ")}setMarkType(){return o.GrammarMarkType.rect}setDefaultDataTransform(){var e;return[{type:"sankey",width:{signal:"viewWidth"},height:{signal:"viewHeight"},nodeKey:null===(e=this.spec.encode)||void 0===e?void 0:e.node}]}getDataIdOfLink(){var e,t;return`${null!==(t=null===(e=this.spec.data)||void 0===e?void 0:e.id)&&void 0!==t?t:this.spec.id}-data-link`}setMultipleData(){return[{id:this.getDataIdOfFiltered(),transform:[{type:"map",all:!0,callback:e=>e[0].nodes}]},{source:this.getDataIdOfMain(),id:this.getDataIdOfLink(),transform:[{type:"map",all:!0,callback:e=>e[0].links}]}]}parseScaleByEncode(e,t){return"color"===e?{type:"ordinal",id:this.getScaleId("color"),domain:{data:this.getDataIdOfFiltered(),field:t},range:this.getPalette()}:null}convertMarkEncode(e){var i,o,r,l;const a=this.convertSimpleMarkEncode(e),s={x:{field:"x0"},x1:{field:"x1"},y:{field:"y0"},y1:{field:"y1"}};if(a.stroke&&(s.stroke=a.stroke),a.color){const e=this.getScaleId("color"),i=t.field(a.color.field);s.fill=(t,o,r)=>r[e].scale(i(null==t?void 0:t.datum))}else s.fill=null!==(r=null===(o=null===(i=this.spec.style)||void 0===i?void 0:i.nodeStyle)||void 0===o?void 0:o.fill)&&void 0!==r?r:null===(l=this.getPalette())||void 0===l?void 0:l[0];return s}setMainMarkSpec(){return{key:"key"}}setLabelTextGetter(e,i){const o=t.field(e);return(e,t,i)=>o(e.datum)}setMultiMarksSpec(){var e;return[{id:`${this.getMarkId()}-link`,type:"glyph",glyphType:"linkPath",from:{data:this.getDataIdOfLink()},layout:{position:"content",skipBeforeLayouted:!0},key:"index",dependency:this.viewSpec.scales.map((e=>e.id)).concat(o.SIGNAL_VIEW_BOX),animation:this.convertMarkAnimation(),encode:Object.assign({},this.spec.state,{enter:Object.assign({backgroundStyle:{fillColor:"#ccc",fillOpacity:.2},fillOpacity:.8,round:!0},null===(e=this.spec.style)||void 0===e?void 0:e.linkStyle),update:(e,t,i)=>{var o,r,l,a;return{direction:e.vertical?"vertical":"horizontal",x0:e.x0,x1:e.x1,y0:e.y0,y1:e.y1,thickness:e.thickness,fill:null!==(l=null===(r=null===(o=this.spec.style)||void 0===o?void 0:o.linkStyle)||void 0===r?void 0:r.fill)&&void 0!==l?l:null===(a=this.getPalette())||void 0===a?void 0:a[0]}}})}]}}I.type=n.sankey;class O extends s{constructor(e){super(n.sunburst,e),o.getTransform("sunburst")||this._logger.error("Please add this line of code: import { registerSunburstTransforms } from 'vgrammar-hierarchy': \n and run registerSunburstTransforms() before use sunburst chart")}setMarkType(){return o.GrammarMarkType.arc}setDefaultDataTransform(){var e;return[{type:"sunburst",width:{signal:"viewWidth"},height:{signal:"viewHeight"},nodeKey:null===(e=this.spec.encode)||void 0===e?void 0:e.node,flatten:!0}]}getDataIdOfLabel(){var e,t;return`${null!==(t=null===(e=this.spec.data)||void 0===e?void 0:e.id)&&void 0!==t?t:this.spec.id}-data-link`}setMultipleData(){return this.spec.label?[{source:this.getDataIdOfFiltered(),id:this.getDataIdOfLabel(),transform:[{type:"filter",callback:e=>!!e.label}]}]:null}parseScaleByEncode(e,t){return"color"===e?{type:"ordinal",id:this.getScaleId("color"),domain:{data:this.getDataIdOfFiltered(),field:t},range:this.getPalette()}:null}convertMarkEncode(e){var i,o,r;const l=this.convertSimpleMarkEncode(e),a={x:{field:"x"},y:{field:"y"},innerRadius:{field:"innerRadius"},outerRadius:{field:"outerRadius"},startAngle:{field:"startAngle"},endAngle:{field:"endAngle"}};if(l.stroke&&(a.stroke=l.stroke),l.color){const e=this.getScaleId("color"),i=t.field(l.color.field);a.fill=(t,o,r)=>{const l=r[e];return(null==t?void 0:t.datum)?l.scale(i(t.datum[t.datum.length-1])):void 0}}else a.fill=null!==(o=null===(i=this.spec.style)||void 0===i?void 0:i.fill)&&void 0!==o?o:null===(r=this.getPalette())||void 0===r?void 0:r[0];return a}setMainMarkEnterEncode(){var e;return null===(e=this.spec.style)||void 0===e?void 0:e.nodeStyle}setMainMarkSpec(){return{key:"key"}}parseLabelSpec(){return[]}setMultiMarksSpec(){const e=this.spec.label;return e?Object.keys(e).map((i=>{const r=t.field(i);return{id:`${this.getMarkId()}-text-${i}`,type:"text",from:{data:this.getDataIdOfLabel()},layout:{position:"content",skipBeforeLayouted:!0},key:"flattenIndex",dependency:this.viewSpec.scales.map((e=>e.id)).concat(o.SIGNAL_VIEW_BOX),animation:this.convertMarkAnimation(),encode:{enter:e[i].textStyle,update:(e,t,i)=>({x:e.label.x,y:e.label.y,textAlign:e.label.textAlign,textBaseline:e.label.textBaseline,text:r(e.datum[e.datum.length-1]),angle:e.label.angle,maxLineWidth:e.label.maxLineWidth})}}})):null}}O.type=n.sunburst;class T extends s{constructor(e){super(n.treemap,e),o.getTransform("treemap")||this._logger.error("Please add this line of code: import { registerTreemapTransforms } from 'vgrammar-hierarchy'; \n and run registerTreemapTransforms() before use treemap")}setMarkType(){return o.GrammarMarkType.rect}setDefaultDataTransform(){var e;return[{type:"treemap",width:{signal:"viewWidth"},height:{signal:"viewHeight"},nodeKey:null===(e=this.spec.encode)||void 0===e?void 0:e.node,flatten:!0}]}parseScaleByEncode(e,t){return"color"===e?{type:"ordinal",id:this.getScaleId("color"),domain:{data:this.getDataIdOfFiltered(),field:t},range:this.getPalette()}:null}convertMarkEncode(e){var i,o,r;const l=this.convertSimpleMarkEncode(e),a={x:{field:"x0"},x1:{field:"x1"},y:{field:"y0"},y1:{field:"y1"}};if(l.stroke&&(a.stroke=l.stroke),l.color){const e=this.getScaleId("color"),i=t.field(l.color.field);a.fill=(t,o,r)=>{const l=r[e];return(null==t?void 0:t.datum)?l.scale(i(t.datum[t.datum.length-1])):void 0}}else a.fill=null!==(o=null===(i=this.spec.style)||void 0===i?void 0:i.fill)&&void 0!==o?o:null===(r=this.getPalette())||void 0===r?void 0:r[0];return a}setMainMarkSpec(){return{key:"key"}}parseLabelSpec(){return[]}setMultiMarksSpec(){const e=this.spec.label;return e?Object.keys(e).map((i=>{const r=t.field(i);return{id:`${this.getMarkId()}-text-${i}`,type:"text",from:{data:this.getDataIdOfFiltered()},layout:{position:"content",skipBeforeLayouted:!0},key:"flattenIndex",dependency:this.viewSpec.scales.map((e=>e.id)).concat(o.SIGNAL_VIEW_BOX),animation:this.convertMarkAnimation(),encode:{enter:Object.assign({textAlign:"center",textBaseline:"middle"},e[i].textStyle),update:(e,t,i)=>({x:e.labelRect?(e.labelRect.x0+e.labelRect.x1)/2:(e.x0+e.x1)/2,y:e.labelRect?(e.labelRect.y0+e.labelRect.y1)/2:(e.y0+e.y1)/2,text:r(e.datum[e.datum.length-1])})}}})):null}}T.type=n.treemap;class _ extends s{constructor(e){super(n.circlePacking,e),o.getTransform(n.circlePacking)||this._logger.error("Please add this line of code: import { registerCirclePackingTransforms } from '@visactor/vgrammar-hierarchy'; \n and run registerCirclePackingTransforms() before use treemap chart")}setMarkType(){return o.GrammarMarkType.circle}setDefaultDataTransform(){var e;return[{type:n.circlePacking,width:{signal:"viewWidth"},height:{signal:"viewHeight"},nodeKey:null===(e=this.spec.encode)||void 0===e?void 0:e.node,flatten:!0}]}parseScaleByEncode(e,t){return"color"===e?{type:"ordinal",id:this.getScaleId("color"),domain:{data:this.getDataIdOfFiltered(),field:t},range:this.getPalette()}:null}convertMarkEncode(e){var i,o,r;const l=this.convertSimpleMarkEncode(e),a={x:{field:"x"},y:{field:"y"},radius:{field:"radius"}};if(l.stroke&&(a.stroke=l.stroke),l.color){const e=this.getScaleId("color"),i=t.field(l.color.field);a.fill=(t,o,r)=>{const l=r[e];return(null==t?void 0:t.datum)?l.scale(i(t.datum[t.datum.length-1])):void 0}}else a.fill=null!==(o=null===(i=this.spec.style)||void 0===i?void 0:i.fill)&&void 0!==o?o:null===(r=this.getPalette())||void 0===r?void 0:r[0];return a}setMainMarkSpec(){return{key:"key"}}setLabelTextGetter(e,i){const o=t.field(e);return(e,t,i)=>o(e.datum[e.datum.length-1])}}_.type=n.circlePacking;class D extends s{constructor(e){super(n.tree,e),o.getTransform(n.tree)||this._logger.error("Please add this line of code: import { registerTreeTransforms } from 'vgrammar-hierarchy', \n and run registerTreeTransforms() before use tree"),o.getGlyph("treePath")||this._logger.error("Please add this line of code: import { registerTreePathGlyph } from '@visactor/vgrammar';\n and run registerTreePathGlyph() before use tree")}setMarkType(){return o.GrammarMarkType.symbol}setDefaultDataTransform(){var e;return[{type:"tree",width:{signal:"viewWidth"},height:{signal:"viewHeight"},nodeKey:null===(e=this.spec.encode)||void 0===e?void 0:e.node,flatten:!0}]}getDataIdOfLink(){var e,t;return`${null!==(t=null===(e=this.spec.data)||void 0===e?void 0:e.id)&&void 0!==t?t:this.spec.id}-data-link`}setMultipleData(){return[{id:this.getDataIdOfFiltered(),transform:[{type:"map",all:!0,callback:e=>e[0].nodes}]},{source:this.getDataIdOfMain(),id:this.getDataIdOfLink(),transform:[{type:"map",all:!0,callback:e=>e[0].links}]}]}parseScaleByEncode(e,t){return"color"===e?{type:"ordinal",id:this.getScaleId("color"),domain:{data:this.getDataIdOfFiltered(),field:t},range:this.getPalette()}:null}convertMarkEncode(e){var i,o,r;const l=this.convertSimpleMarkEncode(e),a={x:{field:"x"},y:{field:"y"}};if(l.stroke&&(a.stroke=l.stroke),l.color){const e=this.getScaleId("color"),i=t.field(l.color.field);a.fill=(t,o,r)=>{const l=r[e];return(null==t?void 0:t.datum)?l.scale(i(t.datum[t.datum.length-1])):void 0}}else a.fill=null!==(o=null===(i=this.spec.style)||void 0===i?void 0:i.fill)&&void 0!==o?o:null===(r=this.getPalette())||void 0===r?void 0:r[0];return a}setLabelTextGetter(e,i){const o=t.field(e);return(e,t,i)=>o(e.datum[e.datum.length-1])}setMainMarkSpec(){return{key:"key"}}setMultiMarksSpec(){if(!this.spec.label)return null;const e=[];return e.push({type:"glyph",glyphType:"treePath",from:{data:this.getDataIdOfLink()},key:"key",zIndex:-1,encode:{update:{x0:{field:"x0"},x1:{field:"x1"},y0:{field:"y0"},y1:{field:"y1"},thickness:1,round:!0,stroke:"#333"}}}),e}}D.type=n.tree;class B extends s{constructor(e){super(n.wordcloud,e),o.getTransform(n.wordcloud)||this._logger.error("Please add this line of code:\n 'import { registerWordCloudTransforms } from '@visactor/vgrammar-wordcloud'; \n and run registerWordCloudTransforms() before use wordcloud")}setMarkType(){return o.GrammarMarkType.text}setDefaultMarkTransform(){var e;return[{type:"wordcloud",size:{callback:e=>[e.viewBox.width(),e.viewBox.height()],dependency:["viewBox"]},text:{field:null===(e=this.spec.encode)||void 0===e?void 0:e.text}}]}parseScaleByEncode(e,t){return"color"===e?{type:"ordinal",id:this.getScaleId("color"),domain:{data:this.getDataIdOfFiltered(),field:t},range:this.getPalette()}:null}convertMarkEncode(e){var i,o,r,l;const a=this.convertSimpleMarkEncode(e),s={x:{field:"x"},y:{field:"y"},angle:{field:"angle"},fontSize:{field:"fontSize"},fontStyle:{field:"fontStyle"},fontFamily:{field:"fontFamily"},fontWeight:{field:"fontWeight"},text:{field:null===(i=this.spec.encode)||void 0===i?void 0:i.text}};if(a.stroke&&(s.stroke=a.stroke),a.color){const e=this.getScaleId("color"),i=t.field(a.color.field);s.fill=(t,o,r)=>r[e].scale(i(t))}else s.fill=null!==(r=null===(o=this.spec.style)||void 0===o?void 0:o.fill)&&void 0!==r?r:null===(l=this.getPalette())||void 0===l?void 0:l[0];return s}parseLabelSpec(){return[]}}B.type=n.wordcloud;class A extends s{constructor(e){super(n.wordcloudShape,e),o.getTransform(n.wordcloudShape)||this._logger.error("Please add this line of code:\n import { registerWordCloudShapeTransforms } from '@visactor/vgrammar-wordcloud-shape'; \n and run registerWordCloudShapeTransforms() before use wordcloud-shape")}setMarkType(){return o.GrammarMarkType.text}setDefaultDataTransform(){var e;return[{type:"wordcloudShape",size:{callback:e=>[e.viewBox.width(),e.viewBox.height()],dependency:["viewBox"]},colorList:this.getPalette(),text:{field:null===(e=this.spec.encode)||void 0===e?void 0:e.text}}]}setMainMarkEnterEncode(){return i.merge({textAlign:"center",textBaseline:"middle"},this.spec.style)}parseScaleByEncode(e,t){return"color"===e?{type:"ordinal",id:this.getScaleId("color"),domain:{data:this.getDataIdOfFiltered(),field:t},range:this.getPalette()}:null}convertMarkEncode(e){var i,o,r,l;const a=this.convertSimpleMarkEncode(e),s={x:{field:"x"},y:{field:"y"},angle:{field:"angle"},fontSize:{field:"fontSize"},fontStyle:{field:"fontStyle"},fontFamily:{field:"fontFamily"},fontWeight:{field:"fontWeight"},fillOpacity:{field:"opacity"},text:{field:null===(i=this.spec.encode)||void 0===i?void 0:i.text}};if(a.stroke&&(s.stroke=a.stroke),a.color){const e=this.getScaleId("color"),i=t.field(a.color.field);s.fill=(t,o,r)=>r[e].scale(i(t))}else s.fill=null!==(r=null===(o=this.spec.style)||void 0===o?void 0:o.fill)&&void 0!==r?r:null===(l=this.getPalette())||void 0===l?void 0:l[0];return s}parseLabelSpec(){return[]}}A.type=n.wordcloudShape,g.useMarks([d,c,u,p,h,v,m,k,x,w,S,M,b,P,E,I,O,T,_,D,B,A]),e.Plot=g}));
|
package/es/area.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SemanticMark } from "./semantic-mark";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { GrammarMarkType } from "@visactor/vgrammar";
|
|
4
4
|
|
|
5
5
|
import { isArray } from "@visactor/vutils";
|
|
6
6
|
|
|
@@ -41,7 +41,7 @@ export class Area extends SemanticMark {
|
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
convertMarkEncode(encode) {
|
|
44
|
-
var _a, _b, _c, _d, _e;
|
|
44
|
+
var _a, _b, _c, _d, _e, _f;
|
|
45
45
|
const markEncoder = this.convertSimpleMarkEncode(encode);
|
|
46
46
|
let res;
|
|
47
47
|
if (isArray(null === (_a = markEncoder.x) || void 0 === _a ? void 0 : _a.field)) res = {
|
|
@@ -75,7 +75,7 @@ export class Area extends SemanticMark {
|
|
|
75
75
|
}
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
|
-
return markEncoder.color || markEncoder.group ? res.fill = null !== (_c = markEncoder.color) && void 0 !== _c ? _c : markEncoder.group : res.fill = null !== (_e = null === (_d = this.spec.style) || void 0 === _d ? void 0 : _d.fill) && void 0 !== _e ? _e : getPalette()[0],
|
|
78
|
+
return markEncoder.stroke && (res.stroke = markEncoder.stroke), markEncoder.color || markEncoder.group ? res.fill = null !== (_c = markEncoder.color) && void 0 !== _c ? _c : markEncoder.group : res.fill = null !== (_e = null === (_d = this.spec.style) || void 0 === _d ? void 0 : _d.fill) && void 0 !== _e ? _e : null === (_f = this.getPalette()) || void 0 === _f ? void 0 : _f[0],
|
|
79
79
|
res;
|
|
80
80
|
}
|
|
81
81
|
}
|
package/es/area.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/area.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"sources":["../src/area.ts"],"names":[],"mappings":"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","file":"area.js","sourcesContent":["import type {\n AreaEncodeChannels,\n SemanticTooltipOption,\n WithDefaultEncode,\n PlotAreaEncoderSpec,\n GenerateBaseEncodeSpec,\n GenerateEncoderSpec,\n Nil,\n ScaleSpec,\n ValueOf,\n IElement,\n CrosshairSpec\n} from '@visactor/vgrammar';\nimport { SemanticMark } from './semantic-mark';\n// eslint-disable-next-line no-duplicate-imports\nimport { GrammarMarkType } from '@visactor/vgrammar';\nimport { isArray } from '@visactor/vutils';\nimport { PlotMakType } from './enums';\n\nexport class Area extends SemanticMark<PlotAreaEncoderSpec, AreaEncodeChannels> {\n static readonly type = PlotMakType.area;\n constructor(id?: string | number) {\n super(PlotMakType.area, id);\n }\n\n setMarkType() {\n return GrammarMarkType.area;\n }\n\n protected parseScaleOfEncodeX(\n option: ValueOf<WithDefaultEncode<PlotAreaEncoderSpec, AreaEncodeChannels>, AreaEncodeChannels>\n ): ScaleSpec | Nil {\n const res = super.parseScaleOfEncodeX(option);\n\n res.type = 'point';\n return res;\n }\n\n parseScaleByEncode(\n channel: AreaEncodeChannels,\n option: ValueOf<WithDefaultEncode<PlotAreaEncoderSpec, AreaEncodeChannels>, AreaEncodeChannels>\n ): ScaleSpec | Nil {\n return this.parseScaleOfCommonEncode(channel, option);\n }\n\n setDefaultCrosshair(): Record<string, Pick<CrosshairSpec, 'crosshairShape' | 'crosshairType'>> {\n return {\n x: { crosshairShape: 'line' }\n };\n }\n\n setDefaultTooltip(): SemanticTooltipOption | Nil {\n const encodeX = this.spec.encode?.x;\n const encodeY = this.spec.encode?.y;\n return {\n disableGraphicTooltip: true,\n title: isArray(encodeX) ? encodeX[0] : encodeX,\n content: isArray(encodeY)\n ? encodeY.map(entry => {\n return {\n value: entry\n };\n })\n : [\n {\n value: encodeY\n }\n ]\n };\n }\n\n convertMarkEncode(\n encode: WithDefaultEncode<PlotAreaEncoderSpec, AreaEncodeChannels>\n ): GenerateBaseEncodeSpec<PlotAreaEncoderSpec> {\n const markEncoder = this.convertSimpleMarkEncode(encode);\n\n let res: GenerateEncoderSpec<PlotAreaEncoderSpec>;\n\n if (isArray(markEncoder.x?.field)) {\n res = {\n y: markEncoder.y,\n x: { field: markEncoder.x.field[0], scale: markEncoder.x.scale },\n x1: { field: markEncoder.x.field[1], scale: markEncoder.x.scale }\n } as GenerateEncoderSpec<PlotAreaEncoderSpec>;\n } else if (isArray(markEncoder.y?.field)) {\n res = {\n y: { field: markEncoder.y.field[0], scale: markEncoder.y.scale },\n y1: { field: markEncoder.y.field[1], scale: markEncoder.y.scale },\n x: markEncoder.x\n } as GenerateEncoderSpec<PlotAreaEncoderSpec>;\n } else {\n const scaleYId = this.getScaleId('y');\n res = {\n x: markEncoder.x,\n y: markEncoder.y,\n y1: (datum: any, el: IElement, params: any) => {\n const scale = params[scaleYId];\n const domain = scale.domain();\n const min = Math.min.apply(null, domain);\n const max = Math.max.apply(null, domain);\n const baseValue = min > 0 ? min : max < 0 ? max : 0;\n\n return scale.scale(baseValue);\n }\n } as GenerateEncoderSpec<PlotAreaEncoderSpec>;\n }\n\n if (markEncoder.stroke) {\n res.stroke = markEncoder.stroke;\n }\n\n if (markEncoder.color || markEncoder.group) {\n res.fill = markEncoder.color ?? markEncoder.group;\n } else {\n res.fill = this.spec.style?.fill ?? this.getPalette()?.[0];\n }\n\n return res;\n }\n}\n"]}
|
package/es/cell.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SemanticMark } from "./semantic-mark";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { GrammarMarkType } from "@visactor/vgrammar";
|
|
4
4
|
|
|
5
5
|
import { PlotMakType } from "./enums";
|
|
6
6
|
|
|
@@ -35,12 +35,12 @@ export class Cell extends SemanticMark {
|
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
convertMarkEncode(encode) {
|
|
38
|
-
var _a, _b, _c;
|
|
38
|
+
var _a, _b, _c, _d;
|
|
39
39
|
const markEncoder = this.convertSimpleMarkEncode(encode), res = {
|
|
40
40
|
y: markEncoder.y,
|
|
41
41
|
x: markEncoder.x
|
|
42
42
|
};
|
|
43
|
-
return markEncoder.color || markEncoder.group ? res.
|
|
43
|
+
return markEncoder.stroke && (res.stroke = markEncoder.stroke), markEncoder.color || markEncoder.group ? res.fill = null !== (_a = markEncoder.color) && void 0 !== _a ? _a : markEncoder.group : res.fill = null !== (_c = null === (_b = this.spec.style) || void 0 === _b ? void 0 : _b.fill) && void 0 !== _c ? _c : null === (_d = this.getPalette()) || void 0 === _d ? void 0 : _d[0],
|
|
44
44
|
res;
|
|
45
45
|
}
|
|
46
46
|
}
|
package/es/cell.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cell.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"sources":["../src/cell.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,MAAM,OAAO,IAAK,SAAQ,YAA6D;IAErF,YAAY,EAAoB;QAC9B,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAC9B,CAAC;IAED,WAAW;QACT,OAAO,eAAe,CAAC,IAAI,CAAC;IAC9B,CAAC;IAES,mBAAmB,CAC3B,MAAuG;QAEvG,MAAM,GAAG,GAAG,KAAK,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;QAE9C,GAAG,CAAC,IAAI,GAAG,OAAO,CAAC;QACnB,OAAO,GAAG,CAAC;IACb,CAAC;IAED,kBAAkB,CAChB,OAA2B,EAC3B,MAAuG;QAEvG,OAAO,IAAI,CAAC,wBAAwB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACxD,CAAC;IAED,mBAAmB;QACjB,OAAO;YACL,CAAC,EAAE,EAAE,cAAc,EAAE,MAAM,EAAE;SAC9B,CAAC;IACJ,CAAC;IAED,iBAAiB;;QACf,OAAO;YACL,KAAK,EAAE,MAAA,IAAI,CAAC,IAAI,CAAC,MAAM,0CAAE,CAAC;YAC1B,OAAO,EAAE;gBACP;oBACE,KAAK,EAAE,MAAA,IAAI,CAAC,IAAI,CAAC,MAAM,0CAAE,CAAC;iBAC3B;aACF;SACF,CAAC;IACJ,CAAC;IAED,iBAAiB,CACf,MAA0E;;QAE1E,MAAM,WAAW,GAAG,IAAI,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC;QAEzD,MAAM,GAAG,GAAG;YACV,CAAC,EAAE,WAAW,CAAC,CAAC;YAChB,CAAC,EAAE,WAAW,CAAC,CAAC;SACmC,CAAC;QAEtD,IAAI,WAAW,CAAC,MAAM,EAAE;YACtB,GAAG,CAAC,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC;SACjC;QAED,IAAI,WAAW,CAAC,KAAK,IAAI,WAAW,CAAC,KAAK,EAAE;YAC1C,GAAG,CAAC,IAAI,GAAG,MAAA,WAAW,CAAC,KAAK,mCAAI,WAAW,CAAC,KAAK,CAAC;SACnD;aAAM;YACL,GAAG,CAAC,IAAI,GAAG,MAAA,MAAA,IAAI,CAAC,IAAI,CAAC,KAAK,0CAAE,IAAI,mCAAI,MAAA,IAAI,CAAC,UAAU,EAAE,0CAAG,CAAC,CAAC,CAAC;SAC5D;QAED,OAAO,GAAG,CAAC;IACb,CAAC;;AA/De,SAAI,GAAG,WAAW,CAAC,IAAI,CAAC","file":"cell.js","sourcesContent":["import type {\n BasicEncoderSpecMap,\n GenerateBaseEncodeSpec,\n GenerateEncoderSpec,\n Nil,\n ScaleSpec,\n ValueOf,\n CrosshairSpec,\n CellEncodeChannels,\n SemanticTooltipOption,\n WithDefaultEncode\n} from '@visactor/vgrammar';\nimport { SemanticMark } from './semantic-mark';\n// eslint-disable-next-line no-duplicate-imports\nimport { GrammarMarkType } from '@visactor/vgrammar';\nimport { PlotMakType } from './enums';\n\nexport class Cell extends SemanticMark<BasicEncoderSpecMap['cell'], CellEncodeChannels> {\n static readonly type = PlotMakType.cell;\n constructor(id?: string | number) {\n super(PlotMakType.cell, id);\n }\n\n setMarkType() {\n return GrammarMarkType.cell;\n }\n\n protected parseScaleOfEncodeX(\n option: ValueOf<WithDefaultEncode<BasicEncoderSpecMap['cell'], CellEncodeChannels>, CellEncodeChannels>\n ): ScaleSpec | Nil {\n const res = super.parseScaleOfEncodeX(option);\n\n res.type = 'point';\n return res;\n }\n\n parseScaleByEncode(\n channel: CellEncodeChannels,\n option: ValueOf<WithDefaultEncode<BasicEncoderSpecMap['cell'], CellEncodeChannels>, CellEncodeChannels>\n ): ScaleSpec | Nil {\n return this.parseScaleOfCommonEncode(channel, option);\n }\n\n setDefaultCrosshair(): Record<string, Pick<CrosshairSpec, 'crosshairShape' | 'crosshairType'>> {\n return {\n x: { crosshairShape: 'line' }\n };\n }\n\n setDefaultTooltip(): SemanticTooltipOption | Nil {\n return {\n title: this.spec.encode?.x,\n content: [\n {\n value: this.spec.encode?.y\n }\n ]\n };\n }\n\n convertMarkEncode(\n encode: WithDefaultEncode<BasicEncoderSpecMap['cell'], CellEncodeChannels>\n ): GenerateBaseEncodeSpec<BasicEncoderSpecMap['cell']> {\n const markEncoder = this.convertSimpleMarkEncode(encode);\n\n const res = {\n y: markEncoder.y,\n x: markEncoder.x\n } as GenerateEncoderSpec<BasicEncoderSpecMap['cell']>;\n\n if (markEncoder.stroke) {\n res.stroke = markEncoder.stroke;\n }\n\n if (markEncoder.color || markEncoder.group) {\n res.fill = markEncoder.color ?? markEncoder.group;\n } else {\n res.fill = this.spec.style?.fill ?? this.getPalette()?.[0];\n }\n\n return res;\n }\n}\n"]}
|
package/es/circle-packing.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SemanticMark } from "./semantic-mark";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { GrammarMarkType, getTransform } from "@visactor/vgrammar";
|
|
4
4
|
|
|
5
5
|
import { PlotMakType } from "./enums";
|
|
6
6
|
|
|
@@ -35,11 +35,11 @@ export class CirclePackingSemanticMark extends SemanticMark {
|
|
|
35
35
|
data: this.getDataIdOfFiltered(),
|
|
36
36
|
field: option
|
|
37
37
|
},
|
|
38
|
-
range: getPalette()
|
|
38
|
+
range: this.getPalette()
|
|
39
39
|
} : null;
|
|
40
40
|
}
|
|
41
41
|
convertMarkEncode(encode) {
|
|
42
|
-
var _a, _b;
|
|
42
|
+
var _a, _b, _c;
|
|
43
43
|
const markEncoder = this.convertSimpleMarkEncode(encode), res = {
|
|
44
44
|
x: {
|
|
45
45
|
field: "x"
|
|
@@ -51,13 +51,13 @@ export class CirclePackingSemanticMark extends SemanticMark {
|
|
|
51
51
|
field: "radius"
|
|
52
52
|
}
|
|
53
53
|
};
|
|
54
|
-
if (markEncoder.color) {
|
|
54
|
+
if (markEncoder.stroke && (res.stroke = markEncoder.stroke), markEncoder.color) {
|
|
55
55
|
const scaleColorId = this.getScaleId("color"), colorAccessor = getFieldAccessor(markEncoder.color.field);
|
|
56
56
|
res.fill = (datum, el, params) => {
|
|
57
57
|
const scale = params[scaleColorId];
|
|
58
58
|
return (null == datum ? void 0 : datum.datum) ? scale.scale(colorAccessor(datum.datum[datum.datum.length - 1])) : void 0;
|
|
59
59
|
};
|
|
60
|
-
} else res.fill = null !== (_b = null === (_a = this.spec.style) || void 0 === _a ? void 0 : _a.fill) && void 0 !== _b ? _b : getPalette()[0];
|
|
60
|
+
} else res.fill = null !== (_b = null === (_a = this.spec.style) || void 0 === _a ? void 0 : _a.fill) && void 0 !== _b ? _b : null === (_c = this.getPalette()) || void 0 === _c ? void 0 : _c[0];
|
|
61
61
|
return res;
|
|
62
62
|
}
|
|
63
63
|
setMainMarkSpec() {
|
package/es/circle-packing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/circle-packing.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"sources":["../src/circle-packing.ts"],"names":[],"mappings":"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","file":"circle-packing.js","sourcesContent":["import type {\n GenerateBaseEncodeSpec,\n GenerateEncoderSpec,\n Nil,\n ScaleSpec,\n ValueOf,\n TransformSpec,\n IElement,\n ChannelEncodeType,\n CirclepackingEncodeChannels,\n WithDefaultEncode,\n PlotCirclePackingEncodeSpec,\n SemanticLabelOption\n} from '@visactor/vgrammar';\nimport { SemanticMark } from './semantic-mark';\n// eslint-disable-next-line no-duplicate-imports\nimport { GrammarMarkType, getTransform } from '@visactor/vgrammar';\nimport { PlotMakType } from './enums';\nimport { field as getFieldAccessor } from '@visactor/vgrammar-util';\nimport type { ITextAttribute } from '@visactor/vrender';\n\nexport class CirclePackingSemanticMark extends SemanticMark<PlotCirclePackingEncodeSpec, CirclepackingEncodeChannels> {\n static readonly type = PlotMakType.circlePacking;\n constructor(id?: string | number) {\n super(PlotMakType.circlePacking, id);\n\n if (!getTransform(PlotMakType.circlePacking)) {\n this._logger.error(\n `Please add this line of code: import { registerCirclePackingTransforms } from '@visactor/vgrammar-hierarchy'; \n and run registerCirclePackingTransforms() before use treemap chart`\n );\n }\n }\n\n setMarkType() {\n return GrammarMarkType.circle;\n }\n\n setDefaultDataTransform(): TransformSpec[] {\n return [\n {\n type: PlotMakType.circlePacking,\n width: { signal: 'viewWidth' },\n height: { signal: 'viewHeight' },\n nodeKey: this.spec.encode?.node,\n flatten: true\n }\n ];\n }\n parseScaleByEncode(\n channel: CirclepackingEncodeChannels,\n option: ValueOf<\n WithDefaultEncode<PlotCirclePackingEncodeSpec, CirclepackingEncodeChannels>,\n CirclepackingEncodeChannels\n >\n ): ScaleSpec | Nil {\n if (channel === 'color') {\n return {\n type: 'ordinal',\n id: this.getScaleId('color'),\n domain: {\n data: this.getDataIdOfFiltered(),\n field: option as string\n },\n range: this.getPalette()\n };\n }\n\n return null;\n }\n\n convertMarkEncode(\n encode: WithDefaultEncode<PlotCirclePackingEncodeSpec, CirclepackingEncodeChannels>\n ): GenerateBaseEncodeSpec<PlotCirclePackingEncodeSpec> {\n const markEncoder = this.convertSimpleMarkEncode(encode);\n\n const res: GenerateEncoderSpec<PlotCirclePackingEncodeSpec> = {\n x: { field: 'x' },\n y: { field: 'y' },\n radius: { field: 'radius' }\n };\n\n if (markEncoder.stroke) {\n res.stroke = markEncoder.stroke;\n }\n\n if (markEncoder.color) {\n const scaleColorId = this.getScaleId('color');\n const colorAccessor = getFieldAccessor(markEncoder.color.field);\n\n res.fill = (datum: any, el: IElement, params: any) => {\n const scale = params[scaleColorId];\n return datum?.datum ? scale.scale(colorAccessor(datum.datum[datum.datum.length - 1])) : undefined;\n };\n } else {\n res.fill = this.spec.style?.fill ?? this.getPalette()?.[0];\n }\n\n return res;\n }\n\n setMainMarkSpec() {\n return { key: 'key' };\n }\n\n protected setLabelTextGetter(\n channel: string,\n option: SemanticLabelOption | boolean\n ): ChannelEncodeType<ITextAttribute['text']> {\n const textGetter = getFieldAccessor(channel);\n return (datum: any, el: IElement, params: any) => {\n return textGetter(datum.datum[datum.datum.length - 1]);\n };\n }\n}\n"]}
|
package/es/image.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SemanticMark } from "./semantic-mark";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { GrammarMarkType } from "@visactor/vgrammar";
|
|
4
4
|
|
|
5
5
|
import { isArray } from "@visactor/vutils";
|
|
6
6
|
|
|
@@ -30,7 +30,7 @@ export class ImageSemanticMark extends SemanticMark {
|
|
|
30
30
|
} : this.parseScaleOfCommonEncode(channel, option);
|
|
31
31
|
}
|
|
32
32
|
convertMarkEncode(encode) {
|
|
33
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
33
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
34
34
|
const markEncoder = this.convertSimpleMarkEncode(encode), scaleXId = this.getScaleId("x"), scaleYId = this.getScaleId("y"), res = {
|
|
35
35
|
image: markEncoder.src
|
|
36
36
|
};
|
|
@@ -62,7 +62,7 @@ export class ImageSemanticMark extends SemanticMark {
|
|
|
62
62
|
res.y = (datum, el, params) => params[scaleXId].scale(yAccessor(datum)) - height / 2,
|
|
63
63
|
res.height = height;
|
|
64
64
|
}
|
|
65
|
-
return markEncoder.color || markEncoder.group ? res.fill = null !== (_g = markEncoder.color) && void 0 !== _g ? _g : markEncoder.group : res.fill = null !== (_j = null === (_h = this.spec.style) || void 0 === _h ? void 0 : _h.fill) && void 0 !== _j ? _j : getPalette()[0],
|
|
65
|
+
return markEncoder.stroke && (res.stroke = markEncoder.stroke), markEncoder.color || markEncoder.group ? res.fill = null !== (_g = markEncoder.color) && void 0 !== _g ? _g : markEncoder.group : res.fill = null !== (_j = null === (_h = this.spec.style) || void 0 === _h ? void 0 : _h.fill) && void 0 !== _j ? _j : null === (_k = this.getPalette()) || void 0 === _k ? void 0 : _k[0],
|
|
66
66
|
res;
|
|
67
67
|
}
|
|
68
68
|
}
|
package/es/image.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/image.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"sources":["../src/image.ts"],"names":[],"mappings":"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","file":"image.js","sourcesContent":["import { SemanticMark } from './semantic-mark';\nimport type {\n ImageEncodeChannels,\n WithDefaultEncode,\n PlotImageEncoderSpec,\n GenerateBaseEncodeSpec,\n GenerateEncoderSpec,\n IElement,\n Nil,\n ScaleSpec,\n ValueOf\n} from '@visactor/vgrammar';\n// eslint-disable-next-line no-duplicate-imports\nimport { GrammarMarkType } from '@visactor/vgrammar';\nimport { isArray } from '@visactor/vutils';\nimport { field as getFieldAccessor } from '@visactor/vgrammar-util';\nimport { PlotMakType } from './enums';\n\nexport class ImageSemanticMark extends SemanticMark<PlotImageEncoderSpec, ImageEncodeChannels> {\n static readonly type = PlotMakType.image;\n static defaultSpec: PlotImageEncoderSpec = { width: 10, height: 10 };\n constructor(id?: string | number) {\n super(PlotMakType.image, id);\n }\n\n setMarkType() {\n return GrammarMarkType.image;\n }\n\n protected parseScaleOfEncodeX(\n option: ValueOf<WithDefaultEncode<PlotImageEncoderSpec, ImageEncodeChannels>, ImageEncodeChannels>\n ): ScaleSpec | Nil {\n const res = super.parseScaleOfEncodeX(option);\n\n res.type = 'point';\n return res;\n }\n\n parseScaleByEncode(\n channel: ImageEncodeChannels,\n option: ValueOf<WithDefaultEncode<PlotImageEncoderSpec, ImageEncodeChannels>, ImageEncodeChannels>\n ): ScaleSpec | Nil {\n if (channel === 'src') {\n return {\n type: 'ordinal',\n id: this.getScaleId('src'),\n domain: {\n data: this.getDataIdOfMain(),\n field: option as string\n }\n };\n }\n\n return this.parseScaleOfCommonEncode(channel, option);\n }\n\n convertMarkEncode(\n encode: WithDefaultEncode<PlotImageEncoderSpec, ImageEncodeChannels>\n ): GenerateBaseEncodeSpec<PlotImageEncoderSpec> {\n const markEncoder = this.convertSimpleMarkEncode(encode);\n const scaleXId = this.getScaleId('x');\n const scaleYId = this.getScaleId('y');\n const res: GenerateEncoderSpec<PlotImageEncoderSpec> = {\n image: markEncoder.src\n };\n\n if (markEncoder.src) {\n res.image = markEncoder.src;\n }\n\n if (isArray(markEncoder.x?.field)) {\n const xAccessor = getFieldAccessor(markEncoder.x.field[0]);\n const x1Accessor = getFieldAccessor(markEncoder.x.field[1]);\n res.x = (datum: any, el: IElement, params: any) => {\n const scale = params[scaleXId];\n\n return Math.min(scale.scale(xAccessor(datum)), scale.scale(x1Accessor(datum)));\n };\n res.width = (datum: any, el: IElement, params: any) => {\n const scale = params[scaleXId];\n\n return Math.abs(scale.scale(xAccessor(datum)) - scale.scale(x1Accessor(datum)));\n };\n } else {\n const width = this.spec.style?.width ?? ImageSemanticMark.defaultSpec.width;\n const xAccessor = getFieldAccessor(markEncoder.x.field);\n\n res.x = (datum: any, el: IElement, params: any) => {\n const scale = params[scaleXId];\n\n return scale.scale(xAccessor(datum)) - width / 2;\n };\n res.width = width;\n }\n\n if (isArray(markEncoder.y?.field)) {\n const yAccessor = getFieldAccessor(markEncoder.y.field[0]);\n const y1Accessor = getFieldAccessor(markEncoder.y.field[1]);\n res.y = (datum: any, el: IElement, params: any) => {\n const scale = params[scaleYId];\n\n return Math.min(scale.scale(yAccessor(datum)), scale.scale(y1Accessor(datum)));\n };\n res.height = (datum: any, el: IElement, params: any) => {\n const scale = params[scaleYId];\n\n return Math.abs(scale.scale(yAccessor(datum)) - scale.scale(y1Accessor(datum)));\n };\n } else {\n const height = this.spec.style?.height ?? ImageSemanticMark.defaultSpec.height;\n const yAccessor = getFieldAccessor(markEncoder.y.field);\n\n res.y = (datum: any, el: IElement, params: any) => {\n const scale = params[scaleXId];\n\n return scale.scale(yAccessor(datum)) - height / 2;\n };\n res.height = height;\n }\n\n if (markEncoder.stroke) {\n res.stroke = markEncoder.stroke;\n }\n\n if (markEncoder.color || markEncoder.group) {\n res.fill = markEncoder.color ?? markEncoder.group;\n } else {\n res.fill = this.spec.style?.fill ?? this.getPalette()?.[0];\n }\n\n return res;\n }\n}\n"]}
|
package/es/interval.js
CHANGED
|
@@ -2,7 +2,7 @@ import { field as getFieldAccessor } from "@visactor/vgrammar-util";
|
|
|
2
2
|
|
|
3
3
|
import { SemanticMark } from "./semantic-mark";
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { GrammarMarkType } from "@visactor/vgrammar";
|
|
6
6
|
|
|
7
7
|
import { isArray } from "@visactor/vutils";
|
|
8
8
|
|
|
@@ -64,7 +64,7 @@ export class Interval extends SemanticMark {
|
|
|
64
64
|
} : {};
|
|
65
65
|
}
|
|
66
66
|
convertMarkEncode(encode) {
|
|
67
|
-
var _a, _b, _c, _d, _e;
|
|
67
|
+
var _a, _b, _c, _d, _e, _f;
|
|
68
68
|
const markEncoder = this.convertSimpleMarkEncode(encode), scaleXId = this.getScaleId("x"), scaleYId = this.getScaleId("y"), xAccessor = getFieldAccessor(markEncoder.x.field), res = {
|
|
69
69
|
x: (datum, el, params) => {
|
|
70
70
|
const scale = params[scaleXId], bandWidth = scale.bandwidth();
|
|
@@ -93,8 +93,8 @@ export class Interval extends SemanticMark {
|
|
|
93
93
|
return scale.scale(baseValue);
|
|
94
94
|
};
|
|
95
95
|
}
|
|
96
|
-
return markEncoder.color || markEncoder.group ? res.fill = null !== (_b = markEncoder.color) && void 0 !== _b ? _b : markEncoder.group : res.fill = null !== (_d = null === (_c = this.spec.style) || void 0 === _c ? void 0 : _c.fill) && void 0 !== _d ? _d : getPalette()[0],
|
|
97
|
-
"polar" === (null === (
|
|
96
|
+
return markEncoder.stroke && (res.stroke = markEncoder.stroke), markEncoder.color || markEncoder.group ? res.fill = null !== (_b = markEncoder.color) && void 0 !== _b ? _b : markEncoder.group : res.fill = null !== (_d = null === (_c = this.spec.style) || void 0 === _c ? void 0 : _c.fill) && void 0 !== _d ? _d : null === (_e = this.getPalette()) || void 0 === _e ? void 0 : _e[0],
|
|
97
|
+
"polar" === (null === (_f = this._coordinate) || void 0 === _f ? void 0 : _f.type) && (res.cx = (datum, el, params) => params[this._coordinate.id].origin().x,
|
|
98
98
|
res.cy = (datum, el, params) => params[this._coordinate.id].origin().y), res;
|
|
99
99
|
}
|
|
100
100
|
}
|