realchart 1.3.4 → 1.3.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "realchart",
3
- "version": "1.3.4",
3
+ "version": "1.3.6",
4
4
  "description": "Wooritech charting library",
5
5
  "main": "./index.js",
6
6
  "module": "./index.mjs",
@@ -128,7 +128,7 @@
128
128
 
129
129
  /** theme */
130
130
  .rct-control {
131
- --rct-background: none;
131
+ --rct-background: #fff;
132
132
  }
133
133
  .rct-control[data-theme="dark"] {
134
134
  --rct-background: #262626;
@@ -846,12 +846,16 @@
846
846
  fill-opacity: 0.85;
847
847
  }
848
848
  .rct-waterfall-point-negative {
849
- fill: #dd5500;
850
- stroke: #dd5500;
849
+ fill: #F28321;
850
+ stroke: #F28321;
851
+ }
852
+ .rct-waterfall-point-mid {
853
+ fill: #B4DD72;
854
+ stroke: #B4DD72;
851
855
  }
852
856
  .rct-waterfall-point-sum {
853
- fill: #0055cc;
854
- stroke: #0055cc;
857
+ fill: #6EAD3F;
858
+ stroke: #6EAD3F;
855
859
  }
856
860
  .rct-waterfall-series-lines {
857
861
  stroke: #77f;
package/split.js CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  /**
3
- * RealChart Split v1.3.4
3
+ * RealChart Split v1.3.6
4
4
  * Copyright (C) 2023-2025 WooriTech Inc.
5
5
  * All Rights Reserved.
6
6
  */
package/split.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  /**
3
- * RealChart Split v1.3.4
3
+ * RealChart Split v1.3.6
4
4
  * Copyright (C) 2023-2025 WooriTech Inc.
5
5
  * All Rights Reserved.
6
6
  */
package/treemap.js CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  /**
3
- * RealChart Treemap v1.3.4
3
+ * RealChart Treemap v1.3.6
4
4
  * Copyright (C) 2023-2025 WooriTech Inc.
5
5
  * All Rights Reserved.
6
6
  */
7
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("realchart")):"function"==typeof define&&define.amd?define(["exports","realchart"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).RealChartTreemap={},e.RealChart)}(this,(function(e,t){"use strict";function i(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(i){if("default"!==i){var s=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,s.get?s:{enumerable:!0,get:function(){return e[i]}})}})),t.default=e,Object.freeze(t)}var s=i(t);class r extends t.DataPoint{_assignTo(e){return t.assignObj(super._assignTo(e),{id:this.id,group:this.group})}_readArray(e,i){if(i.length<=2)this.isNull=!0;else{const s=i.length>3?1:0;s>0&&(this.x=i[t.pickNum(e.options.xField,0)]),this.y=i[t.pickNum(e.options.yField,0+s)],this.id=t.toStr(i[t.pickNum(e.options.idField,1+s)]),this.group=t.toStr(i[t.pickNum(e.options.groupField,2+s)])}}_readObject(e,i){super._readObject(e,i),this.id=t.toStr(i[e.options.idField]),this.group=t.toStr(i[e.options.groupField])}}class h extends t.ChartItem{constructor(e){super(e.chart),this.level=e,this.floating=!0}}h.defaults=t.extend(t.ChartItem.defaults,{visible:!1});class o{constructor(e){this.point=e}level(){return this.parent?this.parent.level()+1:0}getArea(){return{x:this.x,y:this.y,width:this.width,height:this.height}}setArea(e,t,i,s){this.x=e,this.y=t,this.width=i,this.height=s}getTotal(){return this.children.reduce(((e,t)=>e+t.value),0)}}class n extends t.Series{constructor(){super(...arguments),this._map={},this._levels=1}buildMap(e,i){function s(e){if(e.children){let i=0;e.children.forEach(((e,t)=>{s(e),i+=e.value})),e.value=i,e.children=e.children.sort(((e,t)=>t.value-e.value)),e.children.forEach(((e,t)=>{e.index=t})),o=t.maxv(o,e.level()+1+1)}else h.push(e),e.value=e.point?e.point.yValue:0}const r="vertical"===this._op.startDir||i>e,h=this._leafs=[];let o=1;return this._roots.forEach(((e,t)=>{s(e)})),this._roots=this._roots.sort(((e,t)=>t.value-e.value)),this._roots.forEach(((e,t)=>{e.index=t})),(this[this._op.algorithm]||this.squarify).call(this,this._roots,e,i,r),this._levels=o,{roots:this._roots,leafs:this._leafs}}needAxes(){return!1}canMixWith(e){return!1}_createPoint(e){return new r(e)}_getLabeledPoints(){return this._leafs.map((e=>e.point))}_doPrepareRender(){super._doPrepareRender(),this._roots=this.$_buildTree(this._runPoints)}$_buildTree(e){const t=[],i=[],s=this._map;e.forEach((e=>{if(e.id||!e.isNull){const r=new o(e);e.id&&(s[e.id]=r),e.group?i.push(r):t.push(r)}}));for(let e=i.length-1;e>=0;e--){const r=i[e],h=s[r.point.group];(r.parent=h)?(h.children||(h.children=[]),h.children.push(r),r.children&&i.splice(e,1)):(t.push(r),i.splice(e,1))}return t}$_squarifyRow(e,i,s,r){const h=i.width*i.height,o=i.width,n=i.height;let l=i.x,a=i.y,d=Number.MAX_VALUE,u=0;const c=[];if(2===e.length){return(1===s?o>n:o>=n)?e.forEach((e=>{e.setArea(l,a,o*e.value/r,n),l+=e.width})):e.forEach((e=>{e.setArea(l,a,o,n*e.value/r),a+=e.height})),0}for(;e.length>0;){let p,g,f,_,w;if(p=e.shift(),u+=p.value,_=u*h/r,1===s?(g=_/n,f=n*p.value/u):(f=_/o,g=o*p.value/u),w=t.maxv(g/f,f/g),e.length>0&&w>d)return e.unshift(p),u-=p.value,_=h*u/r,1===s?(f=n,g=_/f):(g=o,f=_/g),c.forEach((e=>{1===s?(e.setArea(l,a,g,n*e.value/u),a+=e.height):(e.setArea(l,a,o*e.value/u,f),l+=e.width)})),1===s?(i.x+=g,i.width-=g):(i.y+=f,i.height-=f),r-u;if(0===e.length)return _=h*u/r,1===s?(f=n,g=_/f):(g=o,f=_/g),c.push(p),c.forEach((e=>{1===s?(e.setArea(l,a,g,n*e.value/u),a+=e.height):(e.setArea(l,a,o*e.value/u,f),l+=e.width)})),0;d=w,c.push(p)}}$_squarify(e,t,i,s){const r=e.slice(0);let h=i?1:0,o=e.reduce(((e,t)=>e+t.value),0);do{o=this.$_squarifyRow(r,t,h,o),s&&(h=1-h)}while(o>0);e.forEach((e=>{e.children&&this.$_squarify(e.children,e.getArea(),!i,!0)}))}squarify(e,t,i,s){this.$_squarify(e,{x:0,y:0,width:t,height:i},s,!0)}strip(e,t,i,s){this.$_squarify(e,{x:0,y:0,width:t,height:i},s,!1)}$_sliceNext(e,t,i,s){if(e.x=t.x,e.y=t.y,1===i){const i=t.height*e.value/s;e.width=t.width,e.height=i,t.y+=i,t.height-=i}else{const i=t.width*e.value/s;e.height=t.height,e.width=i,t.x+=i,t.width-=i}e.children&&this.$_slice(e.children,e.getArea(),0===i,!0)}$_slice(e,t,i,s){let r=e.reduce(((e,t)=>e+t.value),0),h=i?1:0;e.forEach((e=>{this.$_sliceNext(e,t,h,r),r-=e.value,s&&(h=1-h)}))}slice(e,t,i,s){this.$_slice(e,{x:0,y:0,width:t,height:i},s,!1)}sliceDice(e,t,i,s){this.$_slice(e,{x:0,y:0,width:t,height:i},s,!0)}}n.type=t.TreemapSeriesType,n.defaults=t.extend(t.ChartItem.defaults,{idField:"id",groupField:"group",algorithm:"squarify",alternate:!0,groupMode:!0});class l extends t.RectElement{constructor(e){super(e,t.SeriesView.POINT_CLASS)}get point(){return this.node.point}render(e){if(1!==e){const t=Object.assign({},this.node);t.width*=e,t.height*=e,t.x+=(this.node.width-t.width)/2,t.y+=(this.node.height-t.height)/2,this.setRect(t)}else this.setRect(this.node)}}class a extends t.SeriesView{constructor(e){super(e,"rct-treemap-series"),this._nodeViews=new t.ElementPool(this._pointContainer,l)}_lazyPrepareLabels(){return!0}_getPointPool(){return this._nodeViews}_prepareSeries(e,t){}_renderSeries(e,t){this._pointContainer.invert(this._inverted,t),this._rootView?this.$_renderGroups(e,t):this.$_renderLeafs(e,t)}_runShowEffect(e){e&&t.SeriesAnimation.grow(this)}_doViewRateChanged(e){this._rootView?this.$_renderGroups(this.width,this.height):this.$_renderLeafs(this.width,this.height)}$_renderLeafs(e,i){const s=this.model,r=s._xAxisObj,h=s._yAxisObj,o=this._inverted;s.pointLabel;const n=this._getGrowRate(),l=this._labelViews(),a=o?e:i,d=o?i:e,{roots:u,leafs:c}=s.buildMap(d,a),p=new t.Color(s._calcedColor),g=[{fill:""}];let f;null==l||l.prepare(this.doc,this);const _=this._labelContainer._textAlign;this._nodeViews.prepare(c.length,((e,i,u)=>{const w=c[i],y=w.point,x=w.parent;let v=p;x&&(!x._color&&x.point.color?v=x._color=new t.Color(x.point.color):x._color&&(v=x._color)),e.node=w,g[0].fill=v.brighten(w.index/u).toString(),this._setPointStyle(e,s,y,g),r.options.reversed&&(w.x=d-w.x-w.width),h.options.reversed&&(w.y=a-w.y-w.height),o&&(w.y=w.y-a),e.render(n);let b=w.x+w.width/2,m=w.y+w.height/2;if(y.xPos=o?-w.y-w.height/2:b,y.yPos=o?d-w.x-w.width/2:m,l&&(f=l.get(y,0))){f.setContrast(e.dom).layout(_);const t=f.getBBox();f.setVis(w.width>=t.height&&w.height>=t.height)&&(o?(b=-w.y-w.height/2-t.width/2,m=d-w.x-(w.width+t.height)/2):(b-=t.width/2,m-=t.height/2),f.trans(b,m))}}))}$_renderGroups(e,t){}}function d(e){(function(e){return e.Series&&e.SeriesView})(e)&&(e.Series.register(n),e.SeriesView.register([n,a]))}d(s),e.TreemapSeries=n,e.default=d,Object.defineProperty(e,"__esModule",{value:!0})}));
7
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("realchart")):"function"==typeof define&&define.amd?define(["exports","realchart"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).RealChartTreemap={},e.RealChart)}(this,(function(e,t){"use strict";function i(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(i){if("default"!==i){var s=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,s.get?s:{enumerable:!0,get:function(){return e[i]}})}})),t.default=e,Object.freeze(t)}var s=i(t);class r extends t.DataPoint{_assignTo(e){return t.assignObj(super._assignTo(e),{id:this.id,group:this.group})}_readArray(e,i){if(i.length<=2)this.isNull=!0;else{const s=i.length>3?1:0;s>0&&(this.x=i[t.pickNum(e.options.xField,0)]),this.y=i[t.pickNum(e.options.yField,0+s)],this.id=t.toStr(i[t.pickNum(e.options.idField,1+s)]),this.group=t.toStr(i[t.pickNum(e.options.groupField,2+s)])}}_readObject(e,i){super._readObject(e,i),this.id=t.toStr(i[e.options.idField]),this.group=t.toStr(i[e.options.groupField])}}class h extends t.ChartItem{constructor(e){super(e.chart),this.level=e,this.floating=!0}}h.defaults=t.extend(t.ChartItem.defaults,{visible:!1});class o{constructor(e){this.point=e}level(){return this.parent?this.parent.level()+1:0}getArea(){return{x:this.x,y:this.y,width:this.width,height:this.height}}setArea(e,t,i,s){this.x=e,this.y=t,this.width=i,this.height=s}getTotal(){return this.children.reduce(((e,t)=>e+t.value),0)}}class n extends t.Series{constructor(){super(...arguments),this._map={},this._levels=1}buildMap(e,i){function s(e){if(e.children){let i=0;e.children.forEach(((e,t)=>{s(e),i+=e.value})),e.value=i,e.children=e.children.sort(((e,t)=>t.value-e.value)),e.children.forEach(((e,t)=>{e.index=t})),o=t.maxv(o,e.level()+1+1)}else h.push(e),e.value=e.point?e.point.yValue:0}const r="vertical"===this._op.startDir||i>e,h=this._leafs=[];let o=1;return this._roots.forEach(((e,t)=>{s(e)})),this._roots=this._roots.sort(((e,t)=>t.value-e.value)),this._roots.forEach(((e,t)=>{e.index=t})),(this[this._op.algorithm]||this.squarify).call(this,this._roots,e,i,r),this._levels=o,{roots:this._roots,leafs:this._leafs}}needAxes(){return!1}canMixWith(e){return!1}_createPoint(e){return new r(e)}_getLabeledPoints(){return this._leafs.map((e=>e.point))}_doPrepareRender(){super._doPrepareRender(),this._roots=this.$_buildTree(this._runPoints)}$_buildTree(e){const t=[],i=[],s=this._map;e.forEach((e=>{if(e.id||!e.isNull){const r=new o(e);e.id&&(s[e.id]=r),e.group?i.push(r):t.push(r)}}));for(let e=i.length-1;e>=0;e--){const r=i[e],h=s[r.point.group];(r.parent=h)?(h.children||(h.children=[]),h.children.push(r),r.children&&i.splice(e,1)):(t.push(r),i.splice(e,1))}return t}$_squarifyRow(e,i,s,r){const h=i.width*i.height,o=i.width,n=i.height;let l=i.x,a=i.y,d=Number.MAX_VALUE,u=0;const c=[];if(2===e.length){return(1===s?o>n:o>=n)?e.forEach((e=>{e.setArea(l,a,o*e.value/r,n),l+=e.width})):e.forEach((e=>{e.setArea(l,a,o,n*e.value/r),a+=e.height})),0}for(;e.length>0;){let p,g,f,_,w;if(p=e.shift(),u+=p.value,_=u*h/r,1===s?(g=_/n,f=n*p.value/u):(f=_/o,g=o*p.value/u),w=t.maxv(g/f,f/g),e.length>0&&w>d)return e.unshift(p),u-=p.value,_=h*u/r,1===s?(f=n,g=_/f):(g=o,f=_/g),c.forEach((e=>{1===s?(e.setArea(l,a,g,n*e.value/u),a+=e.height):(e.setArea(l,a,o*e.value/u,f),l+=e.width)})),1===s?(i.x+=g,i.width-=g):(i.y+=f,i.height-=f),r-u;if(0===e.length)return _=h*u/r,1===s?(f=n,g=_/f):(g=o,f=_/g),c.push(p),c.forEach((e=>{1===s?(e.setArea(l,a,g,n*e.value/u),a+=e.height):(e.setArea(l,a,o*e.value/u,f),l+=e.width)})),0;d=w,c.push(p)}}$_squarify(e,t,i,s){const r=e.slice(0);let h=i?1:0,o=e.reduce(((e,t)=>e+t.value),0);do{o=this.$_squarifyRow(r,t,h,o),s&&(h=1-h)}while(o>0);e.forEach((e=>{e.children&&this.$_squarify(e.children,e.getArea(),!i,!0)}))}squarify(e,t,i,s){this.$_squarify(e,{x:0,y:0,width:t,height:i},s,!0)}strip(e,t,i,s){this.$_squarify(e,{x:0,y:0,width:t,height:i},s,!1)}$_sliceNext(e,t,i,s){if(e.x=t.x,e.y=t.y,1===i){const i=t.height*e.value/s;e.width=t.width,e.height=i,t.y+=i,t.height-=i}else{const i=t.width*e.value/s;e.height=t.height,e.width=i,t.x+=i,t.width-=i}e.children&&this.$_slice(e.children,e.getArea(),0===i,!0)}$_slice(e,t,i,s){let r=e.reduce(((e,t)=>e+t.value),0),h=i?1:0;e.forEach((e=>{this.$_sliceNext(e,t,h,r),r-=e.value,s&&(h=1-h)}))}slice(e,t,i,s){this.$_slice(e,{x:0,y:0,width:t,height:i},s,!1)}sliceDice(e,t,i,s){this.$_slice(e,{x:0,y:0,width:t,height:i},s,!0)}}n.type=t.TreemapSeriesType,n.defaults=t.extend(t.Series.defaults,{idField:"id",groupField:"group",algorithm:"squarify",alternate:!0,groupMode:!0});class l extends t.RectElement{constructor(e){super(e,t.SeriesView.POINT_CLASS)}get point(){return this.node.point}render(e){if(1!==e){const t=Object.assign({},this.node);t.width*=e,t.height*=e,t.x+=(this.node.width-t.width)/2,t.y+=(this.node.height-t.height)/2,this.setRect(t)}else this.setRect(this.node)}}class a extends t.SeriesView{constructor(e){super(e,"rct-treemap-series"),this._nodeViews=new t.ElementPool(this._pointContainer,l)}_lazyPrepareLabels(){return!0}_getPointPool(){return this._nodeViews}_prepareSeries(e,t){}_renderSeries(e,t){this._pointContainer.invert(this._inverted,t),this._rootView?this.$_renderGroups(e,t):this.$_renderLeafs(e,t)}_runShowEffect(e){e&&t.SeriesAnimation.grow(this)}_doViewRateChanged(e){this._rootView?this.$_renderGroups(this.width,this.height):this.$_renderLeafs(this.width,this.height)}$_renderLeafs(e,i){const s=this.model,r=s._xAxisObj,h=s._yAxisObj,o=this._inverted;s.pointLabel;const n=this._getGrowRate(),l=this._labelViews(),a=o?e:i,d=o?i:e,{roots:u,leafs:c}=s.buildMap(d,a),p=new t.Color(s._calcedColor),g=[{fill:""}];let f;null==l||l.prepare(this.doc,this);const _=this._labelContainer._textAlign;this._nodeViews.prepare(c.length,((e,i,u)=>{const w=c[i],y=w.point,x=w.parent;let v=p;x&&(!x._color&&x.point.color?v=x._color=new t.Color(x.point.color):x._color&&(v=x._color)),e.node=w,g[0].fill=v.brighten(w.index/u).toString(),this._setPointStyle(e,s,y,g),r.options.reversed&&(w.x=d-w.x-w.width),h.options.reversed&&(w.y=a-w.y-w.height),o&&(w.y=w.y-a),e.render(n);let b=w.x+w.width/2,m=w.y+w.height/2;if(y.xPos=o?-w.y-w.height/2:b,y.yPos=o?d-w.x-w.width/2:m,l&&(f=l.get(y,0))){f.setContrast(e.dom).layout(_);const t=f.getBBox();f.setVis(w.width>=t.height&&w.height>=t.height)&&(o?(b=-w.y-w.height/2-t.width/2,m=d-w.x-(w.width+t.height)/2):(b-=t.width/2,m-=t.height/2),f.trans(b,m))}}))}$_renderGroups(e,t){}}function d(e){(function(e){return e.Series&&e.SeriesView})(e)&&(e.Series.register(n),e.SeriesView.register([n,a]))}d(s),e.TreemapSeries=n,e.default=d,Object.defineProperty(e,"__esModule",{value:!0})}));
package/treemap.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  /**
3
- * RealChart Treemap v1.3.4
3
+ * RealChart Treemap v1.3.6
4
4
  * Copyright (C) 2023-2025 WooriTech Inc.
5
5
  * All Rights Reserved.
6
6
  */
