@visactor/vgrammar-plot 0.6.4-alpha.2 → 0.6.5-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/dist/index.js +1 -1
- package/dist/index.min.js +1 -1
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
var ScaleEnum;
|
|
8
8
|
!function (ScaleEnum) {
|
|
9
|
-
ScaleEnum.Linear = "linear", ScaleEnum.Log = "log", ScaleEnum.Pow = "pow", ScaleEnum.Sqrt = "sqrt", ScaleEnum.Symlog = "symlog", ScaleEnum.Time = "time", ScaleEnum.Quantile = "quantile", ScaleEnum.Quantize = "quantize", ScaleEnum.Threshold = "threshold", ScaleEnum.Ordinal = "ordinal", ScaleEnum.Point = "point", ScaleEnum.Band = "band";
|
|
9
|
+
ScaleEnum.Identity = "identity", ScaleEnum.Linear = "linear", ScaleEnum.Log = "log", ScaleEnum.Pow = "pow", ScaleEnum.Sqrt = "sqrt", ScaleEnum.Symlog = "symlog", ScaleEnum.Time = "time", ScaleEnum.Quantile = "quantile", ScaleEnum.Quantize = "quantize", ScaleEnum.Threshold = "threshold", ScaleEnum.Ordinal = "ordinal", ScaleEnum.Point = "point", ScaleEnum.Band = "band";
|
|
10
10
|
}(ScaleEnum || (ScaleEnum = {}));
|
|
11
11
|
function isContinuous(type) {
|
|
12
12
|
switch (type) {
|
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.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,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}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visactor/vgrammar-plot",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.5-alpha.0",
|
|
4
4
|
"description": "Plots of vgrammar.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"plot",
|
|
@@ -30,13 +30,13 @@
|
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@visactor/vgrammar-util": "0.6.
|
|
34
|
-
"@visactor/vgrammar-coordinate": "0.6.
|
|
35
|
-
"@visactor/vgrammar": "0.6.4-alpha.
|
|
36
|
-
"@visactor/vscale": "~0.15.
|
|
37
|
-
"@visactor/vrender-components": "~0.14.
|
|
38
|
-
"@visactor/vrender": "~0.14.
|
|
39
|
-
"@visactor/vutils": "~0.15.
|
|
33
|
+
"@visactor/vgrammar-util": "0.6.4",
|
|
34
|
+
"@visactor/vgrammar-coordinate": "0.6.4",
|
|
35
|
+
"@visactor/vgrammar": "0.6.4-alpha.0",
|
|
36
|
+
"@visactor/vscale": "~0.15.8",
|
|
37
|
+
"@visactor/vrender-components": "~0.14.5",
|
|
38
|
+
"@visactor/vrender": "~0.14.5",
|
|
39
|
+
"@visactor/vutils": "~0.15.8"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"d3-array": "1.x",
|