7
- import{extend as e,ChartItem as t,TreemapSeriesType as i,Series as s,maxv as h,DataPoint as r,assignObj as o,pickNum as n,toStr as l,SeriesView as a,ElementPool as d,SeriesAnimation as u,Color as c,RectElement as p}from"./index.mjs";class _ extends r{_assignTo(e){return o(super._assignTo(e),{id:this.id,group:this.group})}_readArray(e,t){if(t.length<=2)this.isNull=!0;else{const i=t.length>3?1:0;i>0&&(this.x=t[n(e.options.xField,0)]),this.y=t[n(e.options.yField,0+i)],this.id=l(t[n(e.options.idField,1+i)]),this.group=l(t[n(e.options.groupField,2+i)])}}_readObject(e,t){super._readObject(e,t),this.id=l(t[e.options.idField]),this.group=l(t[e.options.groupField])}}(class extends t{constructor(e){super(e.chart),this.level=e,this.floating=!0}}).defaults=e(t.defaults,{visible:!1});class g{constructor(e){this.point=e}level(){return this.parent?this.parent.level()+1:0}getArea(){return{x:this.x,y:this.y,width:this.width,height:this.height}}setArea(e,t,i,s){this.x=e,this.y=t,this.width=i,this.height=s}getTotal(){return this.children.reduce(((e,t)=>e+t.value),0)}}class f extends s{constructor(){super(...arguments),this._map={},this._levels=1}buildMap(e,t){function i(e){if(e.children){let t=0;e.children.forEach(((e,s)=>{i(e),t+=e.value})),e.value=t,e.children=e.children.sort(((e,t)=>t.value-e.value)),e.children.forEach(((e,t)=>{e.index=t})),o=h(o,e.level()+1+1)}else r.push(e),e.value=e.point?e.point.yValue:0}const s="vertical"===this._op.startDir||t>e,r=this._leafs=[];let o=1;return this._roots.forEach(((e,t)=>{i(e)})),this._roots=this._roots.sort(((e,t)=>t.value-e.value)),this._roots.forEach(((e,t)=>{e.index=t})),(this[this._op.algorithm]||this.squarify).call(this,this._roots,e,t,s),this._levels=o,{roots:this._roots,leafs:this._leafs}}needAxes(){return!1}canMixWith(e){return!1}_createPoint(e){return new _(e)}_getLabeledPoints(){return this._leafs.map((e=>e.point))}_doPrepareRender(){super._doPrepareRender(),this._roots=this.$_buildTree(this._runPoints)}$_buildTree(e){const t=[],i=[],s=this._map;e.forEach((e=>{if(e.id||!e.isNull){const h=new g(e);e.id&&(s[e.id]=h),e.group?i.push(h):t.push(h)}}));for(let e=i.length-1;e>=0;e--){const h=i[e],r=s[h.point.group];(h.parent=r)?(r.children||(r.children=[]),r.children.push(h),h.children&&i.splice(e,1)):(t.push(h),i.splice(e,1))}return t}$_squarifyRow(e,t,i,s){const r=t.width*t.height,o=t.width,n=t.height;let l=t.x,a=t.y,d=Number.MAX_VALUE,u=0;const c=[];if(2===e.length){return(1===i?o>n:o>=n)?e.forEach((e=>{e.setArea(l,a,o*e.value/s,n),l+=e.width})):e.forEach((e=>{e.setArea(l,a,o,n*e.value/s),a+=e.height})),0}for(;e.length>0;){let p,_,g,f,w;if(p=e.shift(),u+=p.value,f=u*r/s,1===i?(_=f/n,g=n*p.value/u):(g=f/o,_=o*p.value/u),w=h(_/g,g/_),e.length>0&&w>d)return e.unshift(p),u-=p.value,f=r*u/s,1===i?(g=n,_=f/g):(_=o,g=f/_),c.forEach((e=>{1===i?(e.setArea(l,a,_,n*e.value/u),a+=e.height):(e.setArea(l,a,o*e.value/u,g),l+=e.width)})),1===i?(t.x+=_,t.width-=_):(t.y+=g,t.height-=g),s-u;if(0===e.length)return f=r*u/s,1===i?(g=n,_=f/g):(_=o,g=f/_),c.push(p),c.forEach((e=>{1===i?(e.setArea(l,a,_,n*e.value/u),a+=e.height):(e.setArea(l,a,o*e.value/u,g),l+=e.width)})),0;d=w,c.push(p)}}$_squarify(e,t,i,s){const h=e.slice(0);let r=i?1:0,o=e.reduce(((e,t)=>e+t.value),0);do{o=this.$_squarifyRow(h,t,r,o),s&&(r=1-r)}while(o>0);e.forEach((e=>{e.children&&this.$_squarify(e.children,e.getArea(),!i,!0)}))}squarify(e,t,i,s){this.$_squarify(e,{x:0,y:0,width:t,height:i},s,!0)}strip(e,t,i,s){this.$_squarify(e,{x:0,y:0,width:t,height:i},s,!1)}$_sliceNext(e,t,i,s){if(e.x=t.x,e.y=t.y,1===i){const i=t.height*e.value/s;e.width=t.width,e.height=i,t.y+=i,t.height-=i}else{const i=t.width*e.value/s;e.height=t.height,e.width=i,t.x+=i,t.width-=i}e.children&&this.$_slice(e.children,e.getArea(),0===i,!0)}$_slice(e,t,i,s){let h=e.reduce(((e,t)=>e+t.value),0),r=i?1:0;e.forEach((e=>{this.$_sliceNext(e,t,r,h),h-=e.value,s&&(r=1-r)}))}slice(e,t,i,s){this.$_slice(e,{x:0,y:0,width:t,height:i},s,!1)}sliceDice(e,t,i,s){this.$_slice(e,{x:0,y:0,width:t,height:i},s,!0)}}f.type=i,f.defaults=e(t.defaults,{idField:"id",groupField:"group",algorithm:"squarify",alternate:!0,groupMode:!0});class w extends p{constructor(e){super(e,a.POINT_CLASS)}get point(){return this.node.point}render(e){if(1!==e){const t=Object.assign({},this.node);t.width*=e,t.height*=e,t.x+=(this.node.width-t.width)/2,t.y+=(this.node.height-t.height)/2,this.setRect(t)}else this.setRect(this.node)}}class x extends a{constructor(e){super(e,"rct-treemap-series"),this._nodeViews=new d(this._pointContainer,w)}_lazyPrepareLabels(){return!0}_getPointPool(){return this._nodeViews}_prepareSeries(e,t){}_renderSeries(e,t){this._pointContainer.invert(this._inverted,t),this._rootView?this.$_renderGroups(e,t):this.$_renderLeafs(e,t)}_runShowEffect(e){e&&u.grow(this)}_doViewRateChanged(e){this._rootView?this.$_renderGroups(this.width,this.height):this.$_renderLeafs(this.width,this.height)}$_renderLeafs(e,t){const i=this.model,s=i._xAxisObj,h=i._yAxisObj,r=this._inverted;i.pointLabel;const o=this._getGrowRate(),n=this._labelViews(),l=r?e:t,a=r?t:e,{roots:d,leafs:u}=i.buildMap(a,l),p=new c(i._calcedColor),_=[{fill:""}];let g;null==n||n.prepare(this.doc,this);const f=this._labelContainer._textAlign;this._nodeViews.prepare(u.length,((e,t,d)=>{const w=u[t],x=w.point,y=w.parent;let v=p;y&&(!y._color&&y.point.color?v=y._color=new c(y.point.color):y._color&&(v=y._color)),e.node=w,_[0].fill=v.brighten(w.index/d).toString(),this._setPointStyle(e,i,x,_),s.options.reversed&&(w.x=a-w.x-w.width),h.options.reversed&&(w.y=l-w.y-w.height),r&&(w.y=w.y-l),e.render(o);let $=w.x+w.width/2,A=w.y+w.height/2;if(x.xPos=r?-w.y-w.height/2:$,x.yPos=r?a-w.x-w.width/2:A,n&&(g=n.get(x,0))){g.setContrast(e.dom).layout(f);const t=g.getBBox();g.setVis(w.width>=t.height&&w.height>=t.height)&&(r?($=-w.y-w.height/2-t.width/2,A=a-w.x-(w.width+t.height)/2):($-=t.width/2,A-=t.height/2),g.trans($,A))}}))}$_renderGroups(e,t){}}function y(e){(function(e){return e.Series&&e.SeriesView})(e)&&(e.Series.register(f),e.SeriesView.register([f,x]))}export{f as TreemapSeries,y as default};
7
+ import{extend as e,ChartItem as t,TreemapSeriesType as i,Series as s,maxv as h,DataPoint as r,assignObj as o,pickNum as n,toStr as l,SeriesView as a,ElementPool as d,SeriesAnimation as u,Color as c,RectElement as p}from"./index.mjs";class _ extends r{_assignTo(e){return o(super._assignTo(e),{id:this.id,group:this.group})}_readArray(e,t){if(t.length<=2)this.isNull=!0;else{const i=t.length>3?1:0;i>0&&(this.x=t[n(e.options.xField,0)]),this.y=t[n(e.options.yField,0+i)],this.id=l(t[n(e.options.idField,1+i)]),this.group=l(t[n(e.options.groupField,2+i)])}}_readObject(e,t){super._readObject(e,t),this.id=l(t[e.options.idField]),this.group=l(t[e.options.groupField])}}(class extends t{constructor(e){super(e.chart),this.level=e,this.floating=!0}}).defaults=e(t.defaults,{visible:!1});class g{constructor(e){this.point=e}level(){return this.parent?this.parent.level()+1:0}getArea(){return{x:this.x,y:this.y,width:this.width,height:this.height}}setArea(e,t,i,s){this.x=e,this.y=t,this.width=i,this.height=s}getTotal(){return this.children.reduce(((e,t)=>e+t.value),0)}}class f extends s{constructor(){super(...arguments),this._map={},this._levels=1}buildMap(e,t){function i(e){if(e.children){let t=0;e.children.forEach(((e,s)=>{i(e),t+=e.value})),e.value=t,e.children=e.children.sort(((e,t)=>t.value-e.value)),e.children.forEach(((e,t)=>{e.index=t})),o=h(o,e.level()+1+1)}else r.push(e),e.value=e.point?e.point.yValue:0}const s="vertical"===this._op.startDir||t>e,r=this._leafs=[];let o=1;return this._roots.forEach(((e,t)=>{i(e)})),this._roots=this._roots.sort(((e,t)=>t.value-e.value)),this._roots.forEach(((e,t)=>{e.index=t})),(this[this._op.algorithm]||this.squarify).call(this,this._roots,e,t,s),this._levels=o,{roots:this._roots,leafs:this._leafs}}needAxes(){return!1}canMixWith(e){return!1}_createPoint(e){return new _(e)}_getLabeledPoints(){return this._leafs.map((e=>e.point))}_doPrepareRender(){super._doPrepareRender(),this._roots=this.$_buildTree(this._runPoints)}$_buildTree(e){const t=[],i=[],s=this._map;e.forEach((e=>{if(e.id||!e.isNull){const h=new g(e);e.id&&(s[e.id]=h),e.group?i.push(h):t.push(h)}}));for(let e=i.length-1;e>=0;e--){const h=i[e],r=s[h.point.group];(h.parent=r)?(r.children||(r.children=[]),r.children.push(h),h.children&&i.splice(e,1)):(t.push(h),i.splice(e,1))}return t}$_squarifyRow(e,t,i,s){const r=t.width*t.height,o=t.width,n=t.height;let l=t.x,a=t.y,d=Number.MAX_VALUE,u=0;const c=[];if(2===e.length){return(1===i?o>n:o>=n)?e.forEach((e=>{e.setArea(l,a,o*e.value/s,n),l+=e.width})):e.forEach((e=>{e.setArea(l,a,o,n*e.value/s),a+=e.height})),0}for(;e.length>0;){let p,_,g,f,w;if(p=e.shift(),u+=p.value,f=u*r/s,1===i?(_=f/n,g=n*p.value/u):(g=f/o,_=o*p.value/u),w=h(_/g,g/_),e.length>0&&w>d)return e.unshift(p),u-=p.value,f=r*u/s,1===i?(g=n,_=f/g):(_=o,g=f/_),c.forEach((e=>{1===i?(e.setArea(l,a,_,n*e.value/u),a+=e.height):(e.setArea(l,a,o*e.value/u,g),l+=e.width)})),1===i?(t.x+=_,t.width-=_):(t.y+=g,t.height-=g),s-u;if(0===e.length)return f=r*u/s,1===i?(g=n,_=f/g):(_=o,g=f/_),c.push(p),c.forEach((e=>{1===i?(e.setArea(l,a,_,n*e.value/u),a+=e.height):(e.setArea(l,a,o*e.value/u,g),l+=e.width)})),0;d=w,c.push(p)}}$_squarify(e,t,i,s){const h=e.slice(0);let r=i?1:0,o=e.reduce(((e,t)=>e+t.value),0);do{o=this.$_squarifyRow(h,t,r,o),s&&(r=1-r)}while(o>0);e.forEach((e=>{e.children&&this.$_squarify(e.children,e.getArea(),!i,!0)}))}squarify(e,t,i,s){this.$_squarify(e,{x:0,y:0,width:t,height:i},s,!0)}strip(e,t,i,s){this.$_squarify(e,{x:0,y:0,width:t,height:i},s,!1)}$_sliceNext(e,t,i,s){if(e.x=t.x,e.y=t.y,1===i){const i=t.height*e.value/s;e.width=t.width,e.height=i,t.y+=i,t.height-=i}else{const i=t.width*e.value/s;e.height=t.height,e.width=i,t.x+=i,t.width-=i}e.children&&this.$_slice(e.children,e.getArea(),0===i,!0)}$_slice(e,t,i,s){let h=e.reduce(((e,t)=>e+t.value),0),r=i?1:0;e.forEach((e=>{this.$_sliceNext(e,t,r,h),h-=e.value,s&&(r=1-r)}))}slice(e,t,i,s){this.$_slice(e,{x:0,y:0,width:t,height:i},s,!1)}sliceDice(e,t,i,s){this.$_slice(e,{x:0,y:0,width:t,height:i},s,!0)}}f.type=i,f.defaults=e(s.defaults,{idField:"id",groupField:"group",algorithm:"squarify",alternate:!0,groupMode:!0});class w extends p{constructor(e){super(e,a.POINT_CLASS)}get point(){return this.node.point}render(e){if(1!==e){const t=Object.assign({},this.node);t.width*=e,t.height*=e,t.x+=(this.node.width-t.width)/2,t.y+=(this.node.height-t.height)/2,this.setRect(t)}else this.setRect(this.node)}}class x extends a{constructor(e){super(e,"rct-treemap-series"),this._nodeViews=new d(this._pointContainer,w)}_lazyPrepareLabels(){return!0}_getPointPool(){return this._nodeViews}_prepareSeries(e,t){}_renderSeries(e,t){this._pointContainer.invert(this._inverted,t),this._rootView?this.$_renderGroups(e,t):this.$_renderLeafs(e,t)}_runShowEffect(e){e&&u.grow(this)}_doViewRateChanged(e){this._rootView?this.$_renderGroups(this.width,this.height):this.$_renderLeafs(this.width,this.height)}$_renderLeafs(e,t){const i=this.model,s=i._xAxisObj,h=i._yAxisObj,r=this._inverted;i.pointLabel;const o=this._getGrowRate(),n=this._labelViews(),l=r?e:t,a=r?t:e,{roots:d,leafs:u}=i.buildMap(a,l),p=new c(i._calcedColor),_=[{fill:""}];let g;null==n||n.prepare(this.doc,this);const f=this._labelContainer._textAlign;this._nodeViews.prepare(u.length,((e,t,d)=>{const w=u[t],x=w.point,y=w.parent;let v=p;y&&(!y._color&&y.point.color?v=y._color=new c(y.point.color):y._color&&(v=y._color)),e.node=w,_[0].fill=v.brighten(w.index/d).toString(),this._setPointStyle(e,i,x,_),s.options.reversed&&(w.x=a-w.x-w.width),h.options.reversed&&(w.y=l-w.y-w.height),r&&(w.y=w.y-l),e.render(o);let $=w.x+w.width/2,A=w.y+w.height/2;if(x.xPos=r?-w.y-w.height/2:$,x.yPos=r?a-w.x-w.width/2:A,n&&(g=n.get(x,0))){g.setContrast(e.dom).layout(f);const t=g.getBBox();g.setVis(w.width>=t.height&&w.height>=t.height)&&(r?($=-w.y-w.height/2-t.width/2,A=a-w.x-(w.width+t.height)/2):($-=t.width/2,A-=t.height/2),g.trans($,A))}}))}$_renderGroups(e,t){}}function y(e){(function(e){return e.Series&&e.SeriesView})(e)&&(e.Series.register(f),e.SeriesView.register([f,x]))}export{f as TreemapSeries,y as default};
package/vector.js CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  /**
3
- * RealChart Vector v1.3.4
3
+ * RealChart Vector v1.3.6
4
4
  * Copyright (C) 2023-2025 WooriTech Inc.
5
5
  * All Rights Reserved.
6
6
  */
package/vector.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  /**
3
- * RealChart Vector v1.3.4
3
+ * RealChart Vector v1.3.6
4
4
  * Copyright (C) 2023-2025 WooriTech Inc.
5
5
  * All Rights Reserved.
6
6
  */
package/wordcloud.js CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  /**
3
- * RealChart Wordcloud v1.3.4
3
+ * RealChart Wordcloud v1.3.6
4
4
  * Copyright (C) 2023-2025 WooriTech Inc.
5
5
  * All Rights Reserved.
6
6
  */
7
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("realchart")):"function"==typeof define&&define.amd?define(["exports","realchart"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).RealChartWordCloud={},t.RealChart)}(this,(function(t,e){"use strict";function i(t){var e=Object.create(null);return t&&Object.keys(t).forEach((function(i){if("default"!==i){var s=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:function(){return t[i]}})}})),e.default=t,Object.freeze(e)}var s=i(e);class n extends e.WidgetSeriesPoint{}class o extends e.WidgetSeries{$_denormalizeFontSize(t,i,s){let n,r;return"min"==t?(n=e.calcPercent(e.parsePercentSize(o.MinFontSize,!1),i),r=e.calcPercent(e.parsePercentSize(o.MaxMinFontSize,!1),i)):(n=e.calcPercent(e.parsePercentSize(o.MinMaxFontSize,!1),i),r=e.calcPercent(e.parsePercentSize(o.MaxFontSize,!1),i)),s>1?r:s<0?n:s*(r-n)+n}calcFontRatio(t,i,s,n){return e.calcPercent(i,s,n)}getMinFontSize(t,i){const{fixed:s,size:n}=this._minFontSizeDim,r=s&&n<=1?this.$_denormalizeFontSize("min",t,n):e.calcPercent(this._minFontSizeDim,t,i);return Math.max(e.calcPercent(e.parsePercentSize(o.MinFontSize,!1),t),r)}getMaxFontSize(t,i){const{fixed:s,size:n}=this._maxFontSizeDim,r=s&&n<=1?this.$_denormalizeFontSize("max",t,n):e.calcPercent(this._maxFontSizeDim,t,i);return Math.min(e.calcPercent(e.parsePercentSize(o.MaxFontSize,!1),t),r)}getLogFunc(){const t=this._op.logBase;return t>=2?function(e){return Math.max(Math.log(e)/Math.log(t))}:function(t){return t}}_colorByPoint(){return this._op.colorByPoint}_createPoint(t){return new n(t)}_doApply(t){var i;super._doApply(t),(t.text!==this._text||e.Utils.equalArrays(this._excludes,t.excludes))&&(this._text=t.text,this._excludes=null===(i=t.excludes)||void 0===i?void 0:i.slice(),this._dataSourceDirty=!0),this._setDims(t,"minFontSize","maxFontSize")}_doLoadPoints(t){const i=this._op,s=i.text;let n=[];if(s){const t=Math.max(i.minLength||1,1),e={};let o=i.excludes,r=s.split(/\s+/g);Array.isArray(o)&&o.length>0&&(r=r.filter((t=>o.indexOf(t)<0))),r.forEach((i=>{i.length>=t&&(i in e?e[i]++:e[i]=1)}));for(const t in e)n.push({x:t,y:e[t]});n=n.sort(((t,e)=>e.y-t.y))}else if(Array.isArray(t)&&!(t.length>0&&"object"==typeof t[0]&&null!==t[0]))for(let i=0;i<t.length;i+=2)n.push({x:e.toStr(t[i]),y:t[i+1]||0});n.length>0&&(t=n),super._doLoadPoints(t)}isPointLabelVisible(t){return!1}_prepareRender(){super._prepareRender(),this.pointValuesPrepared(null),this.collectValues(null,null),this.collectRanges(null)}}o.type=e.WordCloudSeriesType,o.MinFontSize=8,o.MaxMinFontSize=15,o.MaxFontSize="15%",o.MinMaxFontSize="5%",o.defaults=e.extend(e.WidgetSeries.defaults,{frame:"rectangle",maxCount:100,maxFontSize:1,minFontSize:0,colorByPoint:!0,autoScale:!0});const r=Math.floor;class a{constructor(t){this._options=t}start(t,i,s,n,o,r){this._container=t;const a="circle"===s.frame||"ellipse"===s.frame,h=s.autoScale,l=e.pickNum(s.seed,0)*Math.PI*2/360,c=Math.max(0,e.pickNum(s.wordGap,0));let d=n,u=0,_=o,x=0,p=0;this.$_prepare(s,n,o),this._unit,i.forEach((t=>{const e=t.point;if(this.$_findPos(t,a,s.shuffle,this._radius,l,c)){const{x:i,y:s,width:n,height:o}=t.box.bounds;this.$_placeWord(t),e.xPos=i+n/2,e.yPos=s,d=Math.min(d,i),u=Math.max(u,i+n),_=Math.min(_,s),x=Math.max(x,s+o),p++}else t.setVis(!1)})),e.Utils.log("Words placed.",p,"of",i.length);const m=u-d,f=x-_,g=n/2,y=o/2,M=h?1/(Math.max(m/n,f/o)+.02):1,P=~~((d+m/2-g)*M),w=~~((_+f/2-y)*M);return this._trans={x:P,y:w,cx:g,cy:y,rate:M},i.forEach((t=>{const e=t.point;e.xPos=g-P+(e.xPos-g)*M,e.yPos=y-w+(e.yPos-y)*M})),this.$_transform(),null==r||r(i),this}stop(){}$_transform(t=1){let{x:e,y:i,cx:s,cy:n,rate:o}=this._trans;e=~~(e*t),i=~~(i*t),this._container.dom.setAttribute("transform-origin",`${s} ${n}`),this._container.trans(-e,-i),this._container.scale(o*t)}$_prepare(t,e,i){const s=this._unit=8;this._grid=[],this._cols=r(e/s),this._rows=r(i/s),this._radius=r(Math.sqrt(this._cols*this._cols+this._rows*this._rows)/2);const n=2*this._radius;this._center={c:this._radius,r:this._radius};for(let t=0;t<n;t++)this._grid.push([]);this._rdPoints=[],this._ellipticity="ellipse"===t.frame||"rectangle"===t.frame?i/e:1}$_isOverlapping(t){const e=this._grid;for(let i=t.r1;i<=t.r2;i++)for(let s=t.c1;s<=t.c2;s++)if(e[i]||(e[i]=[]),e[i][s])return!0;return!1}$_placeWord(t){const e=this._grid,i=t.box;for(let s=i.r1;s<=i.r2;s++)for(let n=i.c1;n<=i.c2;n++)e[s][n]=t}$_getPoints(t,e,i){if(this._rdPoints[t])return this._rdPoints[t];const s=this._center,n=this._ellipticity,o=t*this._unit;let r=0,a=[];for(0===t&&a.push([s.c,s.r]);r<o;){const h=r/o*2*Math.PI+i;let l=t*Math.cos(h)/n,c=t*Math.sin(h);if(!e){const t=Math.max(Math.abs(Math.cos(h)),Math.abs(Math.sin(h)));l/=t,c/=t}a.push([~~(s.c+l),~~(s.r+c)]),r++}return this._rdPoints[t]=a}$_rotatePoint(t,e,i){const s=e*Math.PI/180,n=Math.cos(s),o=Math.sin(s),{x:r,y:a,width:h,height:l}=t,c=r+h,d=a+l,u=r+h/2,_=a+l/2,x=[{x:r,y:a},{x:c,y:a},{x:r,y:d},{x:c,y:d}].map((t=>({x:u+(t.x-u)*n-(t.y-_)*o,y:_+(t.x-u)*o+(t.y-_)*n}))),p=Math.min(...x.map((t=>t.x))),m=Math.min(...x.map((t=>t.y))),f=Math.max(...x.map((t=>t.x))),g=Math.max(...x.map((t=>t.y))),y=this._unit,M=f-p,P=g-m;return{c1:Math.max(0,~~(p/y)),r1:Math.max(0,~~(m/y)),c2:~~(f/y),r2:~~(g/y)+i,bounds:{x:p,y:m,width:M,height:P}}}$_getBox(t,e,i,s,n=0){const o=this._unit,{width:r}=t.getBBox(),a=t.hText,h=r/o,l=a/o,c=Math.ceil(h/2),d=Math.ceil(l/2),u=Math.max(0,e-c),_=Math.max(0,i-d),x=u+Math.ceil(h),p=_+Math.ceil(l),m={x:(e-c)*o,y:(i-d)*o,width:r,height:a};return n?this.$_rotatePoint(m,n,s):{c1:u,r1:_,c2:x+s,r2:p,bounds:m}}$_drawDebugBox(t,i){const{doc:s}=this._container,{x:n,y:o,width:r,height:a}=t.bounds,h=e.RectElement.create(s,"",n,o,r,a);h.setFill((null==i?void 0:i.fill)||"#ff000055"),h.setStroke((null==i?void 0:i.stroke)||"none"),h.setAttr("stroke-dasharray",(null==i?void 0:i.strokeDashArray)||"4"),this._container.add(h)}$_findPos(t,i,s,n,o,r){let a=0,h=0;n=Math.max(n,this._grid.length+1);const l=[0,-90],c=l.length;for(;a<n;){const n=this.$_getPoints(a,i,o+h++%4*(Math.PI/4));s&&e.Utils.shuffle(n);if(n.some(((i,s)=>{let n=this._options.rotation?l[~~(e.Utils.randomLike(s+o)*c)]:0;const a=this.$_getBox(t,i[0],i[1],r,n);if(!this.$_isOverlapping(a)){if(a.bounds.x<0||a.bounds.y<0)return!1;const e=this.$_getBox(t,i[0],i[1],r),{bounds:s}=e,o={x:s.width/2,y:s.height/2};return t.wx=s.x,t.wy=s.y,t.setRotation(o.x,o.y,n),t.box=a,!0}})))return!0;a++}}}class h extends a{$_findPos(t,e,i,s,n,o){if(this.$_getPoints(s,e,i?Math.random()*Math.PI*2:n).some((e=>{const i=this.$_getBox(t,e[0],e[1],o);if(!this.$_isOverlapping(i))return t.box=i,!0})))return!0}$_getPoints(t,e,i){const s=this._center,n=this._ellipticity,o=2*t*this._unit;let r=-1,a=[];0===t&&a.push([s.c,s.r]);const h=i>Math.PI?1:-1;if(e)for(;++r<o;){const e=r/o,l=i+r*e*h,c=t*e,d=c*Math.cos(l)/n,u=c*Math.sin(l),_=s.c+d,x=s.r+u;a.push([~~_,~~x])}else{let e=this._unit>>1,o=e/n,l=s.c+o*Math.cos(i),c=s.r+e*Math.sin(i);const d=Math.max(1,this._unit>>1),u=d-Math.max(1,d>>1),_=.99;for(;++r>=0;){e=1+u*Math.pow(_,r),o=e/n;switch(3&(h*Math.sqrt(1+8*r)-1)/2){case 0:l+=o;break;case 1:c+=e;break;case 2:l-=o;break;default:c-=e}if(Math.max(Math.abs(l-t),Math.abs(c-t))>t)break;a.push([~~l,~~c])}}return a}$_getBox(t,e,i,s){const n=this._unit,o=t.getBBox(),a=t.hText,h=Math.min(2*this._radius,Math.max(0,e-r(o.width/2/n))),l=Math.min(2*this._radius,Math.max(0,i-r(a/2/n)));return{c1:h,r1:l,c2:h+r(o.width/n)+s,r2:l+r(a/n),w:t.width,h:a}}}class l extends e.RcElement{constructor(t){super(t,e.SeriesView.POINT_CLASS),this.add(this.hintView=new e.RectElement(t)),this.hintView.setStyles({stroke:"none",fill:"transparent"}),this.add(this.textView=new e.TextElement(t)),this.textView.setStyle("pointerEvents","none")}layout(){const t=this.getBBox();this.hintView.setRect({x:0,y:this.yText*l.TOP_PAD,width:t.width,height:this.hText-this.yText}),this.textView.transY(-this.yText*l.TOP_PAD)}}l.TOP_PAD=.5;class c extends e.WidgetSeriesView{constructor(t){super(t,"rct-wordcloud-series"),this._pointContainer.add(this._wordContainer=new e.LayerElement(t,null)),this._words=new e.ElementPool(this._wordContainer,l)}_getPointPool(){return this._words}needFronting(){return!1}isEmptyView(){return this._empty}_renderSeries(t,i){const s=this.model.options,n=s.text;if(t!==this._wSave||i!==this._hSave||n!==this._tSave){const o=+new Date;let r=this._visPoints.slice();if(s.minWeight>0&&(r=r.filter((t=>t.yValue>=s.minWeight))),s.minLength>1&&(r=r.filter((t=>t.x.length>=s.minLength))),s.maxCount<r.length&&(r.length=Math.max(0,s.maxCount)),this.$_prepareWords(this.doc,this.model,r),"spiral"===s.placer)this._placer=new h(s).start(this._wordContainer,this._words._internalItems(),s,t,i,(e=>{this.$_layoutWords(t,i)}));else this._placer=new a(s).start(this._wordContainer,this._words._internalItems(),s,t,i,(e=>{this.$_layoutWords(t,i)}));this._wSave=t,this._hSave=i,this._tSave=n,this._empty=r.length<1,e.Utils.log(r.length+" words placed in "+(+new Date-o)+"ms.")}else this.$_layoutWords(t,i)}_runShowEffect(t){t&&e.SeriesAnimation.spread(this,(()=>{}))}_doPosRateChanged(t){this.$_layoutWords(this.width,this.height)}$_prepareWords(t,i,s){const n=i._minY,o=i._maxY,r=o-n,a=this.height,h=i.getMaxFontSize(a,1);let c=Math.min(h,i.getMinFontSize(a,0));const d=n===o||c===h,u=d?NaN:i.options.logBase,_=getComputedStyle(this._wordContainer.dom).fontFamily,x=Math.min(2,Math.max(.1,+i.options.textHeight)),p=isNaN(x)?t.createElement("canvas").getContext("2d"):null,m=1-l.TOP_PAD;let f;this._words.prepare(s.length,((o,a)=>{const l=o.point=s[a],g=o.textView;let y=(l.y-n)/r;u>1&&(y=1-(Math.pow(u,1-y)-1)/(u-1));let M=c+(d?(h-c)/2:y*(h-c));const P=l.x;this._preparePoint(t,i,l,o),delete o.box,g.text=P,g.anchor=e.TextAnchor.START,g.setStyles({fontSize:e.pixel(M)}),g.layoutText(),p?(p.font=`${e.pixel(M)} ${_}`,f=p.measureText(P),o.yText=.9*Math.max(0,f.fontBoundingBoxAscent-f.actualBoundingBoxAscent),o.hText=Math.ceil((f.actualBoundingBoxAscent+f.actualBoundingBoxDescent)*(M<=10?1.1:1.08)-.1)+o.yText*m):(o.yText=0,o.hText=o.getBBox().height*x),o.layout(),o.setVis(!0)}))}$_layoutWords(t,e){var i;let s=this._getPosRate();null===(i=this._placer)||void 0===i||i.$_transform(s),s=1-s,this._words.forEach((i=>{const{bounds:n}=i.box,o=n.width,r=n.height,a=(t-o)/2;let h=(e-r)/2;i.trans(i.wx-(i.wx-a)*s,i.wy-(i.wy-h)*s)}))}}function d(t){(function(t){return t.Series&&t.SeriesView})(t)&&(t.Series.register(o),t.SeriesView.register([o,c]))}d(s),t.WordCloudSeries=o,t.default=d,Object.defineProperty(t,"__esModule",{value:!0})}));
7
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("realchart")):"function"==typeof define&&define.amd?define(["exports","realchart"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).RealChartWordCloud={},t.RealChart)}(this,(function(t,e){"use strict";function i(t){var e=Object.create(null);return t&&Object.keys(t).forEach((function(i){if("default"!==i){var s=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:function(){return t[i]}})}})),e.default=t,Object.freeze(e)}var s=i(e);class n extends e.WidgetSeriesPoint{}class o extends e.WidgetSeries{$_denormalizeFontSize(t,i,s){let n,r;return"min"==t?(n=e.calcPercent(e.parsePercentSize(o.MinFontSize,!1),i),r=e.calcPercent(e.parsePercentSize(o.MaxMinFontSize,!1),i)):(n=e.calcPercent(e.parsePercentSize(o.MinMaxFontSize,!1),i),r=e.calcPercent(e.parsePercentSize(o.MaxFontSize,!1),i)),s>1?r:s<0?n:s*(r-n)+n}calcFontRatio(t,i,s,n){return e.calcPercent(i,s,n)}getMinFontSize(t,i){const{fixed:s,size:n}=this._minFontSizeDim,r=s&&n<=1?this.$_denormalizeFontSize("min",t,n):e.calcPercent(this._minFontSizeDim,t,i);return Math.max(e.calcPercent(e.parsePercentSize(o.MinFontSize,!1),t),r)}getMaxFontSize(t,i){const{fixed:s,size:n}=this._maxFontSizeDim,r=s&&n<=1?this.$_denormalizeFontSize("max",t,n):e.calcPercent(this._maxFontSizeDim,t,i);return Math.min(e.calcPercent(e.parsePercentSize(o.MaxFontSize,!1),t),r)}getLogFunc(){const t=this._op.logBase;return t>=2?function(e){return Math.max(Math.log(e)/Math.log(t))}:function(t){return t}}_colorByPoint(){return this._op.colorByPoint}_createPoint(t){return new n(t)}_doApply(t){var i;super._doApply(t),(t.text!==this._text||e.Utils.equalArrays(this._excludes,t.excludes))&&(this._text=t.text,this._excludes=null===(i=t.excludes)||void 0===i?void 0:i.slice(),this._dataSourceDirty=!0),this._setDims(t,"minFontSize","maxFontSize")}_doLoadPoints(t){const i=this._op,s=i.text;let n=[];if(s){const t=Math.max(i.minLength||1,1),e={};let o=i.excludes,r=s.split(/\s+/g);Array.isArray(o)&&o.length>0&&(r=r.filter((t=>o.indexOf(t)<0))),r.forEach((i=>{i.length>=t&&(i in e?e[i]++:e[i]=1)}));for(const t in e)n.push({x:t,y:e[t]})}else if(Array.isArray(t)&&!(t.length>0&&"object"==typeof t[0]&&null!==t[0]))for(let i=0;i<t.length;i+=2)n.push({x:e.toStr(t[i]),y:t[i+1]||0});n.length>0&&(t=n.sort(((t,e)=>e.y-t.y))),super._doLoadPoints(t)}isPointLabelVisible(t){return!1}_prepareRender(){super._prepareRender(),this.pointValuesPrepared(null),this.collectValues(null,null),this.collectRanges(null)}}o.type=e.WordCloudSeriesType,o.MinFontSize=8,o.MaxMinFontSize=15,o.MaxFontSize="15%",o.MinMaxFontSize="5%",o.defaults=e.extend(e.WidgetSeries.defaults,{frame:"rectangle",maxCount:100,maxFontSize:1,minFontSize:0,colorByPoint:!0,autoScale:!0});const r=Math.floor;class a{constructor(t){this._options=t}start(t,i,s,n,o,r){this._container=t;const a="circle"===s.frame||"ellipse"===s.frame,h=s.autoScale,l=e.pickNum(s.seed,0)*Math.PI*2/360,c=Math.max(0,e.pickNum(s.wordGap,0));let d=n,u=0,_=o,x=0,p=0;this.$_prepare(s,n,o),this._unit,i.forEach((t=>{const e=t.point;if(this.$_findPos(t,a,s.shuffle,this._radius,l,c)){const{x:i,y:s,width:n,height:o}=t.box.bounds;this.$_placeWord(t),e.xPos=i+n/2,e.yPos=s,d=Math.min(d,i),u=Math.max(u,i+n),_=Math.min(_,s),x=Math.max(x,s+o),p++}else t.setVis(!1)})),e.Utils.log("Words placed.",p,"of",i.length);const m=u-d,f=x-_,g=n/2,y=o/2,M=h?1/(Math.max(m/n,f/o)+.02):1,P=~~((d+m/2-g)*M),w=~~((_+f/2-y)*M);return this._trans={x:P,y:w,cx:g,cy:y,rate:M},i.forEach((t=>{const e=t.point;e.xPos=g-P+(e.xPos-g)*M,e.yPos=y-w+(e.yPos-y)*M})),this.$_transform(),null==r||r(i),this}stop(){}$_transform(t=1){let{x:e,y:i,cx:s,cy:n,rate:o}=this._trans;e=~~(e*t),i=~~(i*t),this._container.dom.setAttribute("transform-origin",`${s} ${n}`),this._container.trans(-e,-i),this._container.scale(o*t)}$_prepare(t,e,i){const s=this._unit=8;this._grid=[],this._cols=r(e/s),this._rows=r(i/s),this._radius=r(Math.sqrt(this._cols*this._cols+this._rows*this._rows)/2);const n=2*this._radius;this._center={c:this._radius,r:this._radius};for(let t=0;t<n;t++)this._grid.push([]);this._rdPoints=[],this._ellipticity="ellipse"===t.frame||"rectangle"===t.frame?i/e:1}$_isOverlapping(t){const e=this._grid;for(let i=t.r1;i<=t.r2;i++)for(let s=t.c1;s<=t.c2;s++)if(e[i]||(e[i]=[]),e[i][s])return!0;return!1}$_placeWord(t){const e=this._grid,i=t.box;for(let s=i.r1;s<=i.r2;s++)for(let n=i.c1;n<=i.c2;n++)e[s][n]=t}$_getPoints(t,e,i){if(this._rdPoints[t])return this._rdPoints[t];const s=this._center,n=this._ellipticity,o=t*this._unit;let r=0,a=[];for(0===t&&a.push([s.c,s.r]);r<o;){const h=r/o*2*Math.PI+i;let l=t*Math.cos(h)/n,c=t*Math.sin(h);if(!e){const t=Math.max(Math.abs(Math.cos(h)),Math.abs(Math.sin(h)));l/=t,c/=t}a.push([~~(s.c+l),~~(s.r+c)]),r++}return this._rdPoints[t]=a}$_rotatePoint(t,e,i){const s=e*Math.PI/180,n=Math.cos(s),o=Math.sin(s),{x:r,y:a,width:h,height:l}=t,c=r+h,d=a+l,u=r+h/2,_=a+l/2,x=[{x:r,y:a},{x:c,y:a},{x:r,y:d},{x:c,y:d}].map((t=>({x:u+(t.x-u)*n-(t.y-_)*o,y:_+(t.x-u)*o+(t.y-_)*n}))),p=Math.min(...x.map((t=>t.x))),m=Math.min(...x.map((t=>t.y))),f=Math.max(...x.map((t=>t.x))),g=Math.max(...x.map((t=>t.y))),y=this._unit,M=f-p,P=g-m;return{c1:Math.max(0,~~(p/y)),r1:Math.max(0,~~(m/y)),c2:~~(f/y),r2:~~(g/y)+i,bounds:{x:p,y:m,width:M,height:P}}}$_getBox(t,e,i,s,n=0){const o=this._unit,{width:r}=t.getBBox(),a=t.hText,h=r/o,l=a/o,c=Math.ceil(h/2),d=Math.ceil(l/2),u=Math.max(0,e-c),_=Math.max(0,i-d),x=u+Math.ceil(h),p=_+Math.ceil(l),m={x:(e-c)*o,y:(i-d)*o,width:r,height:a};return n?this.$_rotatePoint(m,n,s):{c1:u,r1:_,c2:x+s,r2:p,bounds:m}}$_drawDebugBox(t,i){const{doc:s}=this._container,{x:n,y:o,width:r,height:a}=t.bounds,h=e.RectElement.create(s,"",n,o,r,a);h.setFill((null==i?void 0:i.fill)||"#ff000055"),h.setStroke((null==i?void 0:i.stroke)||"none"),h.setAttr("stroke-dasharray",(null==i?void 0:i.strokeDashArray)||"4"),this._container.add(h)}$_findPos(t,i,s,n,o,r){let a=0,h=0;n=Math.max(n,this._grid.length+1);const l=[0,-90],c=l.length;for(;a<n;){const n=this.$_getPoints(a,i,o+h++%4*(Math.PI/4));s&&e.Utils.shuffle(n);if(n.some(((i,s)=>{let n=this._options.rotation?l[~~(e.Utils.randomLike(s+o)*c)]:0;const a=this.$_getBox(t,i[0],i[1],r,n);if(!this.$_isOverlapping(a)){if(a.bounds.x<0||a.bounds.y<0)return!1;const e=this.$_getBox(t,i[0],i[1],r),{bounds:s}=e,o={x:s.width/2,y:s.height/2};return t.wx=s.x,t.wy=s.y,t.setRotation(o.x,o.y,n),t.box=a,!0}})))return!0;a++}}}class h extends a{$_findPos(t,e,i,s,n,o){if(this.$_getPoints(s,e,i?Math.random()*Math.PI*2:n).some((e=>{const i=this.$_getBox(t,e[0],e[1],o);if(!this.$_isOverlapping(i))return t.box=i,!0})))return!0}$_getPoints(t,e,i){const s=this._center,n=this._ellipticity,o=2*t*this._unit;let r=-1,a=[];0===t&&a.push([s.c,s.r]);const h=i>Math.PI?1:-1;if(e)for(;++r<o;){const e=r/o,l=i+r*e*h,c=t*e,d=c*Math.cos(l)/n,u=c*Math.sin(l),_=s.c+d,x=s.r+u;a.push([~~_,~~x])}else{let e=this._unit>>1,o=e/n,l=s.c+o*Math.cos(i),c=s.r+e*Math.sin(i);const d=Math.max(1,this._unit>>1),u=d-Math.max(1,d>>1),_=.99;for(;++r>=0;){e=1+u*Math.pow(_,r),o=e/n;switch(3&(h*Math.sqrt(1+8*r)-1)/2){case 0:l+=o;break;case 1:c+=e;break;case 2:l-=o;break;default:c-=e}if(Math.max(Math.abs(l-t),Math.abs(c-t))>t)break;a.push([~~l,~~c])}}return a}$_getBox(t,e,i,s){const n=this._unit,o=t.getBBox(),a=t.hText,h=Math.min(2*this._radius,Math.max(0,e-r(o.width/2/n))),l=Math.min(2*this._radius,Math.max(0,i-r(a/2/n)));return{c1:h,r1:l,c2:h+r(o.width/n)+s,r2:l+r(a/n),w:t.width,h:a}}}class l extends e.RcElement{constructor(t){super(t,e.SeriesView.POINT_CLASS),this.add(this.hintView=new e.RectElement(t)),this.hintView.setStyles({stroke:"none",fill:"transparent"}),this.add(this.textView=new e.TextElement(t)),this.textView.setStyle("pointerEvents","none")}layout(){const t=this.getBBox();this.hintView.setRect({x:0,y:this.yText*l.TOP_PAD,width:t.width,height:this.hText-this.yText}),this.textView.transY(-this.yText*l.TOP_PAD)}}l.TOP_PAD=.5;class c extends e.WidgetSeriesView{constructor(t){super(t,"rct-wordcloud-series"),this._pointContainer.add(this._wordContainer=new e.LayerElement(t,null)),this._words=new e.ElementPool(this._wordContainer,l)}_getPointPool(){return this._words}needFronting(){return!1}isEmptyView(){return this._empty}_renderSeries(t,i){const s=this.model.options,n=s.text;if(t!==this._wSave||i!==this._hSave||n!==this._tSave){const o=+new Date;let r=this._visPoints.slice();if(s.minWeight>0&&(r=r.filter((t=>t.yValue>=s.minWeight))),s.minLength>1&&(r=r.filter((t=>t.x.length>=s.minLength))),s.maxCount<r.length&&(r.length=Math.max(0,s.maxCount)),this.$_prepareWords(this.doc,this.model,r),"spiral"===s.placer)this._placer=new h(s).start(this._wordContainer,this._words._internalItems(),s,t,i,(e=>{this.$_layoutWords(t,i)}));else this._placer=new a(s).start(this._wordContainer,this._words._internalItems(),s,t,i,(e=>{this.$_layoutWords(t,i)}));this._wSave=t,this._hSave=i,this._tSave=n,this._empty=r.length<1,e.Utils.log(r.length+" words placed in "+(+new Date-o)+"ms.")}else this.$_layoutWords(t,i)}_runShowEffect(t){t&&e.SeriesAnimation.spread(this,(()=>{}))}_doPosRateChanged(t){this.$_layoutWords(this.width,this.height)}$_prepareWords(t,i,s){const n=i._minY,o=i._maxY,r=o-n,a=this.height,h=i.getMaxFontSize(a,1);let c=Math.min(h,i.getMinFontSize(a,0));const d=n===o||c===h,u=d?NaN:i.options.logBase,_=getComputedStyle(this._wordContainer.dom).fontFamily,x=Math.min(2,Math.max(.1,+i.options.textHeight)),p=isNaN(x)?t.createElement("canvas").getContext("2d"):null,m=1-l.TOP_PAD;let f;this._words.prepare(s.length,((o,a)=>{const l=o.point=s[a],g=o.textView;let y=(l.y-n)/r;u>1&&(y=1-(Math.pow(u,1-y)-1)/(u-1));let M=c+(d?(h-c)/2:y*(h-c));const P=l.x;this._preparePoint(t,i,l,o),delete o.box,g.text=P,g.anchor=e.TextAnchor.START,g.setStyles({fontSize:e.pixel(M)}),g.layoutText(),p?(p.font=`${e.pixel(M)} ${_}`,f=p.measureText(P),o.yText=.9*Math.max(0,f.fontBoundingBoxAscent-f.actualBoundingBoxAscent),o.hText=Math.ceil((f.actualBoundingBoxAscent+f.actualBoundingBoxDescent)*(M<=10?1.1:1.08)-.1)+o.yText*m):(o.yText=0,o.hText=o.getBBox().height*x),o.layout(),o.setVis(!0)}))}$_layoutWords(t,e){var i;let s=this._getPosRate();null===(i=this._placer)||void 0===i||i.$_transform(s),s=1-s,this._words.forEach((i=>{const{bounds:n}=i.box,o=n.width,r=n.height,a=(t-o)/2;let h=(e-r)/2;i.trans(i.wx-(i.wx-a)*s,i.wy-(i.wy-h)*s)}))}}function d(t){(function(t){return t.Series&&t.SeriesView})(t)&&(t.Series.register(o),t.SeriesView.register([o,c]))}d(s),t.WordCloudSeries=o,t.default=d,Object.defineProperty(t,"__esModule",{value:!0})}));
package/wordcloud.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  /**
3
- * RealChart Wordcloud v1.3.4
3
+ * RealChart Wordcloud v1.3.6
4
4
  * Copyright (C) 2023-2025 WooriTech Inc.
5
5
  * All Rights Reserved.
6
6
  */
7
- import{WordCloudSeriesType as t,extend as e,WidgetSeries as i,calcPercent as s,parsePercentSize as n,Utils as o,toStr as r,WidgetSeriesPoint as a,RcElement as h,SeriesView as l,RectElement as c,TextElement as _,WidgetSeriesView as d,LayerElement as x,ElementPool as u,SeriesAnimation as m,TextAnchor as p,pixel as M,pickNum as g}from"./index.mjs";class y extends a{}class f extends i{$_denormalizeFontSize(t,e,i){let o,r;return"min"==t?(o=s(n(f.MinFontSize,!1),e),r=s(n(f.MaxMinFontSize,!1),e)):(o=s(n(f.MinMaxFontSize,!1),e),r=s(n(f.MaxFontSize,!1),e)),i>1?r:i<0?o:i*(r-o)+o}calcFontRatio(t,e,i,n){return s(e,i,n)}getMinFontSize(t,e){const{fixed:i,size:o}=this._minFontSizeDim,r=i&&o<=1?this.$_denormalizeFontSize("min",t,o):s(this._minFontSizeDim,t,e);return Math.max(s(n(f.MinFontSize,!1),t),r)}getMaxFontSize(t,e){const{fixed:i,size:o}=this._maxFontSizeDim,r=i&&o<=1?this.$_denormalizeFontSize("max",t,o):s(this._maxFontSizeDim,t,e);return Math.min(s(n(f.MaxFontSize,!1),t),r)}getLogFunc(){const t=this._op.logBase;return t>=2?function(e){return Math.max(Math.log(e)/Math.log(t))}:function(t){return t}}_colorByPoint(){return this._op.colorByPoint}_createPoint(t){return new y(t)}_doApply(t){var e;super._doApply(t),(t.text!==this._text||o.equalArrays(this._excludes,t.excludes))&&(this._text=t.text,this._excludes=null===(e=t.excludes)||void 0===e?void 0:e.slice(),this._dataSourceDirty=!0),this._setDims(t,"minFontSize","maxFontSize")}_doLoadPoints(t){const e=this._op,i=e.text;let s=[];if(i){const t=Math.max(e.minLength||1,1),n={};let o=e.excludes,r=i.split(/\s+/g);Array.isArray(o)&&o.length>0&&(r=r.filter((t=>o.indexOf(t)<0))),r.forEach((e=>{e.length>=t&&(e in n?n[e]++:n[e]=1)}));for(const t in n)s.push({x:t,y:n[t]});s=s.sort(((t,e)=>e.y-t.y))}else if(Array.isArray(t)&&!(t.length>0&&"object"==typeof t[0]&&null!==t[0]))for(let e=0;e<t.length;e+=2)s.push({x:r(t[e]),y:t[e+1]||0});s.length>0&&(t=s),super._doLoadPoints(t)}isPointLabelVisible(t){return!1}_prepareRender(){super._prepareRender(),this.pointValuesPrepared(null),this.collectValues(null,null),this.collectRanges(null)}}f.type=t,f.MinFontSize=8,f.MaxMinFontSize=15,f.MaxFontSize="15%",f.MinMaxFontSize="5%",f.defaults=e(i.defaults,{frame:"rectangle",maxCount:100,maxFontSize:1,minFontSize:0,colorByPoint:!0,autoScale:!0});const w=Math.floor;class S{constructor(t){this._options=t}start(t,e,i,s,n,r){this._container=t;const a="circle"===i.frame||"ellipse"===i.frame,h=i.autoScale,l=g(i.seed,0)*Math.PI*2/360,c=Math.max(0,g(i.wordGap,0));let _=s,d=0,x=n,u=0,m=0;this.$_prepare(i,s,n),this._unit,e.forEach((t=>{const e=t.point;if(this.$_findPos(t,a,i.shuffle,this._radius,l,c)){const{x:i,y:s,width:n,height:o}=t.box.bounds;this.$_placeWord(t),e.xPos=i+n/2,e.yPos=s,_=Math.min(_,i),d=Math.max(d,i+n),x=Math.min(x,s),u=Math.max(u,s+o),m++}else t.setVis(!1)})),o.log("Words placed.",m,"of",e.length);const p=d-_,M=u-x,y=s/2,f=n/2,w=h?1/(Math.max(p/s,M/n)+.02):1,S=~~((_+p/2-y)*w),P=~~((x+M/2-f)*w);return this._trans={x:S,y:P,cx:y,cy:f,rate:w},e.forEach((t=>{const e=t.point;e.xPos=y-S+(e.xPos-y)*w,e.yPos=f-P+(e.yPos-f)*w})),this.$_transform(),null==r||r(e),this}stop(){}$_transform(t=1){let{x:e,y:i,cx:s,cy:n,rate:o}=this._trans;e=~~(e*t),i=~~(i*t),this._container.dom.setAttribute("transform-origin",`${s} ${n}`),this._container.trans(-e,-i),this._container.scale(o*t)}$_prepare(t,e,i){const s=this._unit=8;this._grid=[],this._cols=w(e/s),this._rows=w(i/s),this._radius=w(Math.sqrt(this._cols*this._cols+this._rows*this._rows)/2);const n=2*this._radius;this._center={c:this._radius,r:this._radius};for(let t=0;t<n;t++)this._grid.push([]);this._rdPoints=[],this._ellipticity="ellipse"===t.frame||"rectangle"===t.frame?i/e:1}$_isOverlapping(t){const e=this._grid;for(let i=t.r1;i<=t.r2;i++)for(let s=t.c1;s<=t.c2;s++)if(e[i]||(e[i]=[]),e[i][s])return!0;return!1}$_placeWord(t){const e=this._grid,i=t.box;for(let s=i.r1;s<=i.r2;s++)for(let n=i.c1;n<=i.c2;n++)e[s][n]=t}$_getPoints(t,e,i){if(this._rdPoints[t])return this._rdPoints[t];const s=this._center,n=this._ellipticity,o=t*this._unit;let r=0,a=[];for(0===t&&a.push([s.c,s.r]);r<o;){const h=r/o*2*Math.PI+i;let l=t*Math.cos(h)/n,c=t*Math.sin(h);if(!e){const t=Math.max(Math.abs(Math.cos(h)),Math.abs(Math.sin(h)));l/=t,c/=t}a.push([~~(s.c+l),~~(s.r+c)]),r++}return this._rdPoints[t]=a}$_rotatePoint(t,e,i){const s=e*Math.PI/180,n=Math.cos(s),o=Math.sin(s),{x:r,y:a,width:h,height:l}=t,c=r+h,_=a+l,d=r+h/2,x=a+l/2,u=[{x:r,y:a},{x:c,y:a},{x:r,y:_},{x:c,y:_}].map((t=>({x:d+(t.x-d)*n-(t.y-x)*o,y:x+(t.x-d)*o+(t.y-x)*n}))),m=Math.min(...u.map((t=>t.x))),p=Math.min(...u.map((t=>t.y))),M=Math.max(...u.map((t=>t.x))),g=Math.max(...u.map((t=>t.y))),y=this._unit,f=M-m,w=g-p;return{c1:Math.max(0,~~(m/y)),r1:Math.max(0,~~(p/y)),c2:~~(M/y),r2:~~(g/y)+i,bounds:{x:m,y:p,width:f,height:w}}}$_getBox(t,e,i,s,n=0){const o=this._unit,{width:r}=t.getBBox(),a=t.hText,h=r/o,l=a/o,c=Math.ceil(h/2),_=Math.ceil(l/2),d=Math.max(0,e-c),x=Math.max(0,i-_),u=d+Math.ceil(h),m=x+Math.ceil(l),p={x:(e-c)*o,y:(i-_)*o,width:r,height:a};return n?this.$_rotatePoint(p,n,s):{c1:d,r1:x,c2:u+s,r2:m,bounds:p}}$_drawDebugBox(t,e){const{doc:i}=this._container,{x:s,y:n,width:o,height:r}=t.bounds,a=c.create(i,"",s,n,o,r);a.setFill((null==e?void 0:e.fill)||"#ff000055"),a.setStroke((null==e?void 0:e.stroke)||"none"),a.setAttr("stroke-dasharray",(null==e?void 0:e.strokeDashArray)||"4"),this._container.add(a)}$_findPos(t,e,i,s,n,r){let a=0,h=0;s=Math.max(s,this._grid.length+1);const l=[0,-90],c=l.length;for(;a<s;){const s=this.$_getPoints(a,e,n+h++%4*(Math.PI/4));i&&o.shuffle(s);if(s.some(((e,i)=>{let s=this._options.rotation?l[~~(o.randomLike(i+n)*c)]:0;const a=this.$_getBox(t,e[0],e[1],r,s);if(!this.$_isOverlapping(a)){if(a.bounds.x<0||a.bounds.y<0)return!1;const i=this.$_getBox(t,e[0],e[1],r),{bounds:n}=i,o={x:n.width/2,y:n.height/2};return t.wx=n.x,t.wy=n.y,t.setRotation(o.x,o.y,s),t.box=a,!0}})))return!0;a++}}}class P extends S{$_findPos(t,e,i,s,n,o){if(this.$_getPoints(s,e,i?Math.random()*Math.PI*2:n).some((e=>{const i=this.$_getBox(t,e[0],e[1],o);if(!this.$_isOverlapping(i))return t.box=i,!0})))return!0}$_getPoints(t,e,i){const s=this._center,n=this._ellipticity,o=2*t*this._unit;let r=-1,a=[];0===t&&a.push([s.c,s.r]);const h=i>Math.PI?1:-1;if(e)for(;++r<o;){const e=r/o,l=i+r*e*h,c=t*e,_=c*Math.cos(l)/n,d=c*Math.sin(l),x=s.c+_,u=s.r+d;a.push([~~x,~~u])}else{let e=this._unit>>1,o=e/n,l=s.c+o*Math.cos(i),c=s.r+e*Math.sin(i);const _=Math.max(1,this._unit>>1),d=_-Math.max(1,_>>1),x=.99;for(;++r>=0;){e=1+d*Math.pow(x,r),o=e/n;switch(3&(h*Math.sqrt(1+8*r)-1)/2){case 0:l+=o;break;case 1:c+=e;break;case 2:l-=o;break;default:c-=e}if(Math.max(Math.abs(l-t),Math.abs(c-t))>t)break;a.push([~~l,~~c])}}return a}$_getBox(t,e,i,s){const n=this._unit,o=t.getBBox(),r=t.hText,a=Math.min(2*this._radius,Math.max(0,e-w(o.width/2/n))),h=Math.min(2*this._radius,Math.max(0,i-w(r/2/n)));return{c1:a,r1:h,c2:a+w(o.width/n)+s,r2:h+w(r/n),w:t.width,h:r}}}class $ extends h{constructor(t){super(t,l.POINT_CLASS),this.add(this.hintView=new c(t)),this.hintView.setStyles({stroke:"none",fill:"transparent"}),this.add(this.textView=new _(t)),this.textView.setStyle("pointerEvents","none")}layout(){const t=this.getBBox();this.hintView.setRect({x:0,y:this.yText*$.TOP_PAD,width:t.width,height:this.hText-this.yText}),this.textView.transY(-this.yText*$.TOP_PAD)}}$.TOP_PAD=.5;class z extends d{constructor(t){super(t,"rct-wordcloud-series"),this._pointContainer.add(this._wordContainer=new x(t,null)),this._words=new u(this._wordContainer,$)}_getPointPool(){return this._words}needFronting(){return!1}isEmptyView(){return this._empty}_renderSeries(t,e){const i=this.model.options,s=i.text;if(t!==this._wSave||e!==this._hSave||s!==this._tSave){const n=+new Date;let r=this._visPoints.slice();if(i.minWeight>0&&(r=r.filter((t=>t.yValue>=i.minWeight))),i.minLength>1&&(r=r.filter((t=>t.x.length>=i.minLength))),i.maxCount<r.length&&(r.length=Math.max(0,i.maxCount)),this.$_prepareWords(this.doc,this.model,r),"spiral"===i.placer)this._placer=new P(i).start(this._wordContainer,this._words._internalItems(),i,t,e,(i=>{this.$_layoutWords(t,e)}));else this._placer=new S(i).start(this._wordContainer,this._words._internalItems(),i,t,e,(i=>{this.$_layoutWords(t,e)}));this._wSave=t,this._hSave=e,this._tSave=s,this._empty=r.length<1,o.log(r.length+" words placed in "+(+new Date-n)+"ms.")}else this.$_layoutWords(t,e)}_runShowEffect(t){t&&m.spread(this,(()=>{}))}_doPosRateChanged(t){this.$_layoutWords(this.width,this.height)}$_prepareWords(t,e,i){const s=e._minY,n=e._maxY,o=n-s,r=this.height,a=e.getMaxFontSize(r,1);let h=Math.min(a,e.getMinFontSize(r,0));const l=s===n||h===a,c=l?NaN:e.options.logBase,_=getComputedStyle(this._wordContainer.dom).fontFamily,d=Math.min(2,Math.max(.1,+e.options.textHeight)),x=isNaN(d)?t.createElement("canvas").getContext("2d"):null,u=1-$.TOP_PAD;let m;this._words.prepare(i.length,((n,r)=>{const g=n.point=i[r],y=n.textView;let f=(g.y-s)/o;c>1&&(f=1-(Math.pow(c,1-f)-1)/(c-1));let w=h+(l?(a-h)/2:f*(a-h));const S=g.x;this._preparePoint(t,e,g,n),delete n.box,y.text=S,y.anchor=p.START,y.setStyles({fontSize:M(w)}),y.layoutText(),x?(x.font=`${M(w)} ${_}`,m=x.measureText(S),n.yText=.9*Math.max(0,m.fontBoundingBoxAscent-m.actualBoundingBoxAscent),n.hText=Math.ceil((m.actualBoundingBoxAscent+m.actualBoundingBoxDescent)*(w<=10?1.1:1.08)-.1)+n.yText*u):(n.yText=0,n.hText=n.getBBox().height*d),n.layout(),n.setVis(!0)}))}$_layoutWords(t,e){var i;let s=this._getPosRate();null===(i=this._placer)||void 0===i||i.$_transform(s),s=1-s,this._words.forEach((i=>{const{bounds:n}=i.box,o=n.width,r=n.height,a=(t-o)/2;let h=(e-r)/2;i.trans(i.wx-(i.wx-a)*s,i.wy-(i.wy-h)*s)}))}}function F(t){(function(t){return t.Series&&t.SeriesView})(t)&&(t.Series.register(f),t.SeriesView.register([f,z]))}export{f as WordCloudSeries,F as default};
7
+ import{WordCloudSeriesType as t,extend as e,WidgetSeries as i,calcPercent as s,parsePercentSize as n,Utils as o,toStr as r,WidgetSeriesPoint as a,RcElement as h,SeriesView as l,RectElement as c,TextElement as _,WidgetSeriesView as d,LayerElement as x,ElementPool as u,SeriesAnimation as m,TextAnchor as p,pixel as M,pickNum as g}from"./index.mjs";class y extends a{}class f extends i{$_denormalizeFontSize(t,e,i){let o,r;return"min"==t?(o=s(n(f.MinFontSize,!1),e),r=s(n(f.MaxMinFontSize,!1),e)):(o=s(n(f.MinMaxFontSize,!1),e),r=s(n(f.MaxFontSize,!1),e)),i>1?r:i<0?o:i*(r-o)+o}calcFontRatio(t,e,i,n){return s(e,i,n)}getMinFontSize(t,e){const{fixed:i,size:o}=this._minFontSizeDim,r=i&&o<=1?this.$_denormalizeFontSize("min",t,o):s(this._minFontSizeDim,t,e);return Math.max(s(n(f.MinFontSize,!1),t),r)}getMaxFontSize(t,e){const{fixed:i,size:o}=this._maxFontSizeDim,r=i&&o<=1?this.$_denormalizeFontSize("max",t,o):s(this._maxFontSizeDim,t,e);return Math.min(s(n(f.MaxFontSize,!1),t),r)}getLogFunc(){const t=this._op.logBase;return t>=2?function(e){return Math.max(Math.log(e)/Math.log(t))}:function(t){return t}}_colorByPoint(){return this._op.colorByPoint}_createPoint(t){return new y(t)}_doApply(t){var e;super._doApply(t),(t.text!==this._text||o.equalArrays(this._excludes,t.excludes))&&(this._text=t.text,this._excludes=null===(e=t.excludes)||void 0===e?void 0:e.slice(),this._dataSourceDirty=!0),this._setDims(t,"minFontSize","maxFontSize")}_doLoadPoints(t){const e=this._op,i=e.text;let s=[];if(i){const t=Math.max(e.minLength||1,1),n={};let o=e.excludes,r=i.split(/\s+/g);Array.isArray(o)&&o.length>0&&(r=r.filter((t=>o.indexOf(t)<0))),r.forEach((e=>{e.length>=t&&(e in n?n[e]++:n[e]=1)}));for(const t in n)s.push({x:t,y:n[t]})}else if(Array.isArray(t)&&!(t.length>0&&"object"==typeof t[0]&&null!==t[0]))for(let e=0;e<t.length;e+=2)s.push({x:r(t[e]),y:t[e+1]||0});s.length>0&&(t=s.sort(((t,e)=>e.y-t.y))),super._doLoadPoints(t)}isPointLabelVisible(t){return!1}_prepareRender(){super._prepareRender(),this.pointValuesPrepared(null),this.collectValues(null,null),this.collectRanges(null)}}f.type=t,f.MinFontSize=8,f.MaxMinFontSize=15,f.MaxFontSize="15%",f.MinMaxFontSize="5%",f.defaults=e(i.defaults,{frame:"rectangle",maxCount:100,maxFontSize:1,minFontSize:0,colorByPoint:!0,autoScale:!0});const w=Math.floor;class S{constructor(t){this._options=t}start(t,e,i,s,n,r){this._container=t;const a="circle"===i.frame||"ellipse"===i.frame,h=i.autoScale,l=g(i.seed,0)*Math.PI*2/360,c=Math.max(0,g(i.wordGap,0));let _=s,d=0,x=n,u=0,m=0;this.$_prepare(i,s,n),this._unit,e.forEach((t=>{const e=t.point;if(this.$_findPos(t,a,i.shuffle,this._radius,l,c)){const{x:i,y:s,width:n,height:o}=t.box.bounds;this.$_placeWord(t),e.xPos=i+n/2,e.yPos=s,_=Math.min(_,i),d=Math.max(d,i+n),x=Math.min(x,s),u=Math.max(u,s+o),m++}else t.setVis(!1)})),o.log("Words placed.",m,"of",e.length);const p=d-_,M=u-x,y=s/2,f=n/2,w=h?1/(Math.max(p/s,M/n)+.02):1,S=~~((_+p/2-y)*w),P=~~((x+M/2-f)*w);return this._trans={x:S,y:P,cx:y,cy:f,rate:w},e.forEach((t=>{const e=t.point;e.xPos=y-S+(e.xPos-y)*w,e.yPos=f-P+(e.yPos-f)*w})),this.$_transform(),null==r||r(e),this}stop(){}$_transform(t=1){let{x:e,y:i,cx:s,cy:n,rate:o}=this._trans;e=~~(e*t),i=~~(i*t),this._container.dom.setAttribute("transform-origin",`${s} ${n}`),this._container.trans(-e,-i),this._container.scale(o*t)}$_prepare(t,e,i){const s=this._unit=8;this._grid=[],this._cols=w(e/s),this._rows=w(i/s),this._radius=w(Math.sqrt(this._cols*this._cols+this._rows*this._rows)/2);const n=2*this._radius;this._center={c:this._radius,r:this._radius};for(let t=0;t<n;t++)this._grid.push([]);this._rdPoints=[],this._ellipticity="ellipse"===t.frame||"rectangle"===t.frame?i/e:1}$_isOverlapping(t){const e=this._grid;for(let i=t.r1;i<=t.r2;i++)for(let s=t.c1;s<=t.c2;s++)if(e[i]||(e[i]=[]),e[i][s])return!0;return!1}$_placeWord(t){const e=this._grid,i=t.box;for(let s=i.r1;s<=i.r2;s++)for(let n=i.c1;n<=i.c2;n++)e[s][n]=t}$_getPoints(t,e,i){if(this._rdPoints[t])return this._rdPoints[t];const s=this._center,n=this._ellipticity,o=t*this._unit;let r=0,a=[];for(0===t&&a.push([s.c,s.r]);r<o;){const h=r/o*2*Math.PI+i;let l=t*Math.cos(h)/n,c=t*Math.sin(h);if(!e){const t=Math.max(Math.abs(Math.cos(h)),Math.abs(Math.sin(h)));l/=t,c/=t}a.push([~~(s.c+l),~~(s.r+c)]),r++}return this._rdPoints[t]=a}$_rotatePoint(t,e,i){const s=e*Math.PI/180,n=Math.cos(s),o=Math.sin(s),{x:r,y:a,width:h,height:l}=t,c=r+h,_=a+l,d=r+h/2,x=a+l/2,u=[{x:r,y:a},{x:c,y:a},{x:r,y:_},{x:c,y:_}].map((t=>({x:d+(t.x-d)*n-(t.y-x)*o,y:x+(t.x-d)*o+(t.y-x)*n}))),m=Math.min(...u.map((t=>t.x))),p=Math.min(...u.map((t=>t.y))),M=Math.max(...u.map((t=>t.x))),g=Math.max(...u.map((t=>t.y))),y=this._unit,f=M-m,w=g-p;return{c1:Math.max(0,~~(m/y)),r1:Math.max(0,~~(p/y)),c2:~~(M/y),r2:~~(g/y)+i,bounds:{x:m,y:p,width:f,height:w}}}$_getBox(t,e,i,s,n=0){const o=this._unit,{width:r}=t.getBBox(),a=t.hText,h=r/o,l=a/o,c=Math.ceil(h/2),_=Math.ceil(l/2),d=Math.max(0,e-c),x=Math.max(0,i-_),u=d+Math.ceil(h),m=x+Math.ceil(l),p={x:(e-c)*o,y:(i-_)*o,width:r,height:a};return n?this.$_rotatePoint(p,n,s):{c1:d,r1:x,c2:u+s,r2:m,bounds:p}}$_drawDebugBox(t,e){const{doc:i}=this._container,{x:s,y:n,width:o,height:r}=t.bounds,a=c.create(i,"",s,n,o,r);a.setFill((null==e?void 0:e.fill)||"#ff000055"),a.setStroke((null==e?void 0:e.stroke)||"none"),a.setAttr("stroke-dasharray",(null==e?void 0:e.strokeDashArray)||"4"),this._container.add(a)}$_findPos(t,e,i,s,n,r){let a=0,h=0;s=Math.max(s,this._grid.length+1);const l=[0,-90],c=l.length;for(;a<s;){const s=this.$_getPoints(a,e,n+h++%4*(Math.PI/4));i&&o.shuffle(s);if(s.some(((e,i)=>{let s=this._options.rotation?l[~~(o.randomLike(i+n)*c)]:0;const a=this.$_getBox(t,e[0],e[1],r,s);if(!this.$_isOverlapping(a)){if(a.bounds.x<0||a.bounds.y<0)return!1;const i=this.$_getBox(t,e[0],e[1],r),{bounds:n}=i,o={x:n.width/2,y:n.height/2};return t.wx=n.x,t.wy=n.y,t.setRotation(o.x,o.y,s),t.box=a,!0}})))return!0;a++}}}class P extends S{$_findPos(t,e,i,s,n,o){if(this.$_getPoints(s,e,i?Math.random()*Math.PI*2:n).some((e=>{const i=this.$_getBox(t,e[0],e[1],o);if(!this.$_isOverlapping(i))return t.box=i,!0})))return!0}$_getPoints(t,e,i){const s=this._center,n=this._ellipticity,o=2*t*this._unit;let r=-1,a=[];0===t&&a.push([s.c,s.r]);const h=i>Math.PI?1:-1;if(e)for(;++r<o;){const e=r/o,l=i+r*e*h,c=t*e,_=c*Math.cos(l)/n,d=c*Math.sin(l),x=s.c+_,u=s.r+d;a.push([~~x,~~u])}else{let e=this._unit>>1,o=e/n,l=s.c+o*Math.cos(i),c=s.r+e*Math.sin(i);const _=Math.max(1,this._unit>>1),d=_-Math.max(1,_>>1),x=.99;for(;++r>=0;){e=1+d*Math.pow(x,r),o=e/n;switch(3&(h*Math.sqrt(1+8*r)-1)/2){case 0:l+=o;break;case 1:c+=e;break;case 2:l-=o;break;default:c-=e}if(Math.max(Math.abs(l-t),Math.abs(c-t))>t)break;a.push([~~l,~~c])}}return a}$_getBox(t,e,i,s){const n=this._unit,o=t.getBBox(),r=t.hText,a=Math.min(2*this._radius,Math.max(0,e-w(o.width/2/n))),h=Math.min(2*this._radius,Math.max(0,i-w(r/2/n)));return{c1:a,r1:h,c2:a+w(o.width/n)+s,r2:h+w(r/n),w:t.width,h:r}}}class $ extends h{constructor(t){super(t,l.POINT_CLASS),this.add(this.hintView=new c(t)),this.hintView.setStyles({stroke:"none",fill:"transparent"}),this.add(this.textView=new _(t)),this.textView.setStyle("pointerEvents","none")}layout(){const t=this.getBBox();this.hintView.setRect({x:0,y:this.yText*$.TOP_PAD,width:t.width,height:this.hText-this.yText}),this.textView.transY(-this.yText*$.TOP_PAD)}}$.TOP_PAD=.5;class z extends d{constructor(t){super(t,"rct-wordcloud-series"),this._pointContainer.add(this._wordContainer=new x(t,null)),this._words=new u(this._wordContainer,$)}_getPointPool(){return this._words}needFronting(){return!1}isEmptyView(){return this._empty}_renderSeries(t,e){const i=this.model.options,s=i.text;if(t!==this._wSave||e!==this._hSave||s!==this._tSave){const n=+new Date;let r=this._visPoints.slice();if(i.minWeight>0&&(r=r.filter((t=>t.yValue>=i.minWeight))),i.minLength>1&&(r=r.filter((t=>t.x.length>=i.minLength))),i.maxCount<r.length&&(r.length=Math.max(0,i.maxCount)),this.$_prepareWords(this.doc,this.model,r),"spiral"===i.placer)this._placer=new P(i).start(this._wordContainer,this._words._internalItems(),i,t,e,(i=>{this.$_layoutWords(t,e)}));else this._placer=new S(i).start(this._wordContainer,this._words._internalItems(),i,t,e,(i=>{this.$_layoutWords(t,e)}));this._wSave=t,this._hSave=e,this._tSave=s,this._empty=r.length<1,o.log(r.length+" words placed in "+(+new Date-n)+"ms.")}else this.$_layoutWords(t,e)}_runShowEffect(t){t&&m.spread(this,(()=>{}))}_doPosRateChanged(t){this.$_layoutWords(this.width,this.height)}$_prepareWords(t,e,i){const s=e._minY,n=e._maxY,o=n-s,r=this.height,a=e.getMaxFontSize(r,1);let h=Math.min(a,e.getMinFontSize(r,0));const l=s===n||h===a,c=l?NaN:e.options.logBase,_=getComputedStyle(this._wordContainer.dom).fontFamily,d=Math.min(2,Math.max(.1,+e.options.textHeight)),x=isNaN(d)?t.createElement("canvas").getContext("2d"):null,u=1-$.TOP_PAD;let m;this._words.prepare(i.length,((n,r)=>{const g=n.point=i[r],y=n.textView;let f=(g.y-s)/o;c>1&&(f=1-(Math.pow(c,1-f)-1)/(c-1));let w=h+(l?(a-h)/2:f*(a-h));const S=g.x;this._preparePoint(t,e,g,n),delete n.box,y.text=S,y.anchor=p.START,y.setStyles({fontSize:M(w)}),y.layoutText(),x?(x.font=`${M(w)} ${_}`,m=x.measureText(S),n.yText=.9*Math.max(0,m.fontBoundingBoxAscent-m.actualBoundingBoxAscent),n.hText=Math.ceil((m.actualBoundingBoxAscent+m.actualBoundingBoxDescent)*(w<=10?1.1:1.08)-.1)+n.yText*u):(n.yText=0,n.hText=n.getBBox().height*d),n.layout(),n.setVis(!0)}))}$_layoutWords(t,e){var i;let s=this._getPosRate();null===(i=this._placer)||void 0===i||i.$_transform(s),s=1-s,this._words.forEach((i=>{const{bounds:n}=i.box,o=n.width,r=n.height,a=(t-o)/2;let h=(e-r)/2;i.trans(i.wx-(i.wx-a)*s,i.wy-(i.wy-h)*s)}))}}function F(t){(function(t){return t.Series&&t.SeriesView})(t)&&(t.Series.register(f),t.SeriesView.register([f,z]))}export{f as WordCloudSeries,F as default};