realchart 1.4.33 → 1.5.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/gauge.js +2 -2
- package/gauge.mjs +2 -2
- package/heatmap.js +2 -2
- package/heatmap.mjs +2 -2
- package/ie/gauge.ie.js +2 -2
- package/ie/heatmap.ie.js +2 -2
- package/ie/index.ie.js +2 -2
- package/ie/pictogram.ie.js +2 -2
- package/ie/split.ie.js +2 -2
- package/ie/treemap.ie.js +2 -2
- package/ie/vector.ie.js +2 -2
- package/ie/wordcloud.ie.js +2 -2
- package/index.d.ts +350 -88
- package/index.js +2 -2
- package/index.mjs +2 -2
- package/package.json +27 -8
- package/pictogram.d.ts +1 -1
- package/pictogram.js +2 -2
- package/pictogram.mjs +2 -2
- package/split.d.ts +2 -0
- package/split.js +2 -2
- package/split.mjs +2 -2
- package/treemap.js +2 -2
- package/treemap.mjs +2 -2
- package/vector.d.ts +1 -1
- package/vector.js +2 -2
- package/vector.mjs +2 -2
- package/wordcloud.js +2 -2
- package/wordcloud.mjs +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "realchart",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Wooritech charting library",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"module": "./index.mjs",
|
|
@@ -15,12 +15,6 @@
|
|
|
15
15
|
"import": "./index.mjs",
|
|
16
16
|
"default": "./index.mjs"
|
|
17
17
|
},
|
|
18
|
-
"./design": {
|
|
19
|
-
"types": "./design.d.ts",
|
|
20
|
-
"require": "./design.js",
|
|
21
|
-
"import": "./design.mjs",
|
|
22
|
-
"default": "./design.mjs"
|
|
23
|
-
},
|
|
24
18
|
"./gauge": {
|
|
25
19
|
"types": "./gauge.d.ts",
|
|
26
20
|
"require": "./gauge.js",
|
|
@@ -81,5 +75,30 @@
|
|
|
81
75
|
"charts",
|
|
82
76
|
"realreport"
|
|
83
77
|
],
|
|
84
|
-
"license": "license.txt"
|
|
78
|
+
"license": "license.txt",
|
|
79
|
+
"sideEffects": [
|
|
80
|
+
"./*.css",
|
|
81
|
+
"./ie/*.css",
|
|
82
|
+
"./gauge.js",
|
|
83
|
+
"./gauge.mjs",
|
|
84
|
+
"./ie/gauge.ie.js",
|
|
85
|
+
"./heatmap.js",
|
|
86
|
+
"./heatmap.mjs",
|
|
87
|
+
"./ie/heatmap.ie.js",
|
|
88
|
+
"./pictogram.js",
|
|
89
|
+
"./pictogram.mjs",
|
|
90
|
+
"./ie/pictogram.ie.js",
|
|
91
|
+
"./split.js",
|
|
92
|
+
"./split.mjs",
|
|
93
|
+
"./ie/split.ie.js",
|
|
94
|
+
"./treemap.js",
|
|
95
|
+
"./treemap.mjs",
|
|
96
|
+
"./ie/treemap.ie.js",
|
|
97
|
+
"./vector.js",
|
|
98
|
+
"./vector.mjs",
|
|
99
|
+
"./ie/vector.ie.js",
|
|
100
|
+
"./wordcloud.js",
|
|
101
|
+
"./wordcloud.mjs",
|
|
102
|
+
"./ie/wordcloud.ie.js"
|
|
103
|
+
]
|
|
85
104
|
}
|
package/pictogram.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { BasedSeries, PictogramSeriesOptions, RcElement, BarSeriesBase, Pictoria
|
|
|
8
8
|
* {@link https://realchart.co.kr/docs/api/options/SeriesOptions#type type}은 {@link https://realchart.co.kr/config/config/series/pictogram pictogram}이고,
|
|
9
9
|
* {@link options 설정} 모델은 {@link https://realchart.co.kr/docs/api/options/PictogramSeriesOptions PictogramSeriesOptions}이다.
|
|
10
10
|
*
|
|
11
|
-
* @modules
|
|
11
|
+
* @modules pictogram
|
|
12
12
|
*/
|
|
13
13
|
declare class PictogramSeries extends BasedSeries<PictogramSeriesOptions> {
|
|
14
14
|
static readonly type = "pictogram";
|
package/pictogram.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
/**
|
|
3
|
-
* RealChart Pictogram v1.
|
|
3
|
+
* RealChart Pictogram v1.5.0
|
|
4
4
|
* Copyright (C) 2023-2026 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).RealChartPictogram={},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.BasedSeries{_createLegendMarker(e,i){return t.RectElement.create(e,t.Series.LEGEND_MARKER,0,0,i,i,2)}}r.type=t.PictogramSeriesType,r.defaults=t.extend(t.BasedSeries.defaults,{iconGap:2,integral:!1,integralThreshold:.5});class o extends t.RcElement{constructor(e){super(e,t.SeriesView.POINT_CLASS),this.add(this._back=new t.RectElement(e)),this._back.setTransparent(!0)}preppareIcons(e,t,i,s){}layout(e,t,i){const s=this.wPoint,r=this.hPoint;t-=s/2,r<0&&(e=e.map(e=>-e)),this._back.setBounds(t,i-r,s,r)}}class n extends t.BasedSeriesView{constructor(e){super(e,"rct-pictogram-series"),this._bars=new t.PointViewPool(this._pointContainer,o)}_getPointPool(){return this._bars}_preparePoints(e,t,i){}_shrinkPoint(e){}_layoutPoint(e,t,i,s,r,o){}}class a extends t.BarSeriesPoint{_readObject(e,i){super._readObject(e,i),this.figure=t.pickProp(e._figureFielder(i),i.figure)}_readArray(e,t){super._readArray(e,t);const i=+e.prop("figureField");isNaN(i)||(this.figure=t[i])}}class h extends t.BarSeriesBase{getMode(){return this._mode}getFigure(){return this._figurePath}getImage(e){let t=e.figure;return"number"==typeof t&&(t=this._imageUrls[t]),!t&&this.prop("figureByPoint")&&(t=this._imageUrls[e.vindex%this._imageUrls.length]),this._imageRoot+(t||this._imageUrls[0])}getFigureWidth(e){return t.calcPercent(this._widthDim,e,e)}getFigureGap(){return this._figureGap}_createPoint(e){return new a(e)}_createLegendMarker(e,i){return t.RectElement.create(e,t.Series.LEGEND_MARKER,0,0,i,i,2)}_doApply(e){super._doApply(e),this._figureFielder=this._createFielder(e.figureField||"figure"),this._figurePath=t.isArray(e.figurePath)?e.figurePath.join(" "):e.figurePath;const i=e.figureImage;t.isArray(i)?this._imageUrls=i.slice(0):t.isString(i)?this._imageUrls=[i]:this._imageUrls=[],this._imageRoot=t.isString(e.figureImageRoot)?e.figureImageRoot:"",this._mode="both"===e.mode||"figure"===e.mode?e.mode:e.figurePath?"both":"figure",this._figureGap=t.pickNum(e.figureGap,0),this._widthDim=t.parsePercentSize(e.figureWidth,!0)}}h.type=t.PictorialBarSeriesType,h.defaults=t.extend(t.BarSeriesBase.defaults,{mode:"auto",figureWidth:"100%"});class l extends t.WidgetSeriesPoint{}class c extends l{constructor(e,t){super(e),this.points=t}}class d extends t.WidgetSeriesLabel{getDistance(){const e=this.num("distance");return isNaN(e)?"far"===this.prop("align")?d.ENDED_DIST:d.OUTSIDE_DIST:e||0}}d.OUTSIDE_DIST=25,d.ENDED_DIST=10;class u extends t.WidgetSeries{get paths(){return this._paths}getPictorialSize(e,i,s){const r=t.calcPercent(this._sizeDim,1),o=t.minv(i*r/e.width,s*r/e.height);return{width:t.pickNum(t.calcPercent(this._widthDim,i),e.width*o),height:t.pickNum(t.calcPercent(this._heightDim,s),e.height*o)}}get pointLabel(){return this._pointLabel}_createLabel(e){return new d(e)}_createPoint(e){return new l(e)}_createOthersPoint(e,t){return e.y=t.map(e=>e.y).reduce((e,t)=>e+t),new c(e,t)}needClip(e){return!1}getTotal(){const e=super.getSum();return Math.max(e,t.calcPercent(this._totalDim,e))}getSum(){const e=super.getSum(),i=t.calcPercent(this._totalDim,e);return Math.max(e,t.pickNum(i,e))}_doApply(e){super._doApply(e),this._paths=t.isArray(e.figure)?e.figure:[e.figure||""],this._setDims(e,"total","width","height"),this._sizeDim=t.parsePercentSize(this.prop("size"),!1)}_createLegendMarker(e,i){return t.RectElement.create(e,t.Series.LEGEND_MARKER,0,0,i,i,2)}}u.type=t.PictorialSeriesType,u.defaults=t.extend(t.WidgetSeries.defaults,{size:"90%",reversed:!1});class _ extends t.BoxPointElementEx{constructor(e){super(e),this.add(this._figureLayer=new t.RcElement(e,"")),this._figureLayer.add(this._figureView=new t.PathElement(e,"")),this.add(this._imageLayer=new t.RcElement(e,"")),this._imageLayer.add(this._imageView=new t.ImageElement(e,!1,"")),this._imageView.setAttr("preserveAspectRatio","none"),this.add(this._boxView=new t.PathElement(e,"")),this._figureView.setAttr("vector-effect","non-scaling-stroke")}renderSvg(e,t,i,s,r){const o=this._figureView;let n;this._imageLayer.setVis(!1),this._figureLayer.setVis(!0),o.scale(1),o.setPath(s),n=o.getBounds(),e.both?o.scale(r/(e.inverted?n.height:n.width)):e.inverted?o.scale(r/n.height,(e.reversed?-1:1)*this.hPoint/n.width):o.scale(r/n.width,(e.reversed?-1:1)*this.hPoint/n.height),this.$_layoutFigure(e,this._figureLayer,this._figureView,t,i)}renderImage(e,t,i,s,r){const o=this._imageView;this._figureLayer.setVis(!1),this._imageLayer.setVis(!0),o.url=s,o.width=r,o.height=e.both?void 0:Math.abs(this.hPoint),this.$_layoutFigure(e,this._imageLayer,o,t,i)}$_layoutFigure(e,i,s,r,o){const n=s.getBounds(),a=!e.upperClip;let h=this.hPoint,l=!1;e.inverted?e.reversed?a?(s.trans(r+n.height/2,o-h),this._dir="left"):h<0?(s.trans(r+n.height/2,-e.yBase-h),this._dir="left"):(s.trans(r-n.height/2,-e.yBase-h),this._dir="right"):a?(s.trans(r-n.height/2,-h),this._dir="right"):h<0?(s.trans(r+n.height/2,-e.yBase-h),this._dir="left"):(s.trans(r-n.height/2,-e.yBase-h),this._dir="right"):e.reversed?a?(s.trans(r+n.width/2,-h),this._dir="bottom"):h<0?(s.trans(r+n.width/2,e.yLen-e.yBase-h),this._dir="bottom"):(s.trans(r-n.width/2,e.yLen-e.yBase-h),this._dir="top"):a?(s.trans(r-n.width/2,o-h),this._dir="top"):h<0?(s.trans(r+n.width/2,e.yLen-e.yBase-h),this._dir="bottom"):(s.trans(r-n.width/2,e.yLen-e.yBase-h),this._dir="top"),a?(s.rotate(e.reversed?180:0),i.removeAttr("clip-path")):(l=this.point.yValue<e.base,e.reversed&&(l=!l),t.Dom.setClipPath(i.dom,l?e.lowerClip:e.upperClip),s.rotate(l?180:0)),this._boxView.setVis(e.both)&&(l||(l=a&&e.reversed),h-=(l?-1:1)*((e.inverted?n.width:n.height)+e.gap),this.$_layoutBox(e,l,r,o,h))}$_layoutBox(e,i,s,r,o){this._boxView.setVis(i?o<0:o>0)&&this._boxView.setPath(t.SvgShapes.bar(s-this.wPoint/2,r,this.wPoint,-o,e.rTop,e.rBottom))}}class g extends t.BarSeriesViewBase{constructor(e){super(e,"rct-pictorialbar-series")}_createBarPool(e,i){return new t.PointViewPool(e,_)}_prepareLayoutPoints(e,i){const s=this.model,r=this._yBase,o=this._baseVal>s._yAxisObj.axisMin();if(this._info={inverted:this._inverted,reversed:this._yReversed,base:this._baseVal,yBase:r,both:"both"===s.getMode(),gap:s.getFigureGap(),yLen:this._yLen,rTop:+s.prop("topRadius")||0,rBottom:+s.prop("bottomRadius")||0,upperClip:"",lowerClip:""},o){if(!this._upperClip){const e=this.doc,i=this.dom.querySelector("defs")||e.createElementNS(t.SVGNS,"defs"),s=t.Utils.uniqueKey()+"-";this.insertDom(i,this._pointContainer.dom),i.appendChild(this._upperClip=t.Dom.createClipRect(e,s+"upper")),i.appendChild(this._lowerClip=t.Dom.createClipRect(e,s+"lower"))}const s=this._upperClip.firstElementChild,o=this._lowerClip.firstElementChild;this._inverted?(t.Dom.setBounds(s,0,-e,i,e-r),t.Dom.setBounds(o,0,-r,i,e)):(t.Dom.setBounds(s,0,0,e,i-r),t.Dom.setBounds(o,0,i-r,e,r)),this._info.upperClip=this._upperClip.id,this._info.lowerClip=this._lowerClip.id}}_shrinkPoint(e){}_layoutPoint(e,i,s,r,o,n){const a=e.point,h=this.model.getFigure();this._needMask=h&&this._info.both,e.wPoint=o*t.pickNum(a.width,1),e.hPoint=n,e.x=s,h?e.renderSvg(this._info,s,r,h,this._model.getFigureWidth(o)):e.renderImage(this._info,s,r,this._model.getImage(a),this._model.getFigureWidth(o))}setHoverStyle(e){if(super.setHoverStyle(e),this._needMask){const i=getComputedStyle(e.dom),s="none"!==i.stroke?parseFloat(i.strokeWidth):0;if(this._hoverFigureView.parent.setVis(s>0&&this._info.gap<s)){t.Dom.setImportantStyle(e.dom.style,"stroke-width",t.pixel(s+s/2|0));let i=0,r=0;switch(e._dir){case"top":case"right":r=-s/2;break;case"bottom":case"left":r=s/2}this._hoverBoxView.setAttribute("transform",`translate(${i}, ${r})`)}}}focusPointView(e,t){t&&this._needMask?this.$_showHoverView(this._hoverPoint=e).setVis(!0):this._hoverFigureView&&(this._hoverFigureView.parent.setVis(!1),this._hoverPoint=null)}_renderSeries(e,t){super._renderSeries(e,t),this._hoverPoint&&this._hoverFigureView&&this._hoverFigureView.parent.visible&&this.$_showHoverView(this._hoverPoint)}$_showHoverView(e){let i=this._hoverFigureView;if(!i){const e=this.doc;let s;this.add(new t.RcElement(e,"")).add(i=this._hoverFigureView=new t.RcElement(e,"")),i.parent.dom.style.pointerEvents="none",i.appendDom(s=e.createElementNS(t.SVGNS,"path")),s.style.stroke="none",i.parent.appendDom(s=this._hoverBoxView=e.createElementNS(t.SVGNS,"path")),s.style.stroke="none"}const s=i.dom.firstElementChild,r=this._hoverBoxView;return i.parent.setAttr("clip-path",this._pointContainer.getAttr("clip-path")),i.setAttr("clip-path",e._figureLayer.getAttr("clip-path")),s.setAttribute("d",e._figureView.getAttr("d")),s.style.fill=getComputedStyle(e._figureView.dom).fill,s.setAttribute("transform",e._figureView.getTransform()),t.Dom.setVisible(r,e._boxView.visible)&&(r.setAttribute("d",e._boxView.getAttr("d")),r.style.fill=getComputedStyle(e._boxView.dom).fill),this._inverted&&i.parent.setAttr("transform",`rotate(90) translate(${this.height},0) scale(-1, 1)`),i}}class p extends t.PointElement{getTooltipPos(){return{x:this.point.xPos+this.parent.parent.tx,y:this.point.yPos+this.parent.parent.ty}}}class m extends t.WidgetSeriesView{constructor(e){super(e,"rct-pictorial-series");const i=t.Utils.uniqueKey()+"-",s=i+"figure",r=i+"clip",o=i+"hover";this._figurelView=e.createElementNS(t.SVGNS,"use"),this._figurelView.setAttribute("href",`#${s}`),this._figurelView.setAttribute("class","rct-pictorial-series-figure"),this.insertDom(this._figurelView,this._pointContainer.dom);const n=e.createElementNS(t.SVGNS,"defs");this.insertDom(n,this._figurelView),this._sourceView=new t.PathElement(e),this._sourceView.setAttr("vector-effect","non-scaling-stroke"),this._sourceView.dom.id=s,n.appendChild(this._sourceView.dom);const a=e.createElementNS(t.SVGNS,"use"),h=e.createElementNS(t.SVGNS,"clipPath"),l=e.createElementNS(t.SVGNS,"clipPath");a.setAttribute("href",`#${s}`),h.appendChild(a),h.id=r,n.appendChild(h),l.appendChild(this._hoverRect=e.createElementNS(t.SVGNS,"path")),l.id=o,n.appendChild(l),this._hoverView=e.createElementNS(t.SVGNS,"use"),this._hoverView.setAttribute("href",`#${s}`),this._hoverView.setAttribute("clip-path",`url(#${o}`),this._hoverView.style.stroke="none",this._hoverView.style.fill="none",this.appendDom(this._hoverView),this._pointContainer.add(this._sliceLayer=new t.LayerElement(e,null)),this._pointContainer.setAttr("clip-path",`url(#${r})`),this._slices=new t.PointViewPool(this._sliceLayer,p),this.add(this._lineContainer=new t.PointLabelLineContainer(e))}_getPointPool(){return this._slices}getClipContainer(){return null}_prepareSeries(e,t){super._prepareSeries(e,t),this.$_prepareSlices(e,t,this._visPoints),this._lineContainer.prepare(t)}_renderSeries(e,i){this.$_renderFigure(this._sourceView,this._model,e,i);const s=this._visPoints,r=this.model.getCenter(e,i),o=this._figurelView.getBoundingClientRect(),n=r.x-o.width/2,a=r.y-o.height/2,h=`translate(${n},${a})`;t.Dom.hasFill(this._figurelView)||(this._figurelView.style.fill="transparent"),this._figurelView.setAttribute("transform",h),this._hoverView.setAttribute("transform",h),o.x=n,o.y=a,this.$_layoutSlices(s,o,e,i),this._pointContainer.trans(n,a),this._labelContainer.trans(n,a),this._lineContainer.trans(n,a),this.resize(o.width,o.height),this._rSave=o,this._wSave=e,this._hSave=i}_runShowEffect(e){const i=this.model.prop("reversed");e&&t.SeriesAnimation.reveal(this,{from:"column"===this.model.prop("direction")?i?"right":"left":i?"top":"bottom",view:this._sliceLayer})}_refreshZombie(){this.$_layoutSlices(this._visPoints,this._rSave,this._wSave,this._hSave),this._hoverPoint&&!t.Dom.isHidden(this._hoverView)&&this.$_showHoverView(this._hoverPoint)}_animationStarted(e){super._animationStarted(e),this._lineContainer.setVis(this._labelContainer.visible)}setHoverStyle(e){super.setHoverStyle(e);const i=getComputedStyle(e.dom),s="none"!==i.stroke&&parseFloat(i.strokeWidth)>0;t.Dom.setVisible(this._hoverView,s)&&Object.assign(this._hoverView.style,{stroke:i.stroke,strokeWidth:i.strokeWidth,strokeDasharray:i.strokeDasharray})}focusPointView(e,t){this._hoverView.style.display=t?"":"none",t&&this.$_showHoverView(e),this._hoverPoint=t?e:null}$_showHoverView(e){this._hoverRect.setAttribute("d",e.getAttr("d"))}$_prepareSlices(e,t,i){this._slices.prepare(i.length,(s,r)=>{const o=s.point=i[r];this._preparePoint(e,t,o,s)})}$_renderFigure(e,i,s,r){let o,n;e.setPath(i.paths),o=e.getBBox(),n=i.getPictorialSize(o,s,r),e.scale(n.width/o.width,n.height/o.height),t.isIE&&this.$_prepareOutline(this._sourceView.dom,s,r,n.width/o.width,n.height/o.height)}$_layoutSlices(e,t,i,s){const r=this._model,o=r.pointLabel,n=r.prop("reversed");this.$_calcRates(e),this._lineContainer.setStyleOrClass(o.connector.prop("style")),"column"===r.prop("direction")?this.$_renderHorz(n,t,s):this.$_renderVert(n,t,i)}$_calcRates(e){const i=this._zombie,s=this._zombieRate,r=e.length;let o=this.model.getTotal();(isNaN(o)||e.find(e=>e._isDeleted()))&&(o=e.filter(e=>(e.visible||e===i)&&!e.isNull).map(e=>e.yValue*(e===i?s:e._isDeleted()?e._vr:1)).reduce((e,t)=>e+t,0)),r>1||r>0&&!i?1==r&&e[0]._isDeleted()||1===r&&e[0]._vr<1?e[0].yRate=1:e.forEach(e=>{const r=t.fixnum(e.yValue*(e===i?s:e._isDeleted()?e._vr:1)/o)||0;e.yRate=r}):1==r&&(e[0].yRate=t.fixnum(s))}$_createLabelInfo(e){const{a:t,d:i}=e.getCTM(),{width:s,height:r}=e.getBBox();return{dom:e,sx:t,sy:i,wFigure:s,hFigure:r}}$_renderVert(e,i,s){const r=this.model,o=i.width,n=i.height,a=this._labelViews(),h=r.pointLabel,l="inside"===r.getLabelPos(h),c=h.getOffset(),d=h.getDistance(),u=h.getWidgetAlign(),_=null==a?void 0:a.textAlign(),g=[],p=h.prop("opposite"),m=this._lineContainer.setVis(h.connector.visible)?this._lineContainer:null,f=new t.PathBuilder,y=r.getCenter(s,n).x-i.x,w=o/2;let P=e?0:n;const V=a?a.getWidth(0):0,S=g&&!l&&this.$_createLabelInfo(this._sourceView.dom);let b,v;this._slices.forEach(r=>{const h=r.point;if(r.setVis(!h.isNull)){const x=n*h.yRate;if(e?(r.setPath(t.SvgShapes.rectangle(0,P,o,x)),h.yPos=P+x/2,P+=x):(h.yPos=P-x/2,P-=x,r.setPath(t.SvgShapes.rectangle(0,P,o,x))),h.xPos=w,v=null==m?void 0:m.get(h),a&&(b=a.get(h,0))&&b.visible){if(l){const e=b.isDomAnimating(),t=b.getBBox();!e&&b.layout(_||"center"),null==v||v.setVis(!1),b.trans(h.xPos-t.width/2,h.yPos-t.height/2)}else-1===u?this.$_layoutLabelNearVert(S,r,b,_,p,v,f,o,y,c,d):1==u?this.$_layoutLabelFarVert(S,r,b,_,p,v,f,c,d,V,i,s):this.$_layoutLabelOutVert(S,r,b,_,p,v,f,c,d);b.setContrast(l&&r.dom),g.push(b),b.setPosY(b.ty),this._layoutLabelRotation(b)}else v&&v.setVis(!1)}})}$_renderHorz(e,i,s){const r=this.model,o=i.width,n=i.height,a=this._labelViews(),h=r.pointLabel,l="inside"===r.getLabelPos(h),c=h.getOffset(),d=h.getDistance(),u=h.getWidgetAlign(),_=null==a?void 0:a.textAlign(),g=[],p=h.prop("opposite"),m=this._lineContainer.setVis(h.connector.visible)?this._lineContainer:null,f=new t.PathBuilder,y=r.getCenter(o,s).y-i.y,w=n/2,P=a?a.getWidth(0):0,V=g&&!l&&this.$_createLabelInfo(this._sourceView.dom);let S,b,v=e?o:0;this._slices.forEach(r=>{const h=r.point;if(r.setVis(!h.isNull)){const x=o*h.yRate;if(e?(h.xPos=v-x/2,v-=x,r.setPath(t.SvgShapes.rectangle(v,0,x,n))):(h.xPos=v+x/2,r.setPath(t.SvgShapes.rectangle(v,0,x,n)),v+=x),h.yPos=w,b=null==m?void 0:m.get(h),a&&(S=a.get(h,0))&&S.visible){if(l){const e=S.isDomAnimating(),t=S.getBBox();!e&&S.layout(_||"center"),S.trans(h.xPos-t.width/2,h.yPos-t.height/2),null==b||b.setVis(!1)}else-1===u?this.$_layoutLabelNearHorz(V,r,S,_,p,b,f,n,y,c,d):1==u?this.$_layoutLabelFarHorz(V,r,S,_,p,b,f,c,d,P,i,s):this.$_layoutLabelOutHorz(V,r,S,_,p,b,f,c,d);S.setContrast(l&&r.dom),g.push(S),S.setPosY(S.ty),this._layoutLabelRotation(S)}else b&&b.setVis(!1)}})}$_prepareOutline(e,i,s,r,o){const n=+new Date,a=this.control.canvasCtx(),h=e.getTotalLength(),l=t.maxv(1,Math.round(h/500));let c;a.setTransform(1,0,0,1,0,0),a.clearRect(0,0,i,s),a.scale(r,o),a.fillStyle="red",a.beginPath(),c=e.getPointAtLength(0),a.moveTo(c.x,c.y);for(let t=0;t<h;t+=l)c=e.getPointAtLength(t),a.lineTo(c.x,c.y);a.closePath(),a.fill(),console.log("canvas",+new Date-n,"ms.")}$_calcLabelPosVert(e,t,i){const s=e.dom,r=s.ownerSVGElement.createSVGPoint(),{wFigure:o,sx:n}=e,a=2*(e.sx<0?1:1/e.sx);let h=i?0:e.wFigure;if(r.y=t.point.yPos/e.sy,i){for(;h<o;h+=a)if(r.x=h,s.isPointInFill(r))return h>0&&(r.x-=a/2,s.isPointInFill(r)&&(h=r.x)),h*n}else for(;h>=0;h-=a)if(r.x=h,s.isPointInFill(r))return h<o&&(r.x+=a/2,s.isPointInFill(r)&&(h=r.x)),h*n;return e.wFigure*e.sx/2}$_calcLabelPosVertIE(e,t,i){const s=this.control.canvasCtx(),r={x:0,y:0},{wFigure:o,sx:n}=e,a=2*(n<0?1:1/n);let h=r.y=t.point.yPos,l=i?0:o*n;if(i){for(const e=o*n;l<e;l+=a)if(r.x=l,s.isPointInPath(r.x,h))return l>0&&(r.x-=a/2,s.isPointInPath(r.x,h)&&(l=r.x)),l}else for(;l>=0;l-=a)if(r.x=l,s.isPointInPath(l,h))return l<o*n&&(r.x+=a/2,s.isPointInPath(r.x,h)&&(l=r.x)),l;return o/2}$_layoutLabelOutVert(e,i,s,r,o,n,a,h,l){const c=i.point,d=s.isDomAnimating(),u=s.getBBox(),_=c.yPos;!d&&s.layout(r||(o?"right":"left"));let g=t.isIE?this.$_calcLabelPosVertIE(e,i,o):this.$_calcLabelPosVert(e,i,o);n&&(o?n.setLine(a.reset(0,0).line(-l,0).end()):n.setLine(a.reset(0,0).line(l,0).end()),n.trans(g,_)),o?g-=l+h+u.width:g+=l+h,s.trans(g,_-u.height/2)}$_layoutLabelNearVert(e,i,s,r,o,n,a,h,l,c,d){const u=i.point,_=s.isDomAnimating(),g=s.getBBox(),p=u.yPos;!_&&s.layout(r||(o?"right":"left"));const m=t.isIE?this.$_calcLabelPosVertIE(e,i,o):this.$_calcLabelPosVert(e,i,o);let f=l;o?f-=h/2:f+=h/2,n&&(o?n.setLine(a.reset(0,0).line(f-m-d,0).end()):n.setLine(a.reset(0,0).line(f+d-m,0).end()),n.trans(m,p)),o?f-=c+d+g.width:f+=d+c,s.trans(f,p-g.height/2)}$_layoutLabelFarVert(e,i,s,r,o,n,a,h,l,c,d,u){const _=i.point,g=s.isDomAnimating(),p=s.getBBox(),m=_.yPos;!g&&s.layout(r||(o?"right":"left"));const f=t.isIE?this.$_calcLabelPosVertIE(e,i,o):this.$_calcLabelPosVert(e,i,o);let y;y=o?l+h+c-d.x:u-d.x-l-c-h,n&&(o?n.setLine(a.reset(0,0).line(y-f-l,0).end()):n.setLine(a.reset(0,0).line(y+l-f,0).end()),n.trans(f,m)),o?y-=h+l+p.width:y+=l+h,s.trans(y,m-p.height/2)}$_calcLabelPosHorz(e,t,i){const s=e.dom,r=s.ownerSVGElement.createSVGPoint(),{hFigure:o,sy:n}=e,a=2*(e.sy<0?1:1/e.sy);let h=i?e.hFigure:0;if(r.x=t.point.xPos/e.sx,i){for(;h>=0;h-=a)if(r.y=h,s.isPointInFill(r))return h<e.hFigure&&(r.y+=a/2,s.isPointInFill(r)&&(h=r.y)),h*n}else for(;h<o;h+=a)if(r.y=h,s.isPointInFill(r))return h>0&&(r.y-=a/2,s.isPointInFill(r)&&(h=r.y)),h*n;return e.hFigure*e.sy/2}$_calcLabelPosHorzIE(e,t,i){const s=this.control.canvasCtx(),r={x:0,y:0},{hFigure:o,sy:n}=e,a=2*(e.sy<0?1:1/e.sy);let h=r.x=t.point.xPos,l=i?o*n:0;if(i){for(;l>=0;l-=a)if(r.y=l,s.isPointInPath(h,r.y))return l<o*n&&(r.y+=a/2,s.isPointInPath(h,r.y)&&(l=r.y)),l}else for(;l<o;l+=a)if(r.y=l,s.isPointInPath(h,r.y))return l>0&&(r.y-=a/2,s.isPointInPath(h,r.y)&&(l=r.y)),l;return e.hFigure*e.sy/2}$_layoutLabelOutHorz(e,i,s,r,o,n,a,h,l){const c=i.point,d=s.isDomAnimating(),u=s.getBBox(),_=c.xPos;!d&&s.layout(r);let g=t.isIE?this.$_calcLabelPosHorzIE(e,i,o):this.$_calcLabelPosHorz(e,i,o);n&&(o?n.setLine(a.reset(0,0).line(0,l).end()):n.setLine(a.reset(0,0).line(0,-l).end()),n.trans(_,g)),o?g+=l+h:g-=l+h,s.trans(_-u.width/2,o?g:g-u.height)}$_layoutLabelNearHorz(e,i,s,r,o,n,a,h,l,c,d){const u=i.point,_=s.isDomAnimating(),g=s.getBBox(),p=u.xPos;!_&&s.layout(r||(o?"right":"left"));let m=t.isIE?this.$_calcLabelPosHorzIE(e,i,o):this.$_calcLabelPosHorz(e,i,o),f=l;o?f+=h/2:f-=h/2,n&&(o?n.setLine(a.reset(0,0).line(0,f+d-m).end()):n.setLine(a.reset(0,0).line(0,f-m-d).end()),n.trans(p,m)),o?f+=d+c:f-=c+d+g.height,s.trans(p-g.width/2,f)}$_layoutLabelFarHorz(e,i,s,r,o,n,a,h,l,c,d,u){const _=i.point,g=s.isDomAnimating(),p=s.getBBox(),m=_.xPos;!g&&s.layout(r||(o?"right":"left"));const f=t.isIE?this.$_calcLabelPosHorzIE(e,i,o):this.$_calcLabelPosHorz(e,i,o);let y;y=o?u-d.y-l-c-h:l+h+c-d.y,n&&(o?n.setLine(a.reset(0,0).line(0,y+l-f).end()):n.setLine(a.reset(0,0).line(0,y-f-l).end()),n.trans(m,f)),o?y+=l+h:y-=h+l+p.height,s.trans(m-p.width/2,y)}}function f(e){(function(e){return e.Series&&e.SeriesView})(e)&&(e.Series.register(r),e.Series.register(h),e.Series.register(u),e.SeriesView.register([r,n]),e.SeriesView.register([h,g]),e.SeriesView.register([u,m]))}f(s),e.PictogramSeries=r,e.PictorialBarSeries=h,e.PictorialSeries=u,e.default=f,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).RealChartPictogram={},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.BasedSeries{_createLegendMarker(e,i){return t.RectElement.create(e,t.Series.LEGEND_MARKER,0,0,i,i,2)}}r.type=t.PictogramSeriesType,r.defaults=t.extend(t.BasedSeries.defaults,{iconGap:2,integral:!1,integralThreshold:.5});class o extends t.RcElement{constructor(e){super(e,t.SeriesView.POINT_CLASS),this.add(this._back=new t.RectElement(e)),this._back.setTransparent(!0)}preppareIcons(e,t,i,s){}layout(e,t,i){const s=this.wPoint,r=this.hPoint;t-=s/2,r<0&&(e=e.map(e=>-e)),this._back.setBounds(t,i-r,s,r)}}class n extends t.BasedSeriesView{constructor(e){super(e,"rct-pictogram-series"),this._bars=new t.PointViewPool(this._pointContainer,o)}_getPointPool(){return this._bars}_preparePoints(e,t,i){this._bars.prepare(i.length,(e,s)=>{const r=e.point=i[s];this._setPointStyle(e,t,r)})}_shrinkPoint(e){}_layoutPoint(e,t,i,s,r,o){e.wPoint=r,e.hPoint=o,e.layout(this._pts||[],i,s)}}class a extends t.BarSeriesPoint{_readObject(e,i){super._readObject(e,i),this.figure=t.pickProp(e._figureFielder(i),i.figure)}_readArray(e,t){super._readArray(e,t);const i=+e.prop("figureField");isNaN(i)||(this.figure=t[i])}}class h extends t.BarSeriesBase{getMode(){return this._mode}getFigure(){return this._figurePath}getImage(e){let t=e.figure;return"number"==typeof t&&(t=this._imageUrls[t]),!t&&this.prop("figureByPoint")&&(t=this._imageUrls[e.vindex%this._imageUrls.length]),this._imageRoot+(t||this._imageUrls[0])}getFigureWidth(e){return t.calcPercent(this._widthDim,e,e)}getFigureGap(){return this._figureGap}_createPoint(e){return new a(e)}_createLegendMarker(e,i){return t.RectElement.create(e,t.Series.LEGEND_MARKER,0,0,i,i,2)}_doApply(e){super._doApply(e),this._figureFielder=this._createFielder(e.figureField||"figure"),this._figurePath=t.isArray(e.figurePath)?e.figurePath.join(" "):e.figurePath;const i=e.figureImage;t.isArray(i)?this._imageUrls=i.slice(0):t.isString(i)?this._imageUrls=[i]:this._imageUrls=[],this._imageRoot=t.isString(e.figureImageRoot)?e.figureImageRoot:"",this._mode="both"===e.mode||"figure"===e.mode?e.mode:e.figurePath?"both":"figure",this._figureGap=t.pickNum(e.figureGap,0),this._widthDim=t.parsePercentSize(e.figureWidth,!0)}}h.type=t.PictorialBarSeriesType,h.defaults=t.extend(t.BarSeriesBase.defaults,{mode:"auto",figureWidth:"100%"});class l extends t.WidgetSeriesPoint{}class c extends l{constructor(e,t){super(e),this.points=t}}class d extends t.WidgetSeriesLabel{getDistance(){const e=this.num("distance");return isNaN(e)?"far"===this.prop("align")?d.ENDED_DIST:d.OUTSIDE_DIST:e||0}}d.OUTSIDE_DIST=25,d.ENDED_DIST=10;class u extends t.WidgetSeries{get paths(){return this._paths}getPictorialSize(e,i,s){const r=t.calcPercent(this._sizeDim,1),o=t.minv(i*r/e.width,s*r/e.height);return{width:t.pickNum(t.calcPercent(this._widthDim,i),e.width*o),height:t.pickNum(t.calcPercent(this._heightDim,s),e.height*o)}}get pointLabel(){return this._pointLabel}_createLabel(e){return new d(e)}_createPoint(e){return new l(e)}_createOthersPoint(e,t){return e.y=t.map(e=>e.y).reduce((e,t)=>e+t),new c(e,t)}needClip(e){return!1}getTotal(){const e=super.getSum();return Math.max(e,t.calcPercent(this._totalDim,e))}getSum(){const e=super.getSum(),i=t.calcPercent(this._totalDim,e);return Math.max(e,t.pickNum(i,e))}_doApply(e){super._doApply(e),this._paths=t.isArray(e.figure)?e.figure:[e.figure||""],this._setDims(e,"total","width","height"),this._sizeDim=t.parsePercentSize(this.prop("size"),!1)}_createLegendMarker(e,i){return t.RectElement.create(e,t.Series.LEGEND_MARKER,0,0,i,i,2)}}u.type=t.PictorialSeriesType,u.defaults=t.extend(t.WidgetSeries.defaults,{size:"90%",reversed:!1});class _ extends t.BoxPointElementEx{constructor(e){super(e),this.add(this._figureLayer=new t.RcElement(e,"")),this._figureLayer.add(this._figureView=new t.PathElement(e,"")),this.add(this._imageLayer=new t.RcElement(e,"")),this._imageLayer.add(this._imageView=new t.ImageElement(e,!1,"")),this._imageView.setAttr("preserveAspectRatio","none"),this.add(this._boxView=new t.PathElement(e,"")),this._figureView.setAttr("vector-effect","non-scaling-stroke")}renderSvg(e,t,i,s,r){const o=this._figureView;let n;this._imageLayer.setVis(!1),this._figureLayer.setVis(!0),o.scale(1),o.setPath(s),n=o.getBounds(),e.both?o.scale(r/(e.inverted?n.height:n.width)):e.inverted?o.scale(r/n.height,(e.reversed?-1:1)*this.hPoint/n.width):o.scale(r/n.width,(e.reversed?-1:1)*this.hPoint/n.height),this.$_layoutFigure(e,this._figureLayer,this._figureView,t,i)}renderImage(e,t,i,s,r){const o=this._imageView;this._figureLayer.setVis(!1),this._imageLayer.setVis(!0),o.url=s,o.width=r,o.height=e.both?void 0:Math.abs(this.hPoint),this.$_layoutFigure(e,this._imageLayer,o,t,i)}$_layoutFigure(e,i,s,r,o){const n=s.getBounds(),a=!e.upperClip;let h=this.hPoint,l=!1;e.inverted?e.reversed?a?(s.trans(r+n.height/2,o-h),this._dir="left"):h<0?(s.trans(r+n.height/2,-e.yBase-h),this._dir="left"):(s.trans(r-n.height/2,-e.yBase-h),this._dir="right"):a?(s.trans(r-n.height/2,-h),this._dir="right"):h<0?(s.trans(r+n.height/2,-e.yBase-h),this._dir="left"):(s.trans(r-n.height/2,-e.yBase-h),this._dir="right"):e.reversed?a?(s.trans(r+n.width/2,-h),this._dir="bottom"):h<0?(s.trans(r+n.width/2,e.yLen-e.yBase-h),this._dir="bottom"):(s.trans(r-n.width/2,e.yLen-e.yBase-h),this._dir="top"):a?(s.trans(r-n.width/2,o-h),this._dir="top"):h<0?(s.trans(r+n.width/2,e.yLen-e.yBase-h),this._dir="bottom"):(s.trans(r-n.width/2,e.yLen-e.yBase-h),this._dir="top"),a?(s.rotate(e.reversed?180:0),i.removeAttr("clip-path")):(l=this.point.yValue<e.base,e.reversed&&(l=!l),t.Dom.setClipPath(i.dom,l?e.lowerClip:e.upperClip),s.rotate(l?180:0)),this._boxView.setVis(e.both)&&(l||(l=a&&e.reversed),h-=(l?-1:1)*((e.inverted?n.width:n.height)+e.gap),this.$_layoutBox(e,l,r,o,h))}$_layoutBox(e,i,s,r,o){this._boxView.setVis(i?o<0:o>0)&&this._boxView.setPath(t.SvgShapes.bar(s-this.wPoint/2,r,this.wPoint,-o,e.rTop,e.rBottom))}}class g extends t.BarSeriesViewBase{constructor(e){super(e,"rct-pictorialbar-series")}_createBarPool(e,i){return new t.PointViewPool(e,_)}_prepareLayoutPoints(e,i){const s=this.model,r=this._yBase,o=this._baseVal>s._yAxisObj.axisMin();if(this._info={inverted:this._inverted,reversed:this._yReversed,base:this._baseVal,yBase:r,both:"both"===s.getMode(),gap:s.getFigureGap(),yLen:this._yLen,rTop:+s.prop("topRadius")||0,rBottom:+s.prop("bottomRadius")||0,upperClip:"",lowerClip:""},o){if(!this._upperClip){const e=this.doc,i=this.dom.querySelector("defs")||e.createElementNS(t.SVGNS,"defs"),s=t.Utils.uniqueKey()+"-";this.insertDom(i,this._pointContainer.dom),i.appendChild(this._upperClip=t.Dom.createClipRect(e,s+"upper")),i.appendChild(this._lowerClip=t.Dom.createClipRect(e,s+"lower"))}const s=this._upperClip.firstElementChild,o=this._lowerClip.firstElementChild;this._inverted?(t.Dom.setBounds(s,0,-e,i,e-r),t.Dom.setBounds(o,0,-r,i,e)):(t.Dom.setBounds(s,0,0,e,i-r),t.Dom.setBounds(o,0,i-r,e,r)),this._info.upperClip=this._upperClip.id,this._info.lowerClip=this._lowerClip.id}}_shrinkPoint(e){}_layoutPoint(e,i,s,r,o,n){const a=e.point,h=this.model.getFigure();this._needMask=h&&this._info.both,e.wPoint=o*t.pickNum(a.width,1),e.hPoint=n,e.x=s,h?e.renderSvg(this._info,s,r,h,this._model.getFigureWidth(o)):e.renderImage(this._info,s,r,this._model.getImage(a),this._model.getFigureWidth(o))}setHoverStyle(e){if(super.setHoverStyle(e),this._needMask){const i=getComputedStyle(e.dom),s="none"!==i.stroke?parseFloat(i.strokeWidth):0;if(this._hoverFigureView.parent.setVis(s>0&&this._info.gap<s)){t.Dom.setImportantStyle(e.dom.style,"stroke-width",t.pixel(s+s/2|0));let i=0,r=0;switch(e._dir){case"top":case"right":r=-s/2;break;case"bottom":case"left":r=s/2}this._hoverBoxView.setAttribute("transform",`translate(${i}, ${r})`)}}}focusPointView(e,t){t&&this._needMask?this.$_showHoverView(this._hoverPoint=e).setVis(!0):this._hoverFigureView&&(this._hoverFigureView.parent.setVis(!1),this._hoverPoint=null)}_renderSeries(e,t){super._renderSeries(e,t),this._hoverPoint&&this._hoverFigureView&&this._hoverFigureView.parent.visible&&this.$_showHoverView(this._hoverPoint)}$_showHoverView(e){let i=this._hoverFigureView;if(!i){const e=this.doc;let s;this.add(new t.RcElement(e,"")).add(i=this._hoverFigureView=new t.RcElement(e,"")),i.parent.dom.style.pointerEvents="none",i.appendDom(s=e.createElementNS(t.SVGNS,"path")),s.style.stroke="none",i.parent.appendDom(s=this._hoverBoxView=e.createElementNS(t.SVGNS,"path")),s.style.stroke="none"}const s=i.dom.firstElementChild,r=this._hoverBoxView;return i.parent.setAttr("clip-path",this._pointContainer.getAttr("clip-path")),i.setAttr("clip-path",e._figureLayer.getAttr("clip-path")),s.setAttribute("d",e._figureView.getAttr("d")),s.style.fill=getComputedStyle(e._figureView.dom).fill,s.setAttribute("transform",e._figureView.getTransform()),t.Dom.setVisible(r,e._boxView.visible)&&(r.setAttribute("d",e._boxView.getAttr("d")),r.style.fill=getComputedStyle(e._boxView.dom).fill),this._inverted&&i.parent.setAttr("transform",`rotate(90) translate(${this.height},0) scale(-1, 1)`),i}}class p extends t.PointElement{getTooltipPos(){return{x:this.point.xPos+this.parent.parent.tx,y:this.point.yPos+this.parent.parent.ty}}}class m extends t.WidgetSeriesView{constructor(e){super(e,"rct-pictorial-series");const i=t.Utils.uniqueKey()+"-",s=i+"figure",r=i+"clip",o=i+"hover";this._figurelView=e.createElementNS(t.SVGNS,"use"),this._figurelView.setAttribute("href",`#${s}`),this._figurelView.setAttribute("class","rct-pictorial-series-figure"),this.insertDom(this._figurelView,this._pointContainer.dom);const n=e.createElementNS(t.SVGNS,"defs");this.insertDom(n,this._figurelView),this._sourceView=new t.PathElement(e),this._sourceView.setAttr("vector-effect","non-scaling-stroke"),this._sourceView.dom.id=s,n.appendChild(this._sourceView.dom);const a=e.createElementNS(t.SVGNS,"use"),h=e.createElementNS(t.SVGNS,"clipPath"),l=e.createElementNS(t.SVGNS,"clipPath");a.setAttribute("href",`#${s}`),h.appendChild(a),h.id=r,n.appendChild(h),l.appendChild(this._hoverRect=e.createElementNS(t.SVGNS,"path")),l.id=o,n.appendChild(l),this._hoverView=e.createElementNS(t.SVGNS,"use"),this._hoverView.setAttribute("href",`#${s}`),this._hoverView.setAttribute("clip-path",`url(#${o}`),this._hoverView.style.stroke="none",this._hoverView.style.fill="none",this.appendDom(this._hoverView),this._pointContainer.add(this._sliceLayer=new t.LayerElement(e,null)),this._pointContainer.setAttr("clip-path",`url(#${r})`),this._slices=new t.PointViewPool(this._sliceLayer,p),this.add(this._lineContainer=new t.PointLabelLineContainer(e))}_getPointPool(){return this._slices}getClipContainer(){return null}_prepareSeries(e,t){super._prepareSeries(e,t),this.$_prepareSlices(e,t,this._visPoints),this._lineContainer.prepare(t)}_renderSeries(e,i){this.$_renderFigure(this._sourceView,this._model,e,i);const s=this._visPoints,r=this.model.getCenter(e,i),o=this._figurelView.getBoundingClientRect(),n=r.x-o.width/2,a=r.y-o.height/2,h=`translate(${n},${a})`;t.Dom.hasFill(this._figurelView)||(this._figurelView.style.fill="transparent"),this._figurelView.setAttribute("transform",h),this._hoverView.setAttribute("transform",h),o.x=n,o.y=a,this.$_layoutSlices(s,o,e,i),this._pointContainer.trans(n,a),this._labelContainer.trans(n,a),this._lineContainer.trans(n,a),this.resize(o.width,o.height),this._rSave=o,this._wSave=e,this._hSave=i}_runShowEffect(e){const i=this.model.prop("reversed");e&&t.SeriesAnimation.reveal(this,{from:"column"===this.model.prop("direction")?i?"right":"left":i?"top":"bottom",view:this._sliceLayer})}_refreshZombie(){this.$_layoutSlices(this._visPoints,this._rSave,this._wSave,this._hSave),this._hoverPoint&&!t.Dom.isHidden(this._hoverView)&&this.$_showHoverView(this._hoverPoint)}_animationStarted(e){super._animationStarted(e),this._lineContainer.setVis(this._labelContainer.visible)}setHoverStyle(e){super.setHoverStyle(e);const i=getComputedStyle(e.dom),s="none"!==i.stroke&&parseFloat(i.strokeWidth)>0;t.Dom.setVisible(this._hoverView,s)&&Object.assign(this._hoverView.style,{stroke:i.stroke,strokeWidth:i.strokeWidth,strokeDasharray:i.strokeDasharray})}focusPointView(e,t){this._hoverView.style.display=t?"":"none",t&&this.$_showHoverView(e),this._hoverPoint=t?e:null}$_showHoverView(e){this._hoverRect.setAttribute("d",e.getAttr("d"))}$_prepareSlices(e,t,i){this._slices.prepare(i.length,(s,r)=>{const o=s.point=i[r];this._preparePoint(e,t,o,s)})}$_renderFigure(e,i,s,r){let o,n;e.setPath(i.paths),o=e.getBBox(),n=i.getPictorialSize(o,s,r),e.scale(n.width/o.width,n.height/o.height),t.isIE&&this.$_prepareOutline(this._sourceView.dom,s,r,n.width/o.width,n.height/o.height)}$_layoutSlices(e,t,i,s){const r=this._model,o=r.pointLabel,n=r.prop("reversed");this.$_calcRates(e),this._lineContainer.setStyleOrClass(o.connector.prop("style")),"column"===r.prop("direction")?this.$_renderHorz(n,t,s):this.$_renderVert(n,t,i)}$_calcRates(e){const i=this._zombie,s=this._zombieRate,r=e.length;let o=this.model.getTotal();(isNaN(o)||e.find(e=>e._isDeleted()))&&(o=e.filter(e=>(e.visible||e===i)&&!e.isNull).map(e=>e.yValue*(e===i?s:e._isDeleted()?e._vr:1)).reduce((e,t)=>e+t,0)),r>1||r>0&&!i?1==r&&e[0]._isDeleted()||1===r&&e[0]._vr<1?e[0].yRate=1:e.forEach(e=>{const r=t.fixnum(e.yValue*(e===i?s:e._isDeleted()?e._vr:1)/o)||0;e.yRate=r}):1==r&&(e[0].yRate=t.fixnum(s))}$_createLabelInfo(e){const{a:t,d:i}=e.getCTM(),{width:s,height:r}=e.getBBox();return{dom:e,sx:t,sy:i,wFigure:s,hFigure:r}}$_renderVert(e,i,s){const r=this.model,o=i.width,n=i.height,a=this._labelViews(),h=r.pointLabel,l="inside"===r.getLabelPos(h),c=h.getDistance(),d=h.getWidgetAlign(),u=null==a?void 0:a.textAlign(),_=[],g=h.prop("opposite"),p=this._lineContainer.setVis(h.connector.visible)?this._lineContainer:null,m=new t.PathBuilder,y=r.getCenter(s,n).x-i.x,f=o/2;let P=e?0:n;const w=a?a.getWidth(0):0,V=_&&!l&&this.$_createLabelInfo(this._sourceView.dom);let S,b;this._slices.forEach(h=>{const v=h.point;if(h.setVis(!v.isNull)){const x=n*v.yRate;if(e?(h.setPath(t.SvgShapes.rectangle(0,P,o,x)),v.yPos=P+x/2,P+=x):(v.yPos=P-x/2,P-=x,h.setPath(t.SvgShapes.rectangle(0,P,o,x))),v.xPos=f,b=null==p?void 0:p.get(v),a&&(S=a.get(v,0))&&S.visible){const e=r.getLabelOff2(v);if(l){const e=S.isDomAnimating(),t=S.getBBox();!e&&S.layout(u||"center"),null==b||b.setVis(!1),S.trans(v.xPos-t.width/2,v.yPos-t.height/2)}else-1===d?this.$_layoutLabelNearVert(V,h,S,u,g,b,m,o,y,e,c):1==d?this.$_layoutLabelFarVert(V,h,S,u,g,b,m,e,c,w,i,s):this.$_layoutLabelOutVert(V,h,S,u,g,b,m,e,c);S.setContrast(l&&h.dom),_.push(S),S.setPosY(S.ty),this._layoutLabelRotation(S)}else b&&b.setVis(!1)}})}$_renderHorz(e,i,s){const r=this.model,o=i.width,n=i.height,a=this._labelViews(),h=r.pointLabel,l="inside"===r.getLabelPos(h),c=h.getDistance(),d=h.getWidgetAlign(),u=null==a?void 0:a.textAlign(),_=[],g=h.prop("opposite"),p=this._lineContainer.setVis(h.connector.visible)?this._lineContainer:null,m=new t.PathBuilder,y=r.getCenter(o,s).y-i.y,f=n/2,P=a?a.getWidth(0):0,w=_&&!l&&this.$_createLabelInfo(this._sourceView.dom);let V,S,b=e?o:0;this._slices.forEach(h=>{const v=h.point;if(h.setVis(!v.isNull)){const x=o*v.yRate;if(e?(v.xPos=b-x/2,b-=x,h.setPath(t.SvgShapes.rectangle(b,0,x,n))):(v.xPos=b+x/2,h.setPath(t.SvgShapes.rectangle(b,0,x,n)),b+=x),v.yPos=f,S=null==p?void 0:p.get(v),a&&(V=a.get(v,0))&&V.visible){const e=r.getLabelOff2(v);if(l){const e=V.isDomAnimating(),t=V.getBBox();!e&&V.layout(u||"center"),V.trans(v.xPos-t.width/2,v.yPos-t.height/2),null==S||S.setVis(!1)}else-1===d?this.$_layoutLabelNearHorz(w,h,V,u,g,S,m,n,y,e,c):1==d?this.$_layoutLabelFarHorz(w,h,V,u,g,S,m,e,c,P,i,s):this.$_layoutLabelOutHorz(w,h,V,u,g,S,m,e,c);V.setContrast(l&&h.dom),_.push(V),V.setPosY(V.ty),this._layoutLabelRotation(V)}else S&&S.setVis(!1)}})}$_prepareOutline(e,i,s,r,o){const n=+new Date,a=this.control.canvasCtx(),h=e.getTotalLength(),l=t.maxv(1,Math.round(h/500));let c;a.setTransform(1,0,0,1,0,0),a.clearRect(0,0,i,s),a.scale(r,o),a.fillStyle="red",a.beginPath(),c=e.getPointAtLength(0),a.moveTo(c.x,c.y);for(let t=0;t<h;t+=l)c=e.getPointAtLength(t),a.lineTo(c.x,c.y);a.closePath(),a.fill(),console.log("canvas",+new Date-n,"ms.")}$_calcLabelPosVert(e,t,i){const s=e.dom,r=s.ownerSVGElement.createSVGPoint(),{wFigure:o,sx:n}=e,a=2*(e.sx<0?1:1/e.sx);let h=i?0:e.wFigure;if(r.y=t.point.yPos/e.sy,i){for(;h<o;h+=a)if(r.x=h,s.isPointInFill(r))return h>0&&(r.x-=a/2,s.isPointInFill(r)&&(h=r.x)),h*n}else for(;h>=0;h-=a)if(r.x=h,s.isPointInFill(r))return h<o&&(r.x+=a/2,s.isPointInFill(r)&&(h=r.x)),h*n;return e.wFigure*e.sx/2}$_calcLabelPosVertIE(e,t,i){const s=this.control.canvasCtx(),r={x:0,y:0},{wFigure:o,sx:n}=e,a=2*(n<0?1:1/n);let h=r.y=t.point.yPos,l=i?0:o*n;if(i){for(const e=o*n;l<e;l+=a)if(r.x=l,s.isPointInPath(r.x,h))return l>0&&(r.x-=a/2,s.isPointInPath(r.x,h)&&(l=r.x)),l}else for(;l>=0;l-=a)if(r.x=l,s.isPointInPath(l,h))return l<o*n&&(r.x+=a/2,s.isPointInPath(r.x,h)&&(l=r.x)),l;return o/2}$_layoutLabelOutVert(e,i,s,r,o,n,a,h,l){const c=i.point,d=s.isDomAnimating(),u=s.getBBox(),_=c.yPos;!d&&s.layout(r||(o?"right":"left"));let g=t.isIE?this.$_calcLabelPosVertIE(e,i,o):this.$_calcLabelPosVert(e,i,o);n&&(o?n.setLine(a.reset(0,0).line(-l,0).end()):n.setLine(a.reset(0,0).line(l,0).end()),n.trans(g,_)),o?g-=l+h+u.width:g+=l+h,s.trans(g,_-u.height/2)}$_layoutLabelNearVert(e,i,s,r,o,n,a,h,l,c,d){const u=i.point,_=s.isDomAnimating(),g=s.getBBox(),p=u.yPos;!_&&s.layout(r||(o?"right":"left"));const m=t.isIE?this.$_calcLabelPosVertIE(e,i,o):this.$_calcLabelPosVert(e,i,o);let y=l;o?y-=h/2:y+=h/2,n&&(o?n.setLine(a.reset(0,0).line(y-m-d,0).end()):n.setLine(a.reset(0,0).line(y+d-m,0).end()),n.trans(m,p)),o?y-=c+d+g.width:y+=d+c,s.trans(y,p-g.height/2)}$_layoutLabelFarVert(e,i,s,r,o,n,a,h,l,c,d,u){const _=i.point,g=s.isDomAnimating(),p=s.getBBox(),m=_.yPos;!g&&s.layout(r||(o?"right":"left"));const y=t.isIE?this.$_calcLabelPosVertIE(e,i,o):this.$_calcLabelPosVert(e,i,o);let f;f=o?l+h+c-d.x:u-d.x-l-c-h,n&&(o?n.setLine(a.reset(0,0).line(f-y-l,0).end()):n.setLine(a.reset(0,0).line(f+l-y,0).end()),n.trans(y,m)),o?f-=h+l+p.width:f+=l+h,s.trans(f,m-p.height/2)}$_calcLabelPosHorz(e,t,i){const s=e.dom,r=s.ownerSVGElement.createSVGPoint(),{hFigure:o,sy:n}=e,a=2*(e.sy<0?1:1/e.sy);let h=i?e.hFigure:0;if(r.x=t.point.xPos/e.sx,i){for(;h>=0;h-=a)if(r.y=h,s.isPointInFill(r))return h<e.hFigure&&(r.y+=a/2,s.isPointInFill(r)&&(h=r.y)),h*n}else for(;h<o;h+=a)if(r.y=h,s.isPointInFill(r))return h>0&&(r.y-=a/2,s.isPointInFill(r)&&(h=r.y)),h*n;return e.hFigure*e.sy/2}$_calcLabelPosHorzIE(e,t,i){const s=this.control.canvasCtx(),r={x:0,y:0},{hFigure:o,sy:n}=e,a=2*(e.sy<0?1:1/e.sy);let h=r.x=t.point.xPos,l=i?o*n:0;if(i){for(;l>=0;l-=a)if(r.y=l,s.isPointInPath(h,r.y))return l<o*n&&(r.y+=a/2,s.isPointInPath(h,r.y)&&(l=r.y)),l}else for(;l<o;l+=a)if(r.y=l,s.isPointInPath(h,r.y))return l>0&&(r.y-=a/2,s.isPointInPath(h,r.y)&&(l=r.y)),l;return e.hFigure*e.sy/2}$_layoutLabelOutHorz(e,i,s,r,o,n,a,h,l){const c=i.point,d=s.isDomAnimating(),u=s.getBBox(),_=c.xPos;!d&&s.layout(r);let g=t.isIE?this.$_calcLabelPosHorzIE(e,i,o):this.$_calcLabelPosHorz(e,i,o);n&&(o?n.setLine(a.reset(0,0).line(0,l).end()):n.setLine(a.reset(0,0).line(0,-l).end()),n.trans(_,g)),o?g+=l+h:g-=l+h,s.trans(_-u.width/2,o?g:g-u.height)}$_layoutLabelNearHorz(e,i,s,r,o,n,a,h,l,c,d){const u=i.point,_=s.isDomAnimating(),g=s.getBBox(),p=u.xPos;!_&&s.layout(r||(o?"right":"left"));let m=t.isIE?this.$_calcLabelPosHorzIE(e,i,o):this.$_calcLabelPosHorz(e,i,o),y=l;o?y+=h/2:y-=h/2,n&&(o?n.setLine(a.reset(0,0).line(0,y+d-m).end()):n.setLine(a.reset(0,0).line(0,y-m-d).end()),n.trans(p,m)),o?y+=d+c:y-=c+d+g.height,s.trans(p-g.width/2,y)}$_layoutLabelFarHorz(e,i,s,r,o,n,a,h,l,c,d,u){const _=i.point,g=s.isDomAnimating(),p=s.getBBox(),m=_.xPos;!g&&s.layout(r||(o?"right":"left"));const y=t.isIE?this.$_calcLabelPosHorzIE(e,i,o):this.$_calcLabelPosHorz(e,i,o);let f;f=o?u-d.y-l-c-h:l+h+c-d.y,n&&(o?n.setLine(a.reset(0,0).line(0,f+l-y).end()):n.setLine(a.reset(0,0).line(0,f-y-l).end()),n.trans(m,y)),o?f+=l+h:f-=h+l+p.height,s.trans(m-p.width/2,f)}}function y(e){(function(e){return!!(e&&e.Series&&e.SeriesView)})(e)&&(e.Series.register(r),e.Series.register(h),e.Series.register(u),e.SeriesView.register([r,n]),e.SeriesView.register([h,g]),e.SeriesView.register([u,m]))}y(s),e.PictogramSeries=r,e.PictorialBarSeries=h,e.PictorialSeries=u,e.default=y,Object.defineProperty(e,"__esModule",{value:!0})});
|
package/pictogram.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
/**
|
|
3
|
-
* RealChart Pictogram v1.
|
|
3
|
+
* RealChart Pictogram v1.5.0
|
|
4
4
|
* Copyright (C) 2023-2026 WooriTech Inc.
|
|
5
5
|
* All Rights Reserved.
|
|
6
6
|
*/
|
|
7
|
-
import{PictogramSeriesType as e,extend as t,BasedSeries as i,RectElement as s,Series as r,BasedSeriesView as o,PointViewPool as n,RcElement as h,SeriesView as a,PictorialBarSeriesType as l,BarSeriesBase as _,calcPercent as d,isArray as u,isString as g,pickNum as c,parsePercentSize as p,BarSeriesPoint as y,pickProp as f,PictorialSeriesType as w,WidgetSeries as m,WidgetSeriesLabel as P,minv as V,WidgetSeriesPoint as b,BarSeriesViewBase as v,SVGNS as x,Utils as L,Dom as S,pixel as $,BoxPointElementEx as C,PathElement as A,ImageElement as F,SvgShapes as B,WidgetSeriesView as D,LayerElement as E,PointLabelLineContainer as I,SeriesAnimation as R,isIE as N,fixnum as k,PathBuilder as H,maxv as z,PointElement as T}from"./index.mjs";class M extends i{_createLegendMarker(e,t){return s.create(e,r.LEGEND_MARKER,0,0,t,t,2)}}M.type=e,M.defaults=t(i.defaults,{iconGap:2,integral:!1,integralThreshold:.5});class O extends h{constructor(e){super(e,a.POINT_CLASS),this.add(this._back=new s(e)),this._back.setTransparent(!0)}preppareIcons(e,t,i,s){}layout(e,t,i){const s=this.wPoint,r=this.hPoint;t-=s/2,r<0&&(e=e.map(e=>-e)),this._back.setBounds(t,i-r,s,r)}}class G extends o{constructor(e){super(e,"rct-pictogram-series"),this._bars=new n(this._pointContainer,O)}_getPointPool(){return this._bars}_preparePoints(e,t,i){}_shrinkPoint(e){}_layoutPoint(e,t,i,s,r,o){}}class W extends y{_readObject(e,t){super._readObject(e,t),this.figure=f(e._figureFielder(t),t.figure)}_readArray(e,t){super._readArray(e,t);const i=+e.prop("figureField");isNaN(i)||(this.figure=t[i])}}class U extends _{getMode(){return this._mode}getFigure(){return this._figurePath}getImage(e){let t=e.figure;return"number"==typeof t&&(t=this._imageUrls[t]),!t&&this.prop("figureByPoint")&&(t=this._imageUrls[e.vindex%this._imageUrls.length]),this._imageRoot+(t||this._imageUrls[0])}getFigureWidth(e){return d(this._widthDim,e,e)}getFigureGap(){return this._figureGap}_createPoint(e){return new W(e)}_createLegendMarker(e,t){return s.create(e,r.LEGEND_MARKER,0,0,t,t,2)}_doApply(e){super._doApply(e),this._figureFielder=this._createFielder(e.figureField||"figure"),this._figurePath=u(e.figurePath)?e.figurePath.join(" "):e.figurePath;const t=e.figureImage;u(t)?this._imageUrls=t.slice(0):g(t)?this._imageUrls=[t]:this._imageUrls=[],this._imageRoot=g(e.figureImageRoot)?e.figureImageRoot:"",this._mode="both"===e.mode||"figure"===e.mode?e.mode:e.figurePath?"both":"figure",this._figureGap=c(e.figureGap,0),this._widthDim=p(e.figureWidth,!0)}}U.type=l,U.defaults=t(_.defaults,{mode:"auto",figureWidth:"100%"});class j extends b{}class K extends j{constructor(e,t){super(e),this.points=t}}class q extends P{getDistance(){const e=this.num("distance");return isNaN(e)?"far"===this.prop("align")?q.ENDED_DIST:q.OUTSIDE_DIST:e||0}}q.OUTSIDE_DIST=25,q.ENDED_DIST=10;class Y extends m{get paths(){return this._paths}getPictorialSize(e,t,i){const s=d(this._sizeDim,1),r=V(t*s/e.width,i*s/e.height);return{width:c(d(this._widthDim,t),e.width*r),height:c(d(this._heightDim,i),e.height*r)}}get pointLabel(){return this._pointLabel}_createLabel(e){return new q(e)}_createPoint(e){return new j(e)}_createOthersPoint(e,t){return e.y=t.map(e=>e.y).reduce((e,t)=>e+t),new K(e,t)}needClip(e){return!1}getTotal(){const e=super.getSum();return Math.max(e,d(this._totalDim,e))}getSum(){const e=super.getSum(),t=d(this._totalDim,e);return Math.max(e,c(t,e))}_doApply(e){super._doApply(e),this._paths=u(e.figure)?e.figure:[e.figure||""],this._setDims(e,"total","width","height"),this._sizeDim=p(this.prop("size"),!1)}_createLegendMarker(e,t){return s.create(e,r.LEGEND_MARKER,0,0,t,t,2)}}Y.type=w,Y.defaults=t(m.defaults,{size:"90%",reversed:!1});class Z extends C{constructor(e){super(e),this.add(this._figureLayer=new h(e,"")),this._figureLayer.add(this._figureView=new A(e,"")),this.add(this._imageLayer=new h(e,"")),this._imageLayer.add(this._imageView=new F(e,!1,"")),this._imageView.setAttr("preserveAspectRatio","none"),this.add(this._boxView=new A(e,"")),this._figureView.setAttr("vector-effect","non-scaling-stroke")}renderSvg(e,t,i,s,r){const o=this._figureView;let n;this._imageLayer.setVis(!1),this._figureLayer.setVis(!0),o.scale(1),o.setPath(s),n=o.getBounds(),e.both?o.scale(r/(e.inverted?n.height:n.width)):e.inverted?o.scale(r/n.height,(e.reversed?-1:1)*this.hPoint/n.width):o.scale(r/n.width,(e.reversed?-1:1)*this.hPoint/n.height),this.$_layoutFigure(e,this._figureLayer,this._figureView,t,i)}renderImage(e,t,i,s,r){const o=this._imageView;this._figureLayer.setVis(!1),this._imageLayer.setVis(!0),o.url=s,o.width=r,o.height=e.both?void 0:Math.abs(this.hPoint),this.$_layoutFigure(e,this._imageLayer,o,t,i)}$_layoutFigure(e,t,i,s,r){const o=i.getBounds(),n=!e.upperClip;let h=this.hPoint,a=!1;e.inverted?e.reversed?n?(i.trans(s+o.height/2,r-h),this._dir="left"):h<0?(i.trans(s+o.height/2,-e.yBase-h),this._dir="left"):(i.trans(s-o.height/2,-e.yBase-h),this._dir="right"):n?(i.trans(s-o.height/2,-h),this._dir="right"):h<0?(i.trans(s+o.height/2,-e.yBase-h),this._dir="left"):(i.trans(s-o.height/2,-e.yBase-h),this._dir="right"):e.reversed?n?(i.trans(s+o.width/2,-h),this._dir="bottom"):h<0?(i.trans(s+o.width/2,e.yLen-e.yBase-h),this._dir="bottom"):(i.trans(s-o.width/2,e.yLen-e.yBase-h),this._dir="top"):n?(i.trans(s-o.width/2,r-h),this._dir="top"):h<0?(i.trans(s+o.width/2,e.yLen-e.yBase-h),this._dir="bottom"):(i.trans(s-o.width/2,e.yLen-e.yBase-h),this._dir="top"),n?(i.rotate(e.reversed?180:0),t.removeAttr("clip-path")):(a=this.point.yValue<e.base,e.reversed&&(a=!a),S.setClipPath(t.dom,a?e.lowerClip:e.upperClip),i.rotate(a?180:0)),this._boxView.setVis(e.both)&&(a||(a=n&&e.reversed),h-=(a?-1:1)*((e.inverted?o.width:o.height)+e.gap),this.$_layoutBox(e,a,s,r,h))}$_layoutBox(e,t,i,s,r){this._boxView.setVis(t?r<0:r>0)&&this._boxView.setPath(B.bar(i-this.wPoint/2,s,this.wPoint,-r,e.rTop,e.rBottom))}}class J extends v{constructor(e){super(e,"rct-pictorialbar-series")}_createBarPool(e,t){return new n(e,Z)}_prepareLayoutPoints(e,t){const i=this.model,s=this._yBase,r=this._baseVal>i._yAxisObj.axisMin();if(this._info={inverted:this._inverted,reversed:this._yReversed,base:this._baseVal,yBase:s,both:"both"===i.getMode(),gap:i.getFigureGap(),yLen:this._yLen,rTop:+i.prop("topRadius")||0,rBottom:+i.prop("bottomRadius")||0,upperClip:"",lowerClip:""},r){if(!this._upperClip){const e=this.doc,t=this.dom.querySelector("defs")||e.createElementNS(x,"defs"),i=L.uniqueKey()+"-";this.insertDom(t,this._pointContainer.dom),t.appendChild(this._upperClip=S.createClipRect(e,i+"upper")),t.appendChild(this._lowerClip=S.createClipRect(e,i+"lower"))}const i=this._upperClip.firstElementChild,r=this._lowerClip.firstElementChild;this._inverted?(S.setBounds(i,0,-e,t,e-s),S.setBounds(r,0,-s,t,e)):(S.setBounds(i,0,0,e,t-s),S.setBounds(r,0,t-s,e,s)),this._info.upperClip=this._upperClip.id,this._info.lowerClip=this._lowerClip.id}}_shrinkPoint(e){}_layoutPoint(e,t,i,s,r,o){const n=e.point,h=this.model.getFigure();this._needMask=h&&this._info.both,e.wPoint=r*c(n.width,1),e.hPoint=o,e.x=i,h?e.renderSvg(this._info,i,s,h,this._model.getFigureWidth(r)):e.renderImage(this._info,i,s,this._model.getImage(n),this._model.getFigureWidth(r))}setHoverStyle(e){if(super.setHoverStyle(e),this._needMask){const t=getComputedStyle(e.dom),i="none"!==t.stroke?parseFloat(t.strokeWidth):0;if(this._hoverFigureView.parent.setVis(i>0&&this._info.gap<i)){S.setImportantStyle(e.dom.style,"stroke-width",$(i+i/2|0));let t=0,s=0;switch(e._dir){case"top":case"right":s=-i/2;break;case"bottom":case"left":s=i/2}this._hoverBoxView.setAttribute("transform",`translate(${t}, ${s})`)}}}focusPointView(e,t){t&&this._needMask?this.$_showHoverView(this._hoverPoint=e).setVis(!0):this._hoverFigureView&&(this._hoverFigureView.parent.setVis(!1),this._hoverPoint=null)}_renderSeries(e,t){super._renderSeries(e,t),this._hoverPoint&&this._hoverFigureView&&this._hoverFigureView.parent.visible&&this.$_showHoverView(this._hoverPoint)}$_showHoverView(e){let t=this._hoverFigureView;if(!t){const e=this.doc;let i;this.add(new h(e,"")).add(t=this._hoverFigureView=new h(e,"")),t.parent.dom.style.pointerEvents="none",t.appendDom(i=e.createElementNS(x,"path")),i.style.stroke="none",t.parent.appendDom(i=this._hoverBoxView=e.createElementNS(x,"path")),i.style.stroke="none"}const i=t.dom.firstElementChild,s=this._hoverBoxView;return t.parent.setAttr("clip-path",this._pointContainer.getAttr("clip-path")),t.setAttr("clip-path",e._figureLayer.getAttr("clip-path")),i.setAttribute("d",e._figureView.getAttr("d")),i.style.fill=getComputedStyle(e._figureView.dom).fill,i.setAttribute("transform",e._figureView.getTransform()),S.setVisible(s,e._boxView.visible)&&(s.setAttribute("d",e._boxView.getAttr("d")),s.style.fill=getComputedStyle(e._boxView.dom).fill),this._inverted&&t.parent.setAttr("transform",`rotate(90) translate(${this.height},0) scale(-1, 1)`),t}}class Q extends T{getTooltipPos(){return{x:this.point.xPos+this.parent.parent.tx,y:this.point.yPos+this.parent.parent.ty}}}class X extends D{constructor(e){super(e,"rct-pictorial-series");const t=L.uniqueKey()+"-",i=t+"figure",s=t+"clip",r=t+"hover";this._figurelView=e.createElementNS(x,"use"),this._figurelView.setAttribute("href",`#${i}`),this._figurelView.setAttribute("class","rct-pictorial-series-figure"),this.insertDom(this._figurelView,this._pointContainer.dom);const o=e.createElementNS(x,"defs");this.insertDom(o,this._figurelView),this._sourceView=new A(e),this._sourceView.setAttr("vector-effect","non-scaling-stroke"),this._sourceView.dom.id=i,o.appendChild(this._sourceView.dom);const h=e.createElementNS(x,"use"),a=e.createElementNS(x,"clipPath"),l=e.createElementNS(x,"clipPath");h.setAttribute("href",`#${i}`),a.appendChild(h),a.id=s,o.appendChild(a),l.appendChild(this._hoverRect=e.createElementNS(x,"path")),l.id=r,o.appendChild(l),this._hoverView=e.createElementNS(x,"use"),this._hoverView.setAttribute("href",`#${i}`),this._hoverView.setAttribute("clip-path",`url(#${r}`),this._hoverView.style.stroke="none",this._hoverView.style.fill="none",this.appendDom(this._hoverView),this._pointContainer.add(this._sliceLayer=new E(e,null)),this._pointContainer.setAttr("clip-path",`url(#${s})`),this._slices=new n(this._sliceLayer,Q),this.add(this._lineContainer=new I(e))}_getPointPool(){return this._slices}getClipContainer(){return null}_prepareSeries(e,t){super._prepareSeries(e,t),this.$_prepareSlices(e,t,this._visPoints),this._lineContainer.prepare(t)}_renderSeries(e,t){this.$_renderFigure(this._sourceView,this._model,e,t);const i=this._visPoints,s=this.model.getCenter(e,t),r=this._figurelView.getBoundingClientRect(),o=s.x-r.width/2,n=s.y-r.height/2,h=`translate(${o},${n})`;S.hasFill(this._figurelView)||(this._figurelView.style.fill="transparent"),this._figurelView.setAttribute("transform",h),this._hoverView.setAttribute("transform",h),r.x=o,r.y=n,this.$_layoutSlices(i,r,e,t),this._pointContainer.trans(o,n),this._labelContainer.trans(o,n),this._lineContainer.trans(o,n),this.resize(r.width,r.height),this._rSave=r,this._wSave=e,this._hSave=t}_runShowEffect(e){const t=this.model.prop("reversed");e&&R.reveal(this,{from:"column"===this.model.prop("direction")?t?"right":"left":t?"top":"bottom",view:this._sliceLayer})}_refreshZombie(){this.$_layoutSlices(this._visPoints,this._rSave,this._wSave,this._hSave),this._hoverPoint&&!S.isHidden(this._hoverView)&&this.$_showHoverView(this._hoverPoint)}_animationStarted(e){super._animationStarted(e),this._lineContainer.setVis(this._labelContainer.visible)}setHoverStyle(e){super.setHoverStyle(e);const t=getComputedStyle(e.dom),i="none"!==t.stroke&&parseFloat(t.strokeWidth)>0;S.setVisible(this._hoverView,i)&&Object.assign(this._hoverView.style,{stroke:t.stroke,strokeWidth:t.strokeWidth,strokeDasharray:t.strokeDasharray})}focusPointView(e,t){this._hoverView.style.display=t?"":"none",t&&this.$_showHoverView(e),this._hoverPoint=t?e:null}$_showHoverView(e){this._hoverRect.setAttribute("d",e.getAttr("d"))}$_prepareSlices(e,t,i){this._slices.prepare(i.length,(s,r)=>{const o=s.point=i[r];this._preparePoint(e,t,o,s)})}$_renderFigure(e,t,i,s){let r,o;e.setPath(t.paths),r=e.getBBox(),o=t.getPictorialSize(r,i,s),e.scale(o.width/r.width,o.height/r.height),N&&this.$_prepareOutline(this._sourceView.dom,i,s,o.width/r.width,o.height/r.height)}$_layoutSlices(e,t,i,s){const r=this._model,o=r.pointLabel,n=r.prop("reversed");this.$_calcRates(e),this._lineContainer.setStyleOrClass(o.connector.prop("style")),"column"===r.prop("direction")?this.$_renderHorz(n,t,s):this.$_renderVert(n,t,i)}$_calcRates(e){const t=this._zombie,i=this._zombieRate,s=e.length;let r=this.model.getTotal();(isNaN(r)||e.find(e=>e._isDeleted()))&&(r=e.filter(e=>(e.visible||e===t)&&!e.isNull).map(e=>e.yValue*(e===t?i:e._isDeleted()?e._vr:1)).reduce((e,t)=>e+t,0)),s>1||s>0&&!t?1==s&&e[0]._isDeleted()||1===s&&e[0]._vr<1?e[0].yRate=1:e.forEach(e=>{const s=k(e.yValue*(e===t?i:e._isDeleted()?e._vr:1)/r)||0;e.yRate=s}):1==s&&(e[0].yRate=k(i))}$_createLabelInfo(e){const{a:t,d:i}=e.getCTM(),{width:s,height:r}=e.getBBox();return{dom:e,sx:t,sy:i,wFigure:s,hFigure:r}}$_renderVert(e,t,i){const s=this.model,r=t.width,o=t.height,n=this._labelViews(),h=s.pointLabel,a="inside"===s.getLabelPos(h),l=h.getOffset(),_=h.getDistance(),d=h.getWidgetAlign(),u=null==n?void 0:n.textAlign(),g=[],c=h.prop("opposite"),p=this._lineContainer.setVis(h.connector.visible)?this._lineContainer:null,y=new H,f=s.getCenter(i,o).x-t.x,w=r/2;let m=e?0:o;const P=n?n.getWidth(0):0,V=g&&!a&&this.$_createLabelInfo(this._sourceView.dom);let b,v;this._slices.forEach(s=>{const h=s.point;if(s.setVis(!h.isNull)){const x=o*h.yRate;if(e?(s.setPath(B.rectangle(0,m,r,x)),h.yPos=m+x/2,m+=x):(h.yPos=m-x/2,m-=x,s.setPath(B.rectangle(0,m,r,x))),h.xPos=w,v=null==p?void 0:p.get(h),n&&(b=n.get(h,0))&&b.visible){if(a){const e=b.isDomAnimating(),t=b.getBBox();!e&&b.layout(u||"center"),null==v||v.setVis(!1),b.trans(h.xPos-t.width/2,h.yPos-t.height/2)}else-1===d?this.$_layoutLabelNearVert(V,s,b,u,c,v,y,r,f,l,_):1==d?this.$_layoutLabelFarVert(V,s,b,u,c,v,y,l,_,P,t,i):this.$_layoutLabelOutVert(V,s,b,u,c,v,y,l,_);b.setContrast(a&&s.dom),g.push(b),b.setPosY(b.ty),this._layoutLabelRotation(b)}else v&&v.setVis(!1)}})}$_renderHorz(e,t,i){const s=this.model,r=t.width,o=t.height,n=this._labelViews(),h=s.pointLabel,a="inside"===s.getLabelPos(h),l=h.getOffset(),_=h.getDistance(),d=h.getWidgetAlign(),u=null==n?void 0:n.textAlign(),g=[],c=h.prop("opposite"),p=this._lineContainer.setVis(h.connector.visible)?this._lineContainer:null,y=new H,f=s.getCenter(r,i).y-t.y,w=o/2,m=n?n.getWidth(0):0,P=g&&!a&&this.$_createLabelInfo(this._sourceView.dom);let V,b,v=e?r:0;this._slices.forEach(s=>{const h=s.point;if(s.setVis(!h.isNull)){const x=r*h.yRate;if(e?(h.xPos=v-x/2,v-=x,s.setPath(B.rectangle(v,0,x,o))):(h.xPos=v+x/2,s.setPath(B.rectangle(v,0,x,o)),v+=x),h.yPos=w,b=null==p?void 0:p.get(h),n&&(V=n.get(h,0))&&V.visible){if(a){const e=V.isDomAnimating(),t=V.getBBox();!e&&V.layout(u||"center"),V.trans(h.xPos-t.width/2,h.yPos-t.height/2),null==b||b.setVis(!1)}else-1===d?this.$_layoutLabelNearHorz(P,s,V,u,c,b,y,o,f,l,_):1==d?this.$_layoutLabelFarHorz(P,s,V,u,c,b,y,l,_,m,t,i):this.$_layoutLabelOutHorz(P,s,V,u,c,b,y,l,_);V.setContrast(a&&s.dom),g.push(V),V.setPosY(V.ty),this._layoutLabelRotation(V)}else b&&b.setVis(!1)}})}$_prepareOutline(e,t,i,s,r){const o=+new Date,n=this.control.canvasCtx(),h=e.getTotalLength(),a=z(1,Math.round(h/500));let l;n.setTransform(1,0,0,1,0,0),n.clearRect(0,0,t,i),n.scale(s,r),n.fillStyle="red",n.beginPath(),l=e.getPointAtLength(0),n.moveTo(l.x,l.y);for(let t=0;t<h;t+=a)l=e.getPointAtLength(t),n.lineTo(l.x,l.y);n.closePath(),n.fill(),console.log("canvas",+new Date-o,"ms.")}$_calcLabelPosVert(e,t,i){const s=e.dom,r=s.ownerSVGElement.createSVGPoint(),{wFigure:o,sx:n}=e,h=2*(e.sx<0?1:1/e.sx);let a=i?0:e.wFigure;if(r.y=t.point.yPos/e.sy,i){for(;a<o;a+=h)if(r.x=a,s.isPointInFill(r))return a>0&&(r.x-=h/2,s.isPointInFill(r)&&(a=r.x)),a*n}else for(;a>=0;a-=h)if(r.x=a,s.isPointInFill(r))return a<o&&(r.x+=h/2,s.isPointInFill(r)&&(a=r.x)),a*n;return e.wFigure*e.sx/2}$_calcLabelPosVertIE(e,t,i){const s=this.control.canvasCtx(),r={x:0,y:0},{wFigure:o,sx:n}=e,h=2*(n<0?1:1/n);let a=r.y=t.point.yPos,l=i?0:o*n;if(i){for(const e=o*n;l<e;l+=h)if(r.x=l,s.isPointInPath(r.x,a))return l>0&&(r.x-=h/2,s.isPointInPath(r.x,a)&&(l=r.x)),l}else for(;l>=0;l-=h)if(r.x=l,s.isPointInPath(l,a))return l<o*n&&(r.x+=h/2,s.isPointInPath(r.x,a)&&(l=r.x)),l;return o/2}$_layoutLabelOutVert(e,t,i,s,r,o,n,h,a){const l=t.point,_=i.isDomAnimating(),d=i.getBBox(),u=l.yPos;!_&&i.layout(s||(r?"right":"left"));let g=N?this.$_calcLabelPosVertIE(e,t,r):this.$_calcLabelPosVert(e,t,r);o&&(r?o.setLine(n.reset(0,0).line(-a,0).end()):o.setLine(n.reset(0,0).line(a,0).end()),o.trans(g,u)),r?g-=a+h+d.width:g+=a+h,i.trans(g,u-d.height/2)}$_layoutLabelNearVert(e,t,i,s,r,o,n,h,a,l,_){const d=t.point,u=i.isDomAnimating(),g=i.getBBox(),c=d.yPos;!u&&i.layout(s||(r?"right":"left"));const p=N?this.$_calcLabelPosVertIE(e,t,r):this.$_calcLabelPosVert(e,t,r);let y=a;r?y-=h/2:y+=h/2,o&&(r?o.setLine(n.reset(0,0).line(y-p-_,0).end()):o.setLine(n.reset(0,0).line(y+_-p,0).end()),o.trans(p,c)),r?y-=l+_+g.width:y+=_+l,i.trans(y,c-g.height/2)}$_layoutLabelFarVert(e,t,i,s,r,o,n,h,a,l,_,d){const u=t.point,g=i.isDomAnimating(),c=i.getBBox(),p=u.yPos;!g&&i.layout(s||(r?"right":"left"));const y=N?this.$_calcLabelPosVertIE(e,t,r):this.$_calcLabelPosVert(e,t,r);let f;f=r?a+h+l-_.x:d-_.x-a-l-h,o&&(r?o.setLine(n.reset(0,0).line(f-y-a,0).end()):o.setLine(n.reset(0,0).line(f+a-y,0).end()),o.trans(y,p)),r?f-=h+a+c.width:f+=a+h,i.trans(f,p-c.height/2)}$_calcLabelPosHorz(e,t,i){const s=e.dom,r=s.ownerSVGElement.createSVGPoint(),{hFigure:o,sy:n}=e,h=2*(e.sy<0?1:1/e.sy);let a=i?e.hFigure:0;if(r.x=t.point.xPos/e.sx,i){for(;a>=0;a-=h)if(r.y=a,s.isPointInFill(r))return a<e.hFigure&&(r.y+=h/2,s.isPointInFill(r)&&(a=r.y)),a*n}else for(;a<o;a+=h)if(r.y=a,s.isPointInFill(r))return a>0&&(r.y-=h/2,s.isPointInFill(r)&&(a=r.y)),a*n;return e.hFigure*e.sy/2}$_calcLabelPosHorzIE(e,t,i){const s=this.control.canvasCtx(),r={x:0,y:0},{hFigure:o,sy:n}=e,h=2*(e.sy<0?1:1/e.sy);let a=r.x=t.point.xPos,l=i?o*n:0;if(i){for(;l>=0;l-=h)if(r.y=l,s.isPointInPath(a,r.y))return l<o*n&&(r.y+=h/2,s.isPointInPath(a,r.y)&&(l=r.y)),l}else for(;l<o;l+=h)if(r.y=l,s.isPointInPath(a,r.y))return l>0&&(r.y-=h/2,s.isPointInPath(a,r.y)&&(l=r.y)),l;return e.hFigure*e.sy/2}$_layoutLabelOutHorz(e,t,i,s,r,o,n,h,a){const l=t.point,_=i.isDomAnimating(),d=i.getBBox(),u=l.xPos;!_&&i.layout(s);let g=N?this.$_calcLabelPosHorzIE(e,t,r):this.$_calcLabelPosHorz(e,t,r);o&&(r?o.setLine(n.reset(0,0).line(0,a).end()):o.setLine(n.reset(0,0).line(0,-a).end()),o.trans(u,g)),r?g+=a+h:g-=a+h,i.trans(u-d.width/2,r?g:g-d.height)}$_layoutLabelNearHorz(e,t,i,s,r,o,n,h,a,l,_){const d=t.point,u=i.isDomAnimating(),g=i.getBBox(),c=d.xPos;!u&&i.layout(s||(r?"right":"left"));let p=N?this.$_calcLabelPosHorzIE(e,t,r):this.$_calcLabelPosHorz(e,t,r),y=a;r?y+=h/2:y-=h/2,o&&(r?o.setLine(n.reset(0,0).line(0,y+_-p).end()):o.setLine(n.reset(0,0).line(0,y-p-_).end()),o.trans(c,p)),r?y+=_+l:y-=l+_+g.height,i.trans(c-g.width/2,y)}$_layoutLabelFarHorz(e,t,i,s,r,o,n,h,a,l,_,d){const u=t.point,g=i.isDomAnimating(),c=i.getBBox(),p=u.xPos;!g&&i.layout(s||(r?"right":"left"));const y=N?this.$_calcLabelPosHorzIE(e,t,r):this.$_calcLabelPosHorz(e,t,r);let f;f=r?d-_.y-a-l-h:a+h+l-_.y,o&&(r?o.setLine(n.reset(0,0).line(0,f+a-y).end()):o.setLine(n.reset(0,0).line(0,f-y-a).end()),o.trans(p,y)),r?f+=a+h:f-=h+a+c.height,i.trans(p-c.width/2,f)}}function ee(e){(function(e){return e.Series&&e.SeriesView})(e)&&(e.Series.register(M),e.Series.register(U),e.Series.register(Y),e.SeriesView.register([M,G]),e.SeriesView.register([U,J]),e.SeriesView.register([Y,X]))}export{M as PictogramSeries,U as PictorialBarSeries,Y as PictorialSeries,ee as default};
|
|
7
|
+
import*as e from"./index.mjs";import{PictogramSeriesType as t,extend as i,BasedSeries as s,RectElement as r,Series as o,BasedSeriesView as n,PointViewPool as h,RcElement as a,SeriesView as l,PictorialBarSeriesType as _,BarSeriesBase as d,calcPercent as u,isArray as g,isString as c,pickNum as p,parsePercentSize as y,BarSeriesPoint as f,pickProp as m,PictorialSeriesType as w,WidgetSeries as P,WidgetSeriesLabel as V,minv as b,WidgetSeriesPoint as v,BarSeriesViewBase as x,SVGNS as L,Utils as S,Dom as $,pixel as C,BoxPointElementEx as A,PathElement as F,ImageElement as B,SvgShapes as D,WidgetSeriesView as E,LayerElement as I,PointLabelLineContainer as R,SeriesAnimation as N,isIE as k,fixnum as H,PathBuilder as z,maxv as T,PointElement as M}from"./index.mjs";class O extends s{_createLegendMarker(e,t){return r.create(e,o.LEGEND_MARKER,0,0,t,t,2)}}O.type=t,O.defaults=i(s.defaults,{iconGap:2,integral:!1,integralThreshold:.5});class G extends a{constructor(e){super(e,l.POINT_CLASS),this.add(this._back=new r(e)),this._back.setTransparent(!0)}preppareIcons(e,t,i,s){}layout(e,t,i){const s=this.wPoint,r=this.hPoint;t-=s/2,r<0&&(e=e.map(e=>-e)),this._back.setBounds(t,i-r,s,r)}}class W extends n{constructor(e){super(e,"rct-pictogram-series"),this._bars=new h(this._pointContainer,G)}_getPointPool(){return this._bars}_preparePoints(e,t,i){this._bars.prepare(i.length,(e,s)=>{const r=e.point=i[s];this._setPointStyle(e,t,r)})}_shrinkPoint(e){}_layoutPoint(e,t,i,s,r,o){e.wPoint=r,e.hPoint=o,e.layout(this._pts||[],i,s)}}class U extends f{_readObject(e,t){super._readObject(e,t),this.figure=m(e._figureFielder(t),t.figure)}_readArray(e,t){super._readArray(e,t);const i=+e.prop("figureField");isNaN(i)||(this.figure=t[i])}}class j extends d{getMode(){return this._mode}getFigure(){return this._figurePath}getImage(e){let t=e.figure;return"number"==typeof t&&(t=this._imageUrls[t]),!t&&this.prop("figureByPoint")&&(t=this._imageUrls[e.vindex%this._imageUrls.length]),this._imageRoot+(t||this._imageUrls[0])}getFigureWidth(e){return u(this._widthDim,e,e)}getFigureGap(){return this._figureGap}_createPoint(e){return new U(e)}_createLegendMarker(e,t){return r.create(e,o.LEGEND_MARKER,0,0,t,t,2)}_doApply(e){super._doApply(e),this._figureFielder=this._createFielder(e.figureField||"figure"),this._figurePath=g(e.figurePath)?e.figurePath.join(" "):e.figurePath;const t=e.figureImage;g(t)?this._imageUrls=t.slice(0):c(t)?this._imageUrls=[t]:this._imageUrls=[],this._imageRoot=c(e.figureImageRoot)?e.figureImageRoot:"",this._mode="both"===e.mode||"figure"===e.mode?e.mode:e.figurePath?"both":"figure",this._figureGap=p(e.figureGap,0),this._widthDim=y(e.figureWidth,!0)}}j.type=_,j.defaults=i(d.defaults,{mode:"auto",figureWidth:"100%"});class K extends v{}class q extends K{constructor(e,t){super(e),this.points=t}}class Y extends V{getDistance(){const e=this.num("distance");return isNaN(e)?"far"===this.prop("align")?Y.ENDED_DIST:Y.OUTSIDE_DIST:e||0}}Y.OUTSIDE_DIST=25,Y.ENDED_DIST=10;class Z extends P{get paths(){return this._paths}getPictorialSize(e,t,i){const s=u(this._sizeDim,1),r=b(t*s/e.width,i*s/e.height);return{width:p(u(this._widthDim,t),e.width*r),height:p(u(this._heightDim,i),e.height*r)}}get pointLabel(){return this._pointLabel}_createLabel(e){return new Y(e)}_createPoint(e){return new K(e)}_createOthersPoint(e,t){return e.y=t.map(e=>e.y).reduce((e,t)=>e+t),new q(e,t)}needClip(e){return!1}getTotal(){const e=super.getSum();return Math.max(e,u(this._totalDim,e))}getSum(){const e=super.getSum(),t=u(this._totalDim,e);return Math.max(e,p(t,e))}_doApply(e){super._doApply(e),this._paths=g(e.figure)?e.figure:[e.figure||""],this._setDims(e,"total","width","height"),this._sizeDim=y(this.prop("size"),!1)}_createLegendMarker(e,t){return r.create(e,o.LEGEND_MARKER,0,0,t,t,2)}}Z.type=w,Z.defaults=i(P.defaults,{size:"90%",reversed:!1});class J extends A{constructor(e){super(e),this.add(this._figureLayer=new a(e,"")),this._figureLayer.add(this._figureView=new F(e,"")),this.add(this._imageLayer=new a(e,"")),this._imageLayer.add(this._imageView=new B(e,!1,"")),this._imageView.setAttr("preserveAspectRatio","none"),this.add(this._boxView=new F(e,"")),this._figureView.setAttr("vector-effect","non-scaling-stroke")}renderSvg(e,t,i,s,r){const o=this._figureView;let n;this._imageLayer.setVis(!1),this._figureLayer.setVis(!0),o.scale(1),o.setPath(s),n=o.getBounds(),e.both?o.scale(r/(e.inverted?n.height:n.width)):e.inverted?o.scale(r/n.height,(e.reversed?-1:1)*this.hPoint/n.width):o.scale(r/n.width,(e.reversed?-1:1)*this.hPoint/n.height),this.$_layoutFigure(e,this._figureLayer,this._figureView,t,i)}renderImage(e,t,i,s,r){const o=this._imageView;this._figureLayer.setVis(!1),this._imageLayer.setVis(!0),o.url=s,o.width=r,o.height=e.both?void 0:Math.abs(this.hPoint),this.$_layoutFigure(e,this._imageLayer,o,t,i)}$_layoutFigure(e,t,i,s,r){const o=i.getBounds(),n=!e.upperClip;let h=this.hPoint,a=!1;e.inverted?e.reversed?n?(i.trans(s+o.height/2,r-h),this._dir="left"):h<0?(i.trans(s+o.height/2,-e.yBase-h),this._dir="left"):(i.trans(s-o.height/2,-e.yBase-h),this._dir="right"):n?(i.trans(s-o.height/2,-h),this._dir="right"):h<0?(i.trans(s+o.height/2,-e.yBase-h),this._dir="left"):(i.trans(s-o.height/2,-e.yBase-h),this._dir="right"):e.reversed?n?(i.trans(s+o.width/2,-h),this._dir="bottom"):h<0?(i.trans(s+o.width/2,e.yLen-e.yBase-h),this._dir="bottom"):(i.trans(s-o.width/2,e.yLen-e.yBase-h),this._dir="top"):n?(i.trans(s-o.width/2,r-h),this._dir="top"):h<0?(i.trans(s+o.width/2,e.yLen-e.yBase-h),this._dir="bottom"):(i.trans(s-o.width/2,e.yLen-e.yBase-h),this._dir="top"),n?(i.rotate(e.reversed?180:0),t.removeAttr("clip-path")):(a=this.point.yValue<e.base,e.reversed&&(a=!a),$.setClipPath(t.dom,a?e.lowerClip:e.upperClip),i.rotate(a?180:0)),this._boxView.setVis(e.both)&&(a||(a=n&&e.reversed),h-=(a?-1:1)*((e.inverted?o.width:o.height)+e.gap),this.$_layoutBox(e,a,s,r,h))}$_layoutBox(e,t,i,s,r){this._boxView.setVis(t?r<0:r>0)&&this._boxView.setPath(D.bar(i-this.wPoint/2,s,this.wPoint,-r,e.rTop,e.rBottom))}}class Q extends x{constructor(e){super(e,"rct-pictorialbar-series")}_createBarPool(e,t){return new h(e,J)}_prepareLayoutPoints(e,t){const i=this.model,s=this._yBase,r=this._baseVal>i._yAxisObj.axisMin();if(this._info={inverted:this._inverted,reversed:this._yReversed,base:this._baseVal,yBase:s,both:"both"===i.getMode(),gap:i.getFigureGap(),yLen:this._yLen,rTop:+i.prop("topRadius")||0,rBottom:+i.prop("bottomRadius")||0,upperClip:"",lowerClip:""},r){if(!this._upperClip){const e=this.doc,t=this.dom.querySelector("defs")||e.createElementNS(L,"defs"),i=S.uniqueKey()+"-";this.insertDom(t,this._pointContainer.dom),t.appendChild(this._upperClip=$.createClipRect(e,i+"upper")),t.appendChild(this._lowerClip=$.createClipRect(e,i+"lower"))}const i=this._upperClip.firstElementChild,r=this._lowerClip.firstElementChild;this._inverted?($.setBounds(i,0,-e,t,e-s),$.setBounds(r,0,-s,t,e)):($.setBounds(i,0,0,e,t-s),$.setBounds(r,0,t-s,e,s)),this._info.upperClip=this._upperClip.id,this._info.lowerClip=this._lowerClip.id}}_shrinkPoint(e){}_layoutPoint(e,t,i,s,r,o){const n=e.point,h=this.model.getFigure();this._needMask=h&&this._info.both,e.wPoint=r*p(n.width,1),e.hPoint=o,e.x=i,h?e.renderSvg(this._info,i,s,h,this._model.getFigureWidth(r)):e.renderImage(this._info,i,s,this._model.getImage(n),this._model.getFigureWidth(r))}setHoverStyle(e){if(super.setHoverStyle(e),this._needMask){const t=getComputedStyle(e.dom),i="none"!==t.stroke?parseFloat(t.strokeWidth):0;if(this._hoverFigureView.parent.setVis(i>0&&this._info.gap<i)){$.setImportantStyle(e.dom.style,"stroke-width",C(i+i/2|0));let t=0,s=0;switch(e._dir){case"top":case"right":s=-i/2;break;case"bottom":case"left":s=i/2}this._hoverBoxView.setAttribute("transform",`translate(${t}, ${s})`)}}}focusPointView(e,t){t&&this._needMask?this.$_showHoverView(this._hoverPoint=e).setVis(!0):this._hoverFigureView&&(this._hoverFigureView.parent.setVis(!1),this._hoverPoint=null)}_renderSeries(e,t){super._renderSeries(e,t),this._hoverPoint&&this._hoverFigureView&&this._hoverFigureView.parent.visible&&this.$_showHoverView(this._hoverPoint)}$_showHoverView(e){let t=this._hoverFigureView;if(!t){const e=this.doc;let i;this.add(new a(e,"")).add(t=this._hoverFigureView=new a(e,"")),t.parent.dom.style.pointerEvents="none",t.appendDom(i=e.createElementNS(L,"path")),i.style.stroke="none",t.parent.appendDom(i=this._hoverBoxView=e.createElementNS(L,"path")),i.style.stroke="none"}const i=t.dom.firstElementChild,s=this._hoverBoxView;return t.parent.setAttr("clip-path",this._pointContainer.getAttr("clip-path")),t.setAttr("clip-path",e._figureLayer.getAttr("clip-path")),i.setAttribute("d",e._figureView.getAttr("d")),i.style.fill=getComputedStyle(e._figureView.dom).fill,i.setAttribute("transform",e._figureView.getTransform()),$.setVisible(s,e._boxView.visible)&&(s.setAttribute("d",e._boxView.getAttr("d")),s.style.fill=getComputedStyle(e._boxView.dom).fill),this._inverted&&t.parent.setAttr("transform",`rotate(90) translate(${this.height},0) scale(-1, 1)`),t}}class X extends M{getTooltipPos(){return{x:this.point.xPos+this.parent.parent.tx,y:this.point.yPos+this.parent.parent.ty}}}class ee extends E{constructor(e){super(e,"rct-pictorial-series");const t=S.uniqueKey()+"-",i=t+"figure",s=t+"clip",r=t+"hover";this._figurelView=e.createElementNS(L,"use"),this._figurelView.setAttribute("href",`#${i}`),this._figurelView.setAttribute("class","rct-pictorial-series-figure"),this.insertDom(this._figurelView,this._pointContainer.dom);const o=e.createElementNS(L,"defs");this.insertDom(o,this._figurelView),this._sourceView=new F(e),this._sourceView.setAttr("vector-effect","non-scaling-stroke"),this._sourceView.dom.id=i,o.appendChild(this._sourceView.dom);const n=e.createElementNS(L,"use"),a=e.createElementNS(L,"clipPath"),l=e.createElementNS(L,"clipPath");n.setAttribute("href",`#${i}`),a.appendChild(n),a.id=s,o.appendChild(a),l.appendChild(this._hoverRect=e.createElementNS(L,"path")),l.id=r,o.appendChild(l),this._hoverView=e.createElementNS(L,"use"),this._hoverView.setAttribute("href",`#${i}`),this._hoverView.setAttribute("clip-path",`url(#${r}`),this._hoverView.style.stroke="none",this._hoverView.style.fill="none",this.appendDom(this._hoverView),this._pointContainer.add(this._sliceLayer=new I(e,null)),this._pointContainer.setAttr("clip-path",`url(#${s})`),this._slices=new h(this._sliceLayer,X),this.add(this._lineContainer=new R(e))}_getPointPool(){return this._slices}getClipContainer(){return null}_prepareSeries(e,t){super._prepareSeries(e,t),this.$_prepareSlices(e,t,this._visPoints),this._lineContainer.prepare(t)}_renderSeries(e,t){this.$_renderFigure(this._sourceView,this._model,e,t);const i=this._visPoints,s=this.model.getCenter(e,t),r=this._figurelView.getBoundingClientRect(),o=s.x-r.width/2,n=s.y-r.height/2,h=`translate(${o},${n})`;$.hasFill(this._figurelView)||(this._figurelView.style.fill="transparent"),this._figurelView.setAttribute("transform",h),this._hoverView.setAttribute("transform",h),r.x=o,r.y=n,this.$_layoutSlices(i,r,e,t),this._pointContainer.trans(o,n),this._labelContainer.trans(o,n),this._lineContainer.trans(o,n),this.resize(r.width,r.height),this._rSave=r,this._wSave=e,this._hSave=t}_runShowEffect(e){const t=this.model.prop("reversed");e&&N.reveal(this,{from:"column"===this.model.prop("direction")?t?"right":"left":t?"top":"bottom",view:this._sliceLayer})}_refreshZombie(){this.$_layoutSlices(this._visPoints,this._rSave,this._wSave,this._hSave),this._hoverPoint&&!$.isHidden(this._hoverView)&&this.$_showHoverView(this._hoverPoint)}_animationStarted(e){super._animationStarted(e),this._lineContainer.setVis(this._labelContainer.visible)}setHoverStyle(e){super.setHoverStyle(e);const t=getComputedStyle(e.dom),i="none"!==t.stroke&&parseFloat(t.strokeWidth)>0;$.setVisible(this._hoverView,i)&&Object.assign(this._hoverView.style,{stroke:t.stroke,strokeWidth:t.strokeWidth,strokeDasharray:t.strokeDasharray})}focusPointView(e,t){this._hoverView.style.display=t?"":"none",t&&this.$_showHoverView(e),this._hoverPoint=t?e:null}$_showHoverView(e){this._hoverRect.setAttribute("d",e.getAttr("d"))}$_prepareSlices(e,t,i){this._slices.prepare(i.length,(s,r)=>{const o=s.point=i[r];this._preparePoint(e,t,o,s)})}$_renderFigure(e,t,i,s){let r,o;e.setPath(t.paths),r=e.getBBox(),o=t.getPictorialSize(r,i,s),e.scale(o.width/r.width,o.height/r.height),k&&this.$_prepareOutline(this._sourceView.dom,i,s,o.width/r.width,o.height/r.height)}$_layoutSlices(e,t,i,s){const r=this._model,o=r.pointLabel,n=r.prop("reversed");this.$_calcRates(e),this._lineContainer.setStyleOrClass(o.connector.prop("style")),"column"===r.prop("direction")?this.$_renderHorz(n,t,s):this.$_renderVert(n,t,i)}$_calcRates(e){const t=this._zombie,i=this._zombieRate,s=e.length;let r=this.model.getTotal();(isNaN(r)||e.find(e=>e._isDeleted()))&&(r=e.filter(e=>(e.visible||e===t)&&!e.isNull).map(e=>e.yValue*(e===t?i:e._isDeleted()?e._vr:1)).reduce((e,t)=>e+t,0)),s>1||s>0&&!t?1==s&&e[0]._isDeleted()||1===s&&e[0]._vr<1?e[0].yRate=1:e.forEach(e=>{const s=H(e.yValue*(e===t?i:e._isDeleted()?e._vr:1)/r)||0;e.yRate=s}):1==s&&(e[0].yRate=H(i))}$_createLabelInfo(e){const{a:t,d:i}=e.getCTM(),{width:s,height:r}=e.getBBox();return{dom:e,sx:t,sy:i,wFigure:s,hFigure:r}}$_renderVert(e,t,i){const s=this.model,r=t.width,o=t.height,n=this._labelViews(),h=s.pointLabel,a="inside"===s.getLabelPos(h),l=h.getDistance(),_=h.getWidgetAlign(),d=null==n?void 0:n.textAlign(),u=[],g=h.prop("opposite"),c=this._lineContainer.setVis(h.connector.visible)?this._lineContainer:null,p=new z,y=s.getCenter(i,o).x-t.x,f=r/2;let m=e?0:o;const w=n?n.getWidth(0):0,P=u&&!a&&this.$_createLabelInfo(this._sourceView.dom);let V,b;this._slices.forEach(h=>{const v=h.point;if(h.setVis(!v.isNull)){const x=o*v.yRate;if(e?(h.setPath(D.rectangle(0,m,r,x)),v.yPos=m+x/2,m+=x):(v.yPos=m-x/2,m-=x,h.setPath(D.rectangle(0,m,r,x))),v.xPos=f,b=null==c?void 0:c.get(v),n&&(V=n.get(v,0))&&V.visible){const e=s.getLabelOff2(v);if(a){const e=V.isDomAnimating(),t=V.getBBox();!e&&V.layout(d||"center"),null==b||b.setVis(!1),V.trans(v.xPos-t.width/2,v.yPos-t.height/2)}else-1===_?this.$_layoutLabelNearVert(P,h,V,d,g,b,p,r,y,e,l):1==_?this.$_layoutLabelFarVert(P,h,V,d,g,b,p,e,l,w,t,i):this.$_layoutLabelOutVert(P,h,V,d,g,b,p,e,l);V.setContrast(a&&h.dom),u.push(V),V.setPosY(V.ty),this._layoutLabelRotation(V)}else b&&b.setVis(!1)}})}$_renderHorz(e,t,i){const s=this.model,r=t.width,o=t.height,n=this._labelViews(),h=s.pointLabel,a="inside"===s.getLabelPos(h),l=h.getDistance(),_=h.getWidgetAlign(),d=null==n?void 0:n.textAlign(),u=[],g=h.prop("opposite"),c=this._lineContainer.setVis(h.connector.visible)?this._lineContainer:null,p=new z,y=s.getCenter(r,i).y-t.y,f=o/2,m=n?n.getWidth(0):0,w=u&&!a&&this.$_createLabelInfo(this._sourceView.dom);let P,V,b=e?r:0;this._slices.forEach(h=>{const v=h.point;if(h.setVis(!v.isNull)){const x=r*v.yRate;if(e?(v.xPos=b-x/2,b-=x,h.setPath(D.rectangle(b,0,x,o))):(v.xPos=b+x/2,h.setPath(D.rectangle(b,0,x,o)),b+=x),v.yPos=f,V=null==c?void 0:c.get(v),n&&(P=n.get(v,0))&&P.visible){const e=s.getLabelOff2(v);if(a){const e=P.isDomAnimating(),t=P.getBBox();!e&&P.layout(d||"center"),P.trans(v.xPos-t.width/2,v.yPos-t.height/2),null==V||V.setVis(!1)}else-1===_?this.$_layoutLabelNearHorz(w,h,P,d,g,V,p,o,y,e,l):1==_?this.$_layoutLabelFarHorz(w,h,P,d,g,V,p,e,l,m,t,i):this.$_layoutLabelOutHorz(w,h,P,d,g,V,p,e,l);P.setContrast(a&&h.dom),u.push(P),P.setPosY(P.ty),this._layoutLabelRotation(P)}else V&&V.setVis(!1)}})}$_prepareOutline(e,t,i,s,r){const o=+new Date,n=this.control.canvasCtx(),h=e.getTotalLength(),a=T(1,Math.round(h/500));let l;n.setTransform(1,0,0,1,0,0),n.clearRect(0,0,t,i),n.scale(s,r),n.fillStyle="red",n.beginPath(),l=e.getPointAtLength(0),n.moveTo(l.x,l.y);for(let t=0;t<h;t+=a)l=e.getPointAtLength(t),n.lineTo(l.x,l.y);n.closePath(),n.fill(),console.log("canvas",+new Date-o,"ms.")}$_calcLabelPosVert(e,t,i){const s=e.dom,r=s.ownerSVGElement.createSVGPoint(),{wFigure:o,sx:n}=e,h=2*(e.sx<0?1:1/e.sx);let a=i?0:e.wFigure;if(r.y=t.point.yPos/e.sy,i){for(;a<o;a+=h)if(r.x=a,s.isPointInFill(r))return a>0&&(r.x-=h/2,s.isPointInFill(r)&&(a=r.x)),a*n}else for(;a>=0;a-=h)if(r.x=a,s.isPointInFill(r))return a<o&&(r.x+=h/2,s.isPointInFill(r)&&(a=r.x)),a*n;return e.wFigure*e.sx/2}$_calcLabelPosVertIE(e,t,i){const s=this.control.canvasCtx(),r={x:0,y:0},{wFigure:o,sx:n}=e,h=2*(n<0?1:1/n);let a=r.y=t.point.yPos,l=i?0:o*n;if(i){for(const e=o*n;l<e;l+=h)if(r.x=l,s.isPointInPath(r.x,a))return l>0&&(r.x-=h/2,s.isPointInPath(r.x,a)&&(l=r.x)),l}else for(;l>=0;l-=h)if(r.x=l,s.isPointInPath(l,a))return l<o*n&&(r.x+=h/2,s.isPointInPath(r.x,a)&&(l=r.x)),l;return o/2}$_layoutLabelOutVert(e,t,i,s,r,o,n,h,a){const l=t.point,_=i.isDomAnimating(),d=i.getBBox(),u=l.yPos;!_&&i.layout(s||(r?"right":"left"));let g=k?this.$_calcLabelPosVertIE(e,t,r):this.$_calcLabelPosVert(e,t,r);o&&(r?o.setLine(n.reset(0,0).line(-a,0).end()):o.setLine(n.reset(0,0).line(a,0).end()),o.trans(g,u)),r?g-=a+h+d.width:g+=a+h,i.trans(g,u-d.height/2)}$_layoutLabelNearVert(e,t,i,s,r,o,n,h,a,l,_){const d=t.point,u=i.isDomAnimating(),g=i.getBBox(),c=d.yPos;!u&&i.layout(s||(r?"right":"left"));const p=k?this.$_calcLabelPosVertIE(e,t,r):this.$_calcLabelPosVert(e,t,r);let y=a;r?y-=h/2:y+=h/2,o&&(r?o.setLine(n.reset(0,0).line(y-p-_,0).end()):o.setLine(n.reset(0,0).line(y+_-p,0).end()),o.trans(p,c)),r?y-=l+_+g.width:y+=_+l,i.trans(y,c-g.height/2)}$_layoutLabelFarVert(e,t,i,s,r,o,n,h,a,l,_,d){const u=t.point,g=i.isDomAnimating(),c=i.getBBox(),p=u.yPos;!g&&i.layout(s||(r?"right":"left"));const y=k?this.$_calcLabelPosVertIE(e,t,r):this.$_calcLabelPosVert(e,t,r);let f;f=r?a+h+l-_.x:d-_.x-a-l-h,o&&(r?o.setLine(n.reset(0,0).line(f-y-a,0).end()):o.setLine(n.reset(0,0).line(f+a-y,0).end()),o.trans(y,p)),r?f-=h+a+c.width:f+=a+h,i.trans(f,p-c.height/2)}$_calcLabelPosHorz(e,t,i){const s=e.dom,r=s.ownerSVGElement.createSVGPoint(),{hFigure:o,sy:n}=e,h=2*(e.sy<0?1:1/e.sy);let a=i?e.hFigure:0;if(r.x=t.point.xPos/e.sx,i){for(;a>=0;a-=h)if(r.y=a,s.isPointInFill(r))return a<e.hFigure&&(r.y+=h/2,s.isPointInFill(r)&&(a=r.y)),a*n}else for(;a<o;a+=h)if(r.y=a,s.isPointInFill(r))return a>0&&(r.y-=h/2,s.isPointInFill(r)&&(a=r.y)),a*n;return e.hFigure*e.sy/2}$_calcLabelPosHorzIE(e,t,i){const s=this.control.canvasCtx(),r={x:0,y:0},{hFigure:o,sy:n}=e,h=2*(e.sy<0?1:1/e.sy);let a=r.x=t.point.xPos,l=i?o*n:0;if(i){for(;l>=0;l-=h)if(r.y=l,s.isPointInPath(a,r.y))return l<o*n&&(r.y+=h/2,s.isPointInPath(a,r.y)&&(l=r.y)),l}else for(;l<o;l+=h)if(r.y=l,s.isPointInPath(a,r.y))return l>0&&(r.y-=h/2,s.isPointInPath(a,r.y)&&(l=r.y)),l;return e.hFigure*e.sy/2}$_layoutLabelOutHorz(e,t,i,s,r,o,n,h,a){const l=t.point,_=i.isDomAnimating(),d=i.getBBox(),u=l.xPos;!_&&i.layout(s);let g=k?this.$_calcLabelPosHorzIE(e,t,r):this.$_calcLabelPosHorz(e,t,r);o&&(r?o.setLine(n.reset(0,0).line(0,a).end()):o.setLine(n.reset(0,0).line(0,-a).end()),o.trans(u,g)),r?g+=a+h:g-=a+h,i.trans(u-d.width/2,r?g:g-d.height)}$_layoutLabelNearHorz(e,t,i,s,r,o,n,h,a,l,_){const d=t.point,u=i.isDomAnimating(),g=i.getBBox(),c=d.xPos;!u&&i.layout(s||(r?"right":"left"));let p=k?this.$_calcLabelPosHorzIE(e,t,r):this.$_calcLabelPosHorz(e,t,r),y=a;r?y+=h/2:y-=h/2,o&&(r?o.setLine(n.reset(0,0).line(0,y+_-p).end()):o.setLine(n.reset(0,0).line(0,y-p-_).end()),o.trans(c,p)),r?y+=_+l:y-=l+_+g.height,i.trans(c-g.width/2,y)}$_layoutLabelFarHorz(e,t,i,s,r,o,n,h,a,l,_,d){const u=t.point,g=i.isDomAnimating(),c=i.getBBox(),p=u.xPos;!g&&i.layout(s||(r?"right":"left"));const y=k?this.$_calcLabelPosHorzIE(e,t,r):this.$_calcLabelPosHorz(e,t,r);let f;f=r?d-_.y-a-l-h:a+h+l-_.y,o&&(r?o.setLine(n.reset(0,0).line(0,f+a-y).end()):o.setLine(n.reset(0,0).line(0,f-y-a).end()),o.trans(p,y)),r?f+=a+h:f-=h+a+c.height,i.trans(p-c.width/2,f)}}function te(e){(function(e){return!!(e&&e.Series&&e.SeriesView)})(e)&&(e.Series.register(O),e.Series.register(j),e.Series.register(Z),e.SeriesView.register([O,W]),e.SeriesView.register([j,Q]),e.SeriesView.register([Z,ee]))}te(e);export{O as PictogramSeries,j as PictorialBarSeries,Z as PictorialSeries,te as default};
|
package/split.d.ts
CHANGED
|
@@ -94,6 +94,8 @@ declare class Split extends ChartItem<SplitOptions> implements ISplit {
|
|
|
94
94
|
getAxisOf(annotation: Annotation, isX: boolean): IAxis;
|
|
95
95
|
isValidAxis(axis: IAxis): boolean;
|
|
96
96
|
protected _doLoadProp(prop: string, value: any): boolean;
|
|
97
|
+
protected _doUpdateProp(prop: string, value: any): boolean;
|
|
98
|
+
protected _doSaveProp(target: any, prop: string, value: any): boolean;
|
|
97
99
|
protected _doSetSimple(op: any, src?: any): boolean;
|
|
98
100
|
_load(source: any): ChartItem;
|
|
99
101
|
protected _doPrepareRender(chart: IChart): void;
|
package/split.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
/**
|
|
3
|
-
* RealChart Split v1.
|
|
3
|
+
* RealChart Split v1.5.0
|
|
4
4
|
* Copyright (C) 2023-2026 WooriTech Inc.
|
|
5
5
|
* All Rights Reserved.
|
|
6
6
|
*/
|
|
7
|
-
!function(e,s){"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("realchart")):"function"==typeof define&&define.amd?define(["exports","realchart"],s):s((e="undefined"!=typeof globalThis?globalThis:e||self).RealChartSplit={},e.RealChart)}(this,function(e,s){"use strict";function t(e){var s=Object.create(null);return e&&Object.keys(e).forEach(function(t){if("default"!==t){var i=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,i.get?i:{enumerable:!0,get:function(){return e[t]}})}}),s.default=e,Object.freeze(s)}var i=t(s);class o{constructor(e,s){this.row=e,this.col=s,this._axes=[]}sort(e,s){const t=s&&!e||!s&&e;this._axes.length>1&&(t?this._axes.sort((e,s)=>{const t=e._posValue(),i=s._posValue();return t===i?t<0?s._index-e._index:t>0?e._index-s._index:e.row!==s.row?s.row-e.row:e.row<this.row?s._index-e._index:e._index-s._index:i-t}):this._axes.sort((e,s)=>{const t=e._posValue(),i=s._posValue();return t===i?t<0?e._index-s._index:t>0?s._index-e._index:e.col!==s.col?e.col-e.col:e.col<this.col?e._index-s._index:s._index-e._index:t-i}))}}class r{constructor(e,s){this.chart=e,this.isX=s}rows(){return this._matrix.length}cols(){return this._matrix[0].length}_prepare(e,s,t,i){this._doPrepare(e,s,t),this._matrix.forEach(e=>{e.forEach(e=>e.sort(this.isX,i))})}get(e,s){return this._matrix[e][s]}getRow(e){return this._matrix[e]}getColumn(e){return this._matrix.map(s=>s[e])}_buildTicks(e,s){const t=this.isX;this._matrix.forEach((i,o)=>{i.forEach((i,o)=>{i._axes.forEach(i=>{!i.isBased()&&(s<2||t)&&i._buildTicks(e[t?i.prop("col"):i.prop("row")],s)})})}),this._matrix.forEach((i,o)=>{i.forEach((i,o)=>{i._axes.forEach(i=>{i.isBased()&&(s<2||t)&&i._buildTicks(e[t?i.prop("col"):i.prop("row")],s)})})})}_calcPoints(e,s){const t=this.isX;this._matrix.forEach(i=>{i.forEach((i,o)=>{i._axes.forEach(i=>{if(s<2||t){const o=t?i.prop("col"):i.prop("row");i._calcPoints(e[o],s)}})})})}}class n extends r{constructor(e){super(e,!0)}_doPrepare(e,s,t){const i=this._matrix=new Array(s+1);for(let e=0;e<i.length;e++){i[e]=[];for(let s=0;s<t;s++)i[e].push(new o(e,s))}e.forEach(e=>{var t,o;const r=e.prop("position");let n=e.row;"opposite"===r?(n++,e._runPos=r):n<s-1&&"between"===r?(n++,e._runPos="normal"):e._runPos=r,null===(o=null===(t=i[n])||void 0===t?void 0:t[e.col])||void 0===o||o._axes.push(e)})}}class h extends r{constructor(e){super(e,!1)}_doPrepare(e,s,t){const i=this._matrix=new Array(s);for(let e=0;e<i.length;e++){i[e]=[];for(let s=0;s<=t;s++)i[e].push(new o(e,s))}e.forEach(e=>{var s,o;const r=e.prop("position");let n=e.col;"opposite"===r?(n++,e._runPos=r):e.col<t-1&&"between"===r?(n++,e._runPos="normal"):e._runPos=r,null===(o=null===(s=i[e.row])||void 0===s?void 0:s[n])||void 0===o||o._axes.push(e)})}}class a extends s.Body{constructor(e){super(e.chart),this.pane=e}contains(e){return e.col===this.pane.col||e.row===this.pane.row}}a.defaults=s.extend(s.Body.defaults,{extended:!0,radius:void 0,centerX:void 0,centerY:void 0});class c extends s.Legend{constructor(e){super(e.chart),this.pane=e}_doPrepareRender(e){super._doPrepareRender(e),this._location="body"}_getLegendSources(){return this.prop("visible")?this.chart._getSeries().getLegendSources(this.pane.row,this.pane.col):[]}}class l extends s.ChartItem{constructor(e,s,t){super(e),this.row=s,this.col=t}_doInit(e){this._body=this._addChild("body",new a(this)),this._legend=this._addChild("legend",new c(this))}get body(){return this._body}get legend(){return this._legend}_prepareRender(){this._body._prepareRender(),this._legend._prepareRender()}}class _ extends s.ChartItem{constructor(e){super(e),this._cols=1,this._rows=1,this._paneDic={},this._panes=[],this._xAxes=new n(e),this._yAxes=new h(e)}get count(){return this._rows*this._cols}get rowCount(){return this._rows}get colCount(){return this._cols}get paneCount(){return this._rows*this._cols}colSizes(){return this._colSizes}rowSizes(){return this._rowSizes}getPane(e,s){return this._panes[e][s]}getRow(e){return this._panes[e]}getColumn(e){return this._panes.map(s=>s[e])}getAxisOf(e,s){var t,i;const o=this.chart,r=e.body;if(r){const n=r.pane;return s?o._getXAxes().get(e.prop("xAxis"))||this._xAxes.get(n.row,n.col)._axes[0]||(null===(t=o._getSeries().getPaneSeries(n.row,n.col)[0])||void 0===t?void 0:t._xAxisObj):o._getXAxes().get(e.prop("yAxis"))||this._yAxes.get(r.pane.row,r.pane.col)._axes[0]||(null===(i=o._getSeries().getPaneSeries(n.row,n.col)[0])||void 0===i?void 0:i._yAxisObj)}}isValidAxis(e){return e&&e.row<this._rows&&e.col<this._cols}_doLoadProp(e,s){return["panes","cols","rows"].indexOf(e)>=0||super._doLoadProp(e,s)}_doSetSimple(e,t){const i=arguments.length<2?e:t;if(s.isArray(i)&&i.length>0){const e=s.maxv(1,+i[0]),t=s.maxv(1,s.pickNum(+i[1],e));return e>0&&t>0&&(this.$_parsePanes(e,t),this.visible=!0),!0}return super._doSetSimple(e,i)}_load(e){return super._load(e),s.isObject(e)&&(this.$_parsePanes(e.rows,e.cols),this._paneDic=this.$_loadPanes(e.panes)),this}_doPrepareRender(e){this._panes=this.$_collectPanes(e),this._panes.forEach(e=>e.forEach(e=>e._prepareRender()))}_calcSizes(e,t){const i=e.length,o=new Array(i);let r=0;if(i>1){let n=t,h=0;for(r=0;r<i;r++){const t=e[r];s.isNumber(t)?n-=o[r]=Math.max(0,Math.min(n,t)):h+=t.size}if(h>0)for(r=0;r<i;r++){const t=e[r];s.isNumber(t)||(o[r]=n*t.size/h)}}else o[r]=t;return o}getXLens(e){return this._calcSizes(this._colSizes,e)}getYLens(e){return this._calcSizes(this._rowSizes,e)}measureAxes(e,s,t,i){const o=this.getXLens(t?s:e),r=this.getYLens(t?e:s);this._xAxes._buildTicks(o,i),this._yAxes._buildTicks(r,i),this.$_calcAxesPoints(o,r,i)}$_calcAxesPoints(e,s,t){this._xAxes._calcPoints(e,t),this._yAxes._calcPoints(s,t)}completeAxesPoints(e,s){this.$_calcAxesPoints(e,s,101)}getBodyAnnotation(e){for(const s in this._paneDic){const t=this._paneDic[s].body.getAnnotation(e);if(t)return t}}prepareRender(e,s){const t=this.chart.isInverted();this._prepareRender(),this._xAxes._prepare(e,this._rows,this._cols,t),this._yAxes._prepare(s,this._rows,this._cols,t)}$_parseSizes(e){let t;return t=s.isArray(e)&&e.length>0?e.slice(0):e>0?new Array(e).fill("*"):["*"],t.map(e=>{if(s.isString(e)){const t=e.trim();return{size:"*"===t?1:s.pickNum(parseFloat(t),1)}}return s.pickNum(+e,1)})}$_parsePanes(e,s){this._colSizes=this.$_parseSizes(s),this._rowSizes=this.$_parseSizes(e),this._cols=this._colSizes.length,this._rows=this._rowSizes.length}$_loadPanes(e){const t=this.chart,i=this.prop("extendBody")?t._body._config:void 0,o={};if(e=s.isArray(e)?e:s.isObject(e)?[e]:null,s.isArray(e)&&e.forEach(e=>{const s=+e.row||0,r=+e.col||0;if(r>=0&&r<this._cols&&s>=0&&s<this._rows){const n=new l(t,s,r);let h=e;n.init(),!i||e&&e.body&&!1===e.body.extended||(e?(h=Object.assign({},e),e.body?!1!==e.body.extended&&(h.body=Object.assign({},i,e.body)):h.body=i):h={body:i}),n._load(h),o[s+","+r]=n}}),i)for(let e=0;e<this._rows;e++)for(let s=0;s<this._cols;s++){const r=e+","+s;if(!o[r]){const n=new l(t,e,s);n.init(),n._load({body:i}),o[r]=n}}return o}$_collectPanes(e){const s=[];for(let t=0;t<this._rows;t++){const i=[];for(let s=0;s<this._cols;s++){const o=this._paneDic[t+","+s]||new l(e,t,s)._initObject();i.push(o)}s.push(i)}return s}}_.defaults=s.extend(s.ChartItem.defaults,{visible:!1,extendBody:!0,gap:0});class d extends s.SectionView{constructor(){super(...arguments),this.views=[],this._gap=0}isEmpty(){return 0===this.views.length}prepare(e,s,t,i,o){const r=this.views,n=[];for(this.isX=i,o._axes.forEach(e=>{e.checkVisible()&&t.isValidAxis(e)&&n.push(e)});r.length<n.length;){const t=s.createAxisView(e);this.add(t),r.push(t)}for(;r.length>n.length;)r.pop().remove();if(r.forEach((e,s)=>{e.setModel(n[s])}),this.axes=n,this.setVis(r.length>0)){const e=r[0].model;this._gap=e.chart.getAxesGap()}}prepareGuides(e,s,t){const i=this.views,o=this.axes;i.forEach((t,i)=>{const r=o[i];s.forEach(s=>{s.forEach(s=>{s.isConnected(r)&&t.setVis(this.visible)&&(t.prepareGuides(e,s.row,s.col,s._guideContainer,s._frontGuideContainer),r._isHorz||(s._axes||(s._axes=[]),s._axes.push(r)))})})}),s.forEach(s=>{s.forEach(s=>{s._axes&&(s._gridRowContainer.addAll(e,s._axes),s._axes=[])})})}checkHeights(e,s,t){return this.views.length>0?this.$_checkHeights(this.views,e,s,t):0}$_checkHeights(e,s,t,i){let o=0;return e&&(e.forEach(e=>{o+=e.checkHeight(s,t,i)}),o+=(this.views.length-1)*this._gap),o}checkWidths(e,s,t){return this.views.length>0?this.$_checkWidths(this.views,e,s,t):0}$_checkWidths(e,s,t,i){let o=0;return e&&(e.forEach(e=>{o+=e.checkWidth(s,t,i)}),o+=(this.views.length-1)*this._gap),o}getScrollView(e){var s;for(const t of this.views)if(null===(s=t._scrollView)||void 0===s?void 0:s.contains(e))return t._scrollView}setMargins(e,s,t,i){this.views.forEach(o=>o.setMargins(e,s,t,i))}_setInverted(e){super._setInverted(e),this.isHorz=e&&!this.isX||!e&&this.isX}_doMeasure(e,s,t,i,o){const r=this.axes;if(this.isHorz){let s=0;return this.views.forEach((n,h)=>{s+=n.measure(e,r[h],t,i,o).height}),{width:t,height:s}}{let s=0;return this.views.forEach((n,h)=>{s+=n.measure(e,r[h],t,i,o).width}),{width:s,height:i}}}_doLayout(e){const s=this.views,t=this.width,i=this.height,o=s.length;let r=0,n=o-1;if(this.isHorz){let e,h,a=0;for(;r<o;r++){const e=s[r];if(e.model._posValue()<1)break;e.trans(0,a),a+=e.mh}for(e=a,a=i;n>=0;n--){const e=s[n];if(e.model._posValue()>-1)break;a-=e.mh,e.trans(0,a)}h=a;const c=h-e;let l=0;for(let e=r;e<=n;e++)l+=s[e].mh;e+=(c-l)/2;for(let t=r;t<=n;t++){const i=s[t];i.trans(0,e),e+=i.mh}s.forEach(e=>{e.resize(t,e.mh),e.model._calcPoints(t,999),e.layout()})}else{let e,h,a=0;for(;r<o;r++){const e=s[r];if(e.model._posValue()>-1)break;e.trans(a,0),a+=e.mw}for(e=a,a=t;n>=0;n--){const e=s[n];if(e.model._posValue()<1)break;a-=e.mw,e.trans(a,0)}h=a;const c=h-e;let l=0;for(let e=r;e<=n;e++)l+=s[e].mw;e+=(c-l)/2;for(let t=r;t<=n;t++){const i=s[t];i.trans(e,0),e+=i.mw}s.forEach(e=>{e.resize(e.mw,i),e.model._calcPoints(i,999),e.layout()})}}}class p extends s.SectionView{constructor(e,s){super(e,"rct-axis-container"),this.isX=s,this.sections=[]}prepare(e,s,t,i,o,r){const n=this.isX?i.getRow(o):i.getColumn(o);for(;this.sections.length<n.length;){const s=new d(e);this.add(s),this.sections.push(s)}for(;this.sections.length>n.length;)this.sections.pop().remove();this.sections.forEach((i,r)=>{this.isX?(i.row=o,i.col=r):(i.col=o,i.row=r),i.prepare(e,s,t,this.isX,n[r])}),this._setInverted(r)}prepareGuides(e,s,t,i){const o=this.isX?t.getRow(i):t.getColumn(i);for(;this.sections.length<o.length;){const s=new d(e);this.add(s),this.sections.push(s)}for(;this.sections.length>o.length;)this.sections.pop().remove();this.sections.forEach((o,r)=>{this.isX?(o.row=i,o.col=r):(o.col=i,o.row=r),o.prepareGuides(e,s,t)})}checkWidths(e,s,t){return this.sections.length>0?this._isHorz?this.sections.reduce((i,o)=>i+o.checkWidths(e,s,t),0):this.sections.reduce((i,o)=>Math.max(i,o.checkWidths(e,s,t)),0):0}checkHeights(e,s,t){return this.sections.length>0?this._isHorz?this.sections.reduce((i,o)=>Math.max(i,o.checkHeights(e,s,t)),0):this.sections.reduce((i,o)=>i+o.checkHeights(e,s,t),0):0}_setInverted(e){super._setInverted(e),this._isHorz=e&&!this.isX||!e&&this.isX}_doMeasure(e,t,i,o,r){let n=0,h=0;return this._isHorz?this.sections.forEach(n=>{h=s.maxv(h,n.measure(e,t,i,o,r).height)}):this.sections.forEach(h=>{n=s.maxv(n,h.measure(e,t,i,o,r).width)}),{width:n,height:h}}_doLayout(e){this._isHorz?this.height>0&&this.sections.forEach((s,t)=>{s.resize(e[2*(t+1)]-e[2*(t+1)-1],this.height),s.trans(e[2*t+1]-e[1],0),s.layout()}):this.width>0&&this.sections.forEach((s,t)=>{s.resize(this.width,e[2*(t+1)]-e[2*(t+1)-1]),s.trans(0,this.height-(e[2*(t+1)]-e[1])),s.layout()})}layoutPanes(e,s){this.sections.forEach((t,i)=>{const[o,r]=e[i],n=r-o;this._isHorz?(t.resize(n,this.height),t.trans(o-s,0)):(t.resize(this.width,n),t.trans(0,this.height-(r-s))),t.layout()})}}class u extends s.BodyView{constructor(e,t){super(e,t),this.row=0,this.col=0,this.add(this._legendView=new s.LegendView(e))}getCol(){return this.col}getRow(){return this.row}getTooltipPos(){return{x:this.parent.parent.tx+this.tx,y:this.parent.parent.ty+this.ty}}prepareRender(e,t){const i=t.chart,o=t.depth.visible,r=this.row,n=this.col,h=i._split.getPane(r,n).body;this._animatable=s.RcControl._animatable&&i.animatable(),this._prepareSeries(e,t,i._getSeries().getPaneSeries(r,n),o),this._prepareGauges(e,i,i._getGauges().getPaneVisibles(r,n)),this._prepareAnnotations(e,h.getAnnotations().concat(i._getAnnotations().getPaneVisibles(r,n)))}_doMeasure(e,s,t,i,o){return this._legendView.setVis(s.pane.legend.visible)&&this._legendView.measure(e,s.pane.legend,t,i,o),super._doMeasure(e,s,t,i,o)}_doLayout(){super._doLayout();const e=this._legendView;if(e.visible){this._seriesViews.forEach(s=>{if(s.needDecoreateLegend()){const t=e.legendOfSeries(s.model);t&&s.decoreateLegend(t)}});const s=e.model,t=s.prop("align"),i=s.prop("verticalAlign");let o=0,r=0,n=+s.prop("offsetX")||0;switch(t){case"right":o+=this.width-e.mw-n;break;case"center":o+=(this.width-e.mw)/2+n;break;default:o+=n}switch(n=+s.prop("offsetY")||0,i){case"bottom":r+=this.height-e.mh-n;break;case"middle":r+=(this.height-e.mh)/2+n;break;default:r+=n}e.trans(o,r).resize(e.mw,e.mh),e.layout()}}}class f extends s.PaneContainer{constructor(e,s){super(e,f.STYLE_NAME),this._bodies=[],this._xContainers=[],this._yContainers=[],this._owner=s}get bodies(){return this._bodies}bodyViewOf(e){return this._bodies.find(s=>s.contains(e))}axisViewOf(e){for(const s of[this._xContainers,this._yContainers])for(const t of s)for(const s of t.sections){const t=s.views.find(s=>s.model===e);if(t)return t}}prepare(e,s){s.chart,this.$_init(e),this._model=s,this.$_prepareBodies(e,s)}measure(e,s,t,i,o){const r=s.chart,n=this._inverted=s.chart.isInverted(),h=s._xAxes,a=s._yAxes,c=t,l=i;this.$_prepareAxes(e,h,!0,n),this.$_prepareAxes(e,a,!1,n),s.measureAxes(t,i,n,o),n?(t-=this._xContainers.reduce((s,o)=>s+o.checkWidths(e,t,i),0),i-=this._yContainers.reduce((s,o)=>s+o.checkHeights(e,t,i),0)):(i-=this._xContainers.reduce((s,o)=>s+o.checkHeights(e,t,i),0),t-=this._yContainers.reduce((s,o)=>s+o.checkWidths(e,t,i),0)),s.measureAxes(t,i,n,o),this._xContainers.forEach(s=>s.measure(e,r,t,i,o)),this._yContainers.forEach(s=>s.measure(e,r,t,i,o)),t=c,i=l,n?(t-=this._xContainers.reduce((e,s)=>e+s.mw,0),i-=this._yContainers.reduce((e,s)=>e+s.mh,0)):(i-=this._xContainers.reduce((e,s)=>e+s.mh,0),t-=this._yContainers.reduce((e,s)=>e+s.mw,0)),o++,s.measureAxes(t,i,n,o),this.$_prepareAxisGuides(e,h,!0),this.$_prepareAxisGuides(e,a,!1),this._xContainers.forEach(s=>{s.measure(e,r,t,i,o)}),this._yContainers.forEach(s=>{s.measure(e,r,t,i,o)});const _=s.getXLens(n?i:t),d=s.getYLens(n?t:i);s.completeAxesPoints(_,d)}layout(){const e=this._model,s=this.width,t=this.height;this._back.resize(s,t),this.$_calcExtents(e,s,t),this.$_layoutAxes(e,!0,s,t),this.$_layoutAxes(e,!1,s,t),this.$_layoutBodies(e,s,t)}seriesByDom(e){for(const s of this._bodies){const t=s.seriesByDom(e);if(t)return t}}annotationByDom(e){for(const s of this._bodies){const t=s.annotationByDom(e);if(t)return t}}getSeries(e){for(const s of this.bodies){const t=s.findSeries(e);if(t)return t}}legendByDom(e){for(const s of this.bodies){const t=s._legendView.legendByDom(e);if(t)return t}}$_init(e){this._back||(this.add(this._back=new s.RectElement(e)),this._back.setStyles({fill:"none"}),this.add(this._bodyContainer=new s.LayerElement(e,void 0)),this.add(this._axisContainer=new s.LayerElement(e,void 0)))}$_prepareBodies(e,s){s.chart;const t=s.paneCount,i=s.rowCount,o=s.colCount,r=this._bodies,n=this._bodyMap=[];for(;r.length<t;){const s=new u(e,this._owner);this._bodyContainer.add(s),r.push(s)}for(;r.length>t;)r.pop().remove();for(let e=0;e<i;e++){const s=[];for(let t=0;t<o;t++){const i=r[e*o+t];s.push(i),i.row=e,i.col=t}n.push(s)}r.forEach(t=>{t.prepareRender(e,s.getPane(t.row,t.col).body),t.prepareGuideContainers(),t._gridRowContainer.prepare()})}$_prepareAxes(e,s,t,i){const o=this._model.chart,r=t?this._xContainers:this._yContainers,n=t?s.rows():s.cols();for(;r.length<n;){const s=new p(e,t);this._axisContainer.add(s),r.push(s)}for(;r.length>n;)r.pop().remove();r.forEach((t,r)=>{t.prepare(e,this._owner,o,s,r,i)})}$_prepareAxisGuides(e,s,t){(t?this._xContainers:this._yContainers).forEach((t,i)=>{t.prepareGuides(e,this._bodyMap,s,i)})}$_calc(e,t,i,o){const r=i.length,n=new Array(2*(r+1)),h=Math.max(0,s.pickNum(this._model.prop("gap"),0)),a=t-e.reduce((e,s)=>e+s[o],0)-(r>1?(r-1)*h:0),c=this._model._calcSizes(i,a);let l=0,_=0;for(_=0;_<r;_++)n[2*_]=l,n[2*_+1]=l+=e[_][o],l+=c[_],_<r-1&&(l+=h);return n[2*_]=l,n[2*_+1]=l+e[_][o],{pts:n,sizes:c}}$_paneBounds(e,s){return s.map((s,t)=>[e[2*t+1],e[2*t+1]+s])}$_calcExtents(e,s,t){if(this._inverted){const i=this.$_calc(this._xContainers,s,e.rowSizes(),"mw"),o=this.$_calc(this._yContainers,t,e.colSizes(),"mh");this._rowPoints=i.pts,this._colPoints=o.pts,this._rowPaneSizes=i.sizes,this._colPaneSizes=o.sizes}else{const i=this.$_calc(this._xContainers,t,e.rowSizes(),"mh"),o=this.$_calc(this._yContainers,s,e.colSizes(),"mw");this._rowPoints=i.pts,this._colPoints=o.pts,this._rowPaneSizes=i.sizes,this._colPaneSizes=o.sizes}}$_layoutAxes(e,s,t,i){const o=this.control._padding,r=this._rowPoints,n=this._colPoints,h=s?this._xContainers:this._yContainers;if(this._inverted)if(s){const e=n[1],s=n[n.length-2]-e;h.forEach((e,t)=>{e.resize(e.mw,s),e.trans(r[2*t],i-n[n.length-2]),e.layoutPanes(this.$_paneBounds(n,this._colPaneSizes),n[1])})}else{const e=r[1],s=r[r.length-2]-e;h.forEach((t,h)=>{const a=t.sections;for(let e=0,s=a.length;e<s;e++){const t=a[e],i=0===e?o.left:0,n=e===s-1?o.right:0;let h=0,c=0;s>1&&(h=r[2*e+1]-r[2*e],c=r[2*(e+1)+1]-r[2*(e+1)],0===e?a[e+1].isEmpty()?c=r[2*(e+1)]-r[2*(e+1)-1]:c/=2:e===s-1?a[e-1].isEmpty()?h=r[2*(e-1)]-r[2*(e-1)-1]:h/=2:(a[e-1].isEmpty()?h=r[2*(e-1)]-r[2*(e-1)-1]:h/=2,a[e+1].isEmpty()?c=r[2*(e+1)]-r[2*(e+1)-1]:c/=2)),t.setMargins(i,h,c,n)}t.resize(s,t.mh),t.trans(e,i-n[2*h+1]),t.layoutPanes(this.$_paneBounds(r,this._rowPaneSizes),r[1])})}else if(s){const e=n[1];t=n[n.length-2]-e,h.forEach((s,a)=>{const c=s.sections;for(let e=0,s=c.length;e<s;e++){const t=c[e],i=0===a?o.left:0,l=a===h.length-1?o.right:0;let _=0,d=0;s>1&&(_=n[2*e+1]-n[2*e],d=n[2*(e+1)+1]-n[2*(e+1)],0===e?c[e+1].isEmpty()?d=n[2*(e+1)]-n[2*(e+1)-1]:d/=2:e===s-1?c[e-1].isEmpty()?_=n[2*(e-1)]-n[2*(e-1)-1]:_/=2:(c[e-1].isEmpty()?_=n[2*(e-1)]-n[2*(e-1)-1]:_/=2,c[e+1].isEmpty()?d=n[2*(e+1)]-r[2*(e+1)-1]:d/=2)),t.setMargins(i,_,d,l)}s.resize(t,s.mh),s.trans(e,i-r[2*a+1]),s.layoutPanes(this.$_paneBounds(n,this._colPaneSizes),n[1])})}else{const e=r[r.length-2],s=e-r[1];h.forEach((t,o)=>{t.resize(t.mw,s),t.trans(n[2*o],i-e),t.layoutPanes(this.$_paneBounds(r,this._rowPaneSizes),r[1])})}}$_layoutBodies(e,s,t){const i=e.rowCount,o=e.colCount,r=this.$_paneBounds(this._rowPoints,this._rowPaneSizes),n=this.$_paneBounds(this._colPoints,this._colPaneSizes),h=this._bodies;if(this._inverted)for(let s=0;s<i;s++){const[t,i]=r[s];for(let r=0;r<o;r++){const a=h[s*o+r],[c,l]=n[r];a.measure(this.doc,e.getPane(s,r).body,i-t,l-c,1),a.resize(i-t,l-c),a.trans(t,this.height-l),a.layout()}}else for(let s=0;s<i;s++){const[i,a]=r[s];for(let r=0;r<o;r++){const c=h[s*o+r],[l,_]=n[r];c.measure(this.doc,e.getPane(s,r).body,_-l,a-i,1),c.resize(_-l,a-i),c.trans(l,t-a),c.layout()}}}}function g(e){(function(e){return e.Series&&e.SeriesView})(e)&&(e.ChartObject.registerSplitClass(_),e.ChartView.registerPaneClass(f))}f.STYLE_NAME="rct-panes",g(i),e.Split=_,e.default=g,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
7
|
+
!function(e,s){"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("realchart")):"function"==typeof define&&define.amd?define(["exports","realchart"],s):s((e="undefined"!=typeof globalThis?globalThis:e||self).RealChartSplit={},e.RealChart)}(this,function(e,s){"use strict";function t(e){var s=Object.create(null);return e&&Object.keys(e).forEach(function(t){if("default"!==t){var i=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,i.get?i:{enumerable:!0,get:function(){return e[t]}})}}),s.default=e,Object.freeze(s)}var i=t(s);class o{constructor(e,s){this.row=e,this.col=s,this._axes=[]}sort(e,s){const t=s&&!e||!s&&e;this._axes.length>1&&(t?this._axes.sort((e,s)=>{const t=e._posValue(),i=s._posValue();return t===i?t<0?s._index-e._index:t>0?e._index-s._index:e.row!==s.row?s.row-e.row:e.row<this.row?s._index-e._index:e._index-s._index:i-t}):this._axes.sort((e,s)=>{const t=e._posValue(),i=s._posValue();return t===i?t<0?e._index-s._index:t>0?s._index-e._index:e.col!==s.col?e.col-e.col:e.col<this.col?e._index-s._index:s._index-e._index:t-i}))}}class r{constructor(e,s){this.chart=e,this.isX=s}rows(){return this._matrix.length}cols(){return this._matrix[0].length}_prepare(e,s,t,i){this._doPrepare(e,s,t),this._matrix.forEach(e=>{e.forEach(e=>e.sort(this.isX,i))})}get(e,s){return this._matrix[e][s]}getRow(e){return this._matrix[e]}getColumn(e){return this._matrix.map(s=>s[e])}_buildTicks(e,s){const t=this.isX;this._matrix.forEach((i,o)=>{i.forEach((i,o)=>{i._axes.forEach(i=>{!i.isBased()&&(s<2||t)&&i._buildTicks(e[t?i.prop("col"):i.prop("row")],s)})})}),this._matrix.forEach((i,o)=>{i.forEach((i,o)=>{i._axes.forEach(i=>{i.isBased()&&(s<2||t)&&i._buildTicks(e[t?i.prop("col"):i.prop("row")],s)})})})}_calcPoints(e,s){const t=this.isX;this._matrix.forEach(i=>{i.forEach((i,o)=>{i._axes.forEach(i=>{if(s<2||t){const o=t?i.prop("col"):i.prop("row");i._calcPoints(e[o],s)}})})})}}class n extends r{constructor(e){super(e,!0)}_doPrepare(e,s,t){const i=this._matrix=new Array(s+1);for(let e=0;e<i.length;e++){i[e]=[];for(let s=0;s<t;s++)i[e].push(new o(e,s))}e.forEach(e=>{var t,o;const r=e.prop("position");let n=e.row;"opposite"===r?(n++,e._runPos=r):n<s-1&&"between"===r?(n++,e._runPos="normal"):e._runPos=r,null===(o=null===(t=i[n])||void 0===t?void 0:t[e.col])||void 0===o||o._axes.push(e)})}}class h extends r{constructor(e){super(e,!1)}_doPrepare(e,s,t){const i=this._matrix=new Array(s);for(let e=0;e<i.length;e++){i[e]=[];for(let s=0;s<=t;s++)i[e].push(new o(e,s))}e.forEach(e=>{var s,o;const r=e.prop("position");let n=e.col;"opposite"===r?(n++,e._runPos=r):e.col<t-1&&"between"===r?(n++,e._runPos="normal"):e._runPos=r,null===(o=null===(s=i[e.row])||void 0===s?void 0:s[n])||void 0===o||o._axes.push(e)})}}class a extends s.Body{constructor(e){super(e.chart),this.pane=e}contains(e){return e.col===this.pane.col||e.row===this.pane.row}}a.defaults=s.extend(s.Body.defaults,{extended:!0,radius:void 0,centerX:void 0,centerY:void 0});class c extends s.Legend{constructor(e){super(e.chart),this.pane=e}_doPrepareRender(e){super._doPrepareRender(e),this._location="body"}_getLegendSources(){return this.prop("visible")?this.chart._getSeries().getLegendSources(this.pane.row,this.pane.col):[]}}class l extends s.ChartItem{constructor(e,s,t){super(e),this.row=s,this.col=t}_doInit(e){this._body=this._addChild("body",new a(this)),this._legend=this._addChild("legend",new c(this))}get body(){return this._body}get legend(){return this._legend}_prepareRender(){this._body._prepareRender(),this._legend._prepareRender()}}class _ extends s.ChartItem{constructor(e){super(e),this._cols=1,this._rows=1,this._paneDic={},this._panes=[],this._xAxes=new n(e),this._yAxes=new h(e)}get count(){return this._rows*this._cols}get rowCount(){return this._rows}get colCount(){return this._cols}get paneCount(){return this._rows*this._cols}colSizes(){return this._colSizes}rowSizes(){return this._rowSizes}getPane(e,s){return this._panes[e][s]}getRow(e){return this._panes[e]}getColumn(e){return this._panes.map(s=>s[e])}getAxisOf(e,s){var t,i;const o=this.chart,r=e.body;if(r){const n=r.pane;return s?o._getXAxes().get(e.prop("xAxis"))||this._xAxes.get(n.row,n.col)._axes[0]||(null===(t=o._getSeries().getPaneSeries(n.row,n.col)[0])||void 0===t?void 0:t._xAxisObj):o._getXAxes().get(e.prop("yAxis"))||this._yAxes.get(r.pane.row,r.pane.col)._axes[0]||(null===(i=o._getSeries().getPaneSeries(n.row,n.col)[0])||void 0===i?void 0:i._yAxisObj)}}isValidAxis(e){return e&&e.row<this._rows&&e.col<this._cols}_doLoadProp(e,s){return"panes"===e||"cols"===e||"rows"===e||super._doLoadProp(e,s)}_doUpdateProp(e,s){return"rows"!==e&&"cols"!==e&&"panes"!==e?super._doUpdateProp(e,s):s!==this._op[e]&&(this._op[e]=s,"panes"===e?this._paneDic=this.$_loadPanes(s):this.$_parsePanes(this._op.rows,this._op.cols),!0)}_doSaveProp(e,s,t){return"rows"===s||"cols"===s||"panes"===s?(e[s]=t,!0):super._doSaveProp(e,s,t)}_doSetSimple(e,t){const i=arguments.length<2?e:t;if(s.isArray(i)&&i.length>0){const e=s.maxv(1,+i[0]),t=s.maxv(1,s.pickNum(+i[1],e));return e>0&&t>0&&(this.$_parsePanes(e,t),this.visible=!0),!0}return super._doSetSimple(e,i)}_load(e){return super._load(e),s.isObject(e)&&(this.$_parsePanes(e.rows,e.cols),this._paneDic=this.$_loadPanes(e.panes)),this}_doPrepareRender(e){this._panes=this.$_collectPanes(e),this._panes.forEach(e=>e.forEach(e=>e._prepareRender()))}_calcSizes(e,t){const i=e.length,o=new Array(i);let r=0;if(i>1){let n=t,h=0;for(r=0;r<i;r++){const t=e[r];s.isNumber(t)?n-=o[r]=Math.max(0,Math.min(n,t)):h+=t.size}if(h>0)for(r=0;r<i;r++){const t=e[r];s.isNumber(t)||(o[r]=n*t.size/h)}}else o[r]=t;return o}getXLens(e){return this._calcSizes(this._colSizes,e)}getYLens(e){return this._calcSizes(this._rowSizes,e)}measureAxes(e,s,t,i){const o=this.getXLens(t?s:e),r=this.getYLens(t?e:s);this._xAxes._buildTicks(o,i),this._yAxes._buildTicks(r,i),this.$_calcAxesPoints(o,r,i)}$_calcAxesPoints(e,s,t){this._xAxes._calcPoints(e,t),this._yAxes._calcPoints(s,t)}completeAxesPoints(e,s){this.$_calcAxesPoints(e,s,101)}getBodyAnnotation(e){for(const s in this._paneDic){const t=this._paneDic[s].body.getAnnotation(e);if(t)return t}}prepareRender(e,s){const t=this.chart.isInverted();this._prepareRender(),this._xAxes._prepare(e,this._rows,this._cols,t),this._yAxes._prepare(s,this._rows,this._cols,t)}$_parseSizes(e){let t;return t=s.isArray(e)&&e.length>0?e.slice(0):e>0?new Array(e).fill("*"):["*"],t.map(e=>{if(s.isString(e)){const t=e.trim();return{size:"*"===t?1:s.pickNum(parseFloat(t),1)}}return s.pickNum(+e,1)})}$_parsePanes(e,s){this._colSizes=this.$_parseSizes(s),this._rowSizes=this.$_parseSizes(e),this._cols=this._colSizes.length,this._rows=this._rowSizes.length}$_loadPanes(e){const t=this.chart,i=this.prop("extendBody")?t._body._config:void 0,o={};if(e=s.isArray(e)?e:s.isObject(e)?[e]:null,s.isArray(e)&&e.forEach(e=>{const s=+e.row||0,r=+e.col||0;if(r>=0&&r<this._cols&&s>=0&&s<this._rows){const n=new l(t,s,r);let h=e;n.init(),!i||e&&e.body&&!1===e.body.extended||(e?(h=Object.assign({},e),e.body?!1!==e.body.extended&&(h.body=Object.assign({},i,e.body)):h.body=i):h={body:i}),n._load(h),o[s+","+r]=n}}),i)for(let e=0;e<this._rows;e++)for(let s=0;s<this._cols;s++){const r=e+","+s;if(!o[r]){const n=new l(t,e,s);n.init(),n._load({body:i}),o[r]=n}}return o}$_collectPanes(e){const s=[];for(let t=0;t<this._rows;t++){const i=[];for(let s=0;s<this._cols;s++){const o=this._paneDic[t+","+s]||new l(e,t,s)._initObject();i.push(o)}s.push(i)}return s}}_.defaults=s.extend(s.ChartItem.defaults,{visible:!1,extendBody:!0,gap:0});class d extends s.SectionView{constructor(){super(...arguments),this.views=[],this._gap=0}isEmpty(){return 0===this.views.length}prepare(e,s,t,i,o){const r=this.views,n=[];for(this.isX=i,o._axes.forEach(e=>{e.checkVisible()&&t.isValidAxis(e)&&n.push(e)});r.length<n.length;){const t=s.createAxisView(e);this.add(t),r.push(t)}for(;r.length>n.length;)r.pop().remove();if(r.forEach((e,s)=>{e.setModel(n[s])}),this.axes=n,this.setVis(r.length>0)){const e=r[0].model;this._gap=e.chart.getAxesGap()}}prepareGuides(e,s,t){const i=this.views,o=this.axes;i.forEach((t,i)=>{const r=o[i];s.forEach(s=>{s.forEach(s=>{s.isConnected(r)&&t.setVis(this.visible)&&(t.prepareGuides(e,s.row,s.col,s._guideContainer,s._frontGuideContainer),r._isHorz||(s._axes||(s._axes=[]),s._axes.push(r)))})})}),s.forEach(s=>{s.forEach(s=>{s._axes&&(s._gridRowContainer.addAll(e,s._axes),s._axes=[])})})}checkHeights(e,s,t){return this.views.length>0?this.$_checkHeights(this.views,e,s,t):0}$_checkHeights(e,s,t,i){let o=0;return e&&(e.forEach(e=>{o+=e.checkHeight(s,t,i)}),o+=(this.views.length-1)*this._gap),o}checkWidths(e,s,t){return this.views.length>0?this.$_checkWidths(this.views,e,s,t):0}$_checkWidths(e,s,t,i){let o=0;return e&&(e.forEach(e=>{o+=e.checkWidth(s,t,i)}),o+=(this.views.length-1)*this._gap),o}getScrollView(e){var s;for(const t of this.views)if(null===(s=t._scrollView)||void 0===s?void 0:s.contains(e))return t._scrollView}setMargins(e,s,t,i){this.views.forEach(o=>o.setMargins(e,s,t,i))}_setInverted(e){super._setInverted(e),this.isHorz=e&&!this.isX||!e&&this.isX}_doMeasure(e,s,t,i,o){const r=this.axes;if(this.isHorz){let s=0;return this.views.forEach((n,h)=>{s+=n.measure(e,r[h],t,i,o).height}),{width:t,height:s}}{let s=0;return this.views.forEach((n,h)=>{s+=n.measure(e,r[h],t,i,o).width}),{width:s,height:i}}}_doLayout(e){const s=this.views,t=this.width,i=this.height,o=s.length;let r=0,n=o-1;if(this.isHorz){let e,h,a=0;for(;r<o;r++){const e=s[r];if(e.model._posValue()<1)break;e.trans(0,a),a+=e.mh}for(e=a,a=i;n>=0;n--){const e=s[n];if(e.model._posValue()>-1)break;a-=e.mh,e.trans(0,a)}h=a;const c=h-e;let l=0;for(let e=r;e<=n;e++)l+=s[e].mh;e+=(c-l)/2;for(let t=r;t<=n;t++){const i=s[t];i.trans(0,e),e+=i.mh}s.forEach(e=>{e.resize(t,e.mh),e.model._calcPoints(t,999),e.layout()})}else{let e,h,a=0;for(;r<o;r++){const e=s[r];if(e.model._posValue()>-1)break;e.trans(a,0),a+=e.mw}for(e=a,a=t;n>=0;n--){const e=s[n];if(e.model._posValue()<1)break;a-=e.mw,e.trans(a,0)}h=a;const c=h-e;let l=0;for(let e=r;e<=n;e++)l+=s[e].mw;e+=(c-l)/2;for(let t=r;t<=n;t++){const i=s[t];i.trans(e,0),e+=i.mw}s.forEach(e=>{e.resize(e.mw,i),e.model._calcPoints(i,999),e.layout()})}}}class p extends s.SectionView{constructor(e,s){super(e,"rct-axis-container"),this.isX=s,this.sections=[]}prepare(e,s,t,i,o,r){const n=this.isX?i.getRow(o):i.getColumn(o);for(;this.sections.length<n.length;){const s=new d(e);this.add(s),this.sections.push(s)}for(;this.sections.length>n.length;)this.sections.pop().remove();this.sections.forEach((i,r)=>{this.isX?(i.row=o,i.col=r):(i.col=o,i.row=r),i.prepare(e,s,t,this.isX,n[r])}),this._setInverted(r)}prepareGuides(e,s,t,i){const o=this.isX?t.getRow(i):t.getColumn(i);for(;this.sections.length<o.length;){const s=new d(e);this.add(s),this.sections.push(s)}for(;this.sections.length>o.length;)this.sections.pop().remove();this.sections.forEach((o,r)=>{this.isX?(o.row=i,o.col=r):(o.col=i,o.row=r),o.prepareGuides(e,s,t)})}checkWidths(e,s,t){return this.sections.length>0?this._isHorz?this.sections.reduce((i,o)=>i+o.checkWidths(e,s,t),0):this.sections.reduce((i,o)=>Math.max(i,o.checkWidths(e,s,t)),0):0}checkHeights(e,s,t){return this.sections.length>0?this._isHorz?this.sections.reduce((i,o)=>Math.max(i,o.checkHeights(e,s,t)),0):this.sections.reduce((i,o)=>i+o.checkHeights(e,s,t),0):0}_setInverted(e){super._setInverted(e),this._isHorz=e&&!this.isX||!e&&this.isX}_doMeasure(e,t,i,o,r){let n=0,h=0;return this._isHorz?this.sections.forEach(n=>{h=s.maxv(h,n.measure(e,t,i,o,r).height)}):this.sections.forEach(h=>{n=s.maxv(n,h.measure(e,t,i,o,r).width)}),{width:n,height:h}}_doLayout(e){this._isHorz?this.height>0&&this.sections.forEach((s,t)=>{s.resize(e[2*(t+1)]-e[2*(t+1)-1],this.height),s.trans(e[2*t+1]-e[1],0),s.layout()}):this.width>0&&this.sections.forEach((s,t)=>{s.resize(this.width,e[2*(t+1)]-e[2*(t+1)-1]),s.trans(0,this.height-(e[2*(t+1)]-e[1])),s.layout()})}layoutPanes(e,s){this.sections.forEach((t,i)=>{const[o,r]=e[i],n=r-o;this._isHorz?(t.resize(n,this.height),t.trans(o-s,0)):(t.resize(this.width,n),t.trans(0,this.height-(r-s))),t.layout()})}}class u extends s.BodyView{constructor(e,t){super(e,t),this.row=0,this.col=0,this.add(this._legendView=new s.LegendView(e))}getCol(){return this.col}getRow(){return this.row}getTooltipPos(){return{x:this.parent.parent.tx+this.tx,y:this.parent.parent.ty+this.ty}}prepareRender(e,t){const i=t.chart,o=t.depth.visible,r=this.row,n=this.col,h=i._split.getPane(r,n).body;this._animatable=s.RcControl._animatable&&i.animatable(),this._prepareSeries(e,t,i._getSeries().getPaneSeries(r,n),o),this._prepareGauges(e,i,i._getGauges().getPaneVisibles(r,n)),this._prepareAnnotations(e,h.getAnnotations().concat(i._getAnnotations().getPaneVisibles(r,n)))}_doMeasure(e,s,t,i,o){return this._legendView.setVis(s.pane.legend.visible)&&this._legendView.measure(e,s.pane.legend,t,i,o),super._doMeasure(e,s,t,i,o)}_doLayout(){super._doLayout();const e=this._legendView;if(e.visible){this._seriesViews.forEach(s=>{if(s.needDecoreateLegend()){const t=e.legendOfSeries(s.model);t&&s.decoreateLegend(t)}});const s=e.model,t=s.prop("align"),i=s.prop("verticalAlign");let o=0,r=0,n=+s.prop("offsetX")||0;switch(t){case"right":o+=this.width-e.mw-n;break;case"center":o+=(this.width-e.mw)/2+n;break;default:o+=n}switch(n=+s.prop("offsetY")||0,i){case"bottom":r+=this.height-e.mh-n;break;case"middle":r+=(this.height-e.mh)/2+n;break;default:r+=n}e.trans(o,r).resize(e.mw,e.mh),e.layout()}}}class f extends s.PaneContainer{constructor(e,s){super(e,f.STYLE_NAME),this._bodies=[],this._xContainers=[],this._yContainers=[],this._owner=s}get bodies(){return this._bodies}bodyViewOf(e){return this._bodies.find(s=>s.contains(e))}axisViewOf(e){for(const s of[this._xContainers,this._yContainers])for(const t of s)for(const s of t.sections){const t=s.views.find(s=>s.model===e);if(t)return t}}prepare(e,s){s.chart,this.$_init(e),this._model=s,this.$_prepareBodies(e,s)}measure(e,s,t,i,o){const r=s.chart,n=this._inverted=s.chart.isInverted(),h=s._xAxes,a=s._yAxes,c=t,l=i;this.$_prepareAxes(e,h,!0,n),this.$_prepareAxes(e,a,!1,n),s.measureAxes(t,i,n,o),n?(t-=this._xContainers.reduce((s,o)=>s+o.checkWidths(e,t,i),0),i-=this._yContainers.reduce((s,o)=>s+o.checkHeights(e,t,i),0)):(i-=this._xContainers.reduce((s,o)=>s+o.checkHeights(e,t,i),0),t-=this._yContainers.reduce((s,o)=>s+o.checkWidths(e,t,i),0)),s.measureAxes(t,i,n,o),this._xContainers.forEach(s=>s.measure(e,r,t,i,o)),this._yContainers.forEach(s=>s.measure(e,r,t,i,o)),t=c,i=l,n?(t-=this._xContainers.reduce((e,s)=>e+s.mw,0),i-=this._yContainers.reduce((e,s)=>e+s.mh,0)):(i-=this._xContainers.reduce((e,s)=>e+s.mh,0),t-=this._yContainers.reduce((e,s)=>e+s.mw,0)),o++,s.measureAxes(t,i,n,o),this.$_prepareAxisGuides(e,h,!0),this.$_prepareAxisGuides(e,a,!1),this._xContainers.forEach(s=>{s.measure(e,r,t,i,o)}),this._yContainers.forEach(s=>{s.measure(e,r,t,i,o)});const _=s.getXLens(n?i:t),d=s.getYLens(n?t:i);s.completeAxesPoints(_,d)}layout(){const e=this._model,s=this.width,t=this.height;this._back.resize(s,t),this.$_calcExtents(e,s,t),this.$_layoutAxes(e,!0,s,t),this.$_layoutAxes(e,!1,s,t),this.$_layoutBodies(e,s,t)}seriesByDom(e){for(const s of this._bodies){const t=s.seriesByDom(e);if(t)return t}}annotationByDom(e){for(const s of this._bodies){const t=s.annotationByDom(e);if(t)return t}}getSeries(e){for(const s of this.bodies){const t=s.findSeries(e);if(t)return t}}legendByDom(e){for(const s of this.bodies){const t=s._legendView.legendByDom(e);if(t)return t}}$_init(e){this._back||(this.add(this._back=new s.RectElement(e)),this._back.setStyles({fill:"none"}),this.add(this._bodyContainer=new s.LayerElement(e,void 0)),this.add(this._axisContainer=new s.LayerElement(e,void 0)))}$_prepareBodies(e,s){s.chart;const t=s.paneCount,i=s.rowCount,o=s.colCount,r=this._bodies,n=this._bodyMap=[];for(;r.length<t;){const s=new u(e,this._owner);this._bodyContainer.add(s),r.push(s)}for(;r.length>t;)r.pop().remove();for(let e=0;e<i;e++){const s=[];for(let t=0;t<o;t++){const i=r[e*o+t];s.push(i),i.row=e,i.col=t}n.push(s)}r.forEach(t=>{t.prepareRender(e,s.getPane(t.row,t.col).body),t.prepareGuideContainers(),t._gridRowContainer.prepare()})}$_prepareAxes(e,s,t,i){const o=this._model.chart,r=t?this._xContainers:this._yContainers,n=t?s.rows():s.cols();for(;r.length<n;){const s=new p(e,t);this._axisContainer.add(s),r.push(s)}for(;r.length>n;)r.pop().remove();r.forEach((t,r)=>{t.prepare(e,this._owner,o,s,r,i)})}$_prepareAxisGuides(e,s,t){(t?this._xContainers:this._yContainers).forEach((t,i)=>{t.prepareGuides(e,this._bodyMap,s,i)})}$_calc(e,t,i,o){const r=i.length,n=new Array(2*(r+1)),h=Math.max(0,s.pickNum(this._model.prop("gap"),0)),a=t-e.reduce((e,s)=>e+s[o],0)-(r>1?(r-1)*h:0),c=this._model._calcSizes(i,a);let l=0,_=0;for(_=0;_<r;_++)n[2*_]=l,n[2*_+1]=l+=e[_][o],l+=c[_],_<r-1&&(l+=h);return n[2*_]=l,n[2*_+1]=l+e[_][o],{pts:n,sizes:c}}$_paneBounds(e,s){return s.map((s,t)=>[e[2*t+1],e[2*t+1]+s])}$_calcExtents(e,s,t){if(this._inverted){const i=this.$_calc(this._xContainers,s,e.rowSizes(),"mw"),o=this.$_calc(this._yContainers,t,e.colSizes(),"mh");this._rowPoints=i.pts,this._colPoints=o.pts,this._rowPaneSizes=i.sizes,this._colPaneSizes=o.sizes}else{const i=this.$_calc(this._xContainers,t,e.rowSizes(),"mh"),o=this.$_calc(this._yContainers,s,e.colSizes(),"mw");this._rowPoints=i.pts,this._colPoints=o.pts,this._rowPaneSizes=i.sizes,this._colPaneSizes=o.sizes}}$_layoutAxes(e,s,t,i){const o=this.control._padding,r=this._rowPoints,n=this._colPoints,h=s?this._xContainers:this._yContainers;if(this._inverted)if(s){const e=n[1],s=n[n.length-2]-e;h.forEach((e,t)=>{e.resize(e.mw,s),e.trans(r[2*t],i-n[n.length-2]),e.layoutPanes(this.$_paneBounds(n,this._colPaneSizes),n[1])})}else{const e=r[1],s=r[r.length-2]-e;h.forEach((t,h)=>{const a=t.sections;for(let e=0,s=a.length;e<s;e++){const t=a[e],i=0===e?o.left:0,n=e===s-1?o.right:0;let h=0,c=0;s>1&&(h=r[2*e+1]-r[2*e],c=r[2*(e+1)+1]-r[2*(e+1)],0===e?a[e+1].isEmpty()?c=r[2*(e+1)]-r[2*(e+1)-1]:c/=2:e===s-1?a[e-1].isEmpty()?h=r[2*(e-1)]-r[2*(e-1)-1]:h/=2:(a[e-1].isEmpty()?h=r[2*(e-1)]-r[2*(e-1)-1]:h/=2,a[e+1].isEmpty()?c=r[2*(e+1)]-r[2*(e+1)-1]:c/=2)),t.setMargins(i,h,c,n)}t.resize(s,t.mh),t.trans(e,i-n[2*h+1]),t.layoutPanes(this.$_paneBounds(r,this._rowPaneSizes),r[1])})}else if(s){const e=n[1];t=n[n.length-2]-e,h.forEach((s,a)=>{const c=s.sections;for(let e=0,s=c.length;e<s;e++){const t=c[e],i=0===a?o.left:0,l=a===h.length-1?o.right:0;let _=0,d=0;s>1&&(_=n[2*e+1]-n[2*e],d=n[2*(e+1)+1]-n[2*(e+1)],0===e?c[e+1].isEmpty()?d=n[2*(e+1)]-n[2*(e+1)-1]:d/=2:e===s-1?c[e-1].isEmpty()?_=n[2*(e-1)]-n[2*(e-1)-1]:_/=2:(c[e-1].isEmpty()?_=n[2*(e-1)]-n[2*(e-1)-1]:_/=2,c[e+1].isEmpty()?d=n[2*(e+1)]-r[2*(e+1)-1]:d/=2)),t.setMargins(i,_,d,l)}s.resize(t,s.mh),s.trans(e,i-r[2*a+1]),s.layoutPanes(this.$_paneBounds(n,this._colPaneSizes),n[1])})}else{const e=r[r.length-2],s=e-r[1];h.forEach((t,o)=>{t.resize(t.mw,s),t.trans(n[2*o],i-e),t.layoutPanes(this.$_paneBounds(r,this._rowPaneSizes),r[1])})}}$_layoutBodies(e,s,t){const i=e.rowCount,o=e.colCount,r=this.$_paneBounds(this._rowPoints,this._rowPaneSizes),n=this.$_paneBounds(this._colPoints,this._colPaneSizes),h=this._bodies;if(this._inverted)for(let s=0;s<i;s++){const[t,i]=r[s];for(let r=0;r<o;r++){const a=h[s*o+r],[c,l]=n[r];a.measure(this.doc,e.getPane(s,r).body,i-t,l-c,1),a.resize(i-t,l-c),a.trans(t,this.height-l),a.layout()}}else for(let s=0;s<i;s++){const[i,a]=r[s];for(let r=0;r<o;r++){const c=h[s*o+r],[l,_]=n[r];c.measure(this.doc,e.getPane(s,r).body,_-l,a-i,1),c.resize(_-l,a-i),c.trans(l,t-a),c.layout()}}}}function g(e){(function(e){return!!(e&&e.ChartObject&&e.ChartView)})(e)&&(e.ChartObject.registerSplitClass(_),e.ChartView.registerPaneClass(f))}f.STYLE_NAME="rct-panes",g(i),e.Split=_,e.default=g,Object.defineProperty(e,"__esModule",{value:!0})});
|
package/split.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
/**
|
|
3
|
-
* RealChart Split v1.
|
|
3
|
+
* RealChart Split v1.5.0
|
|
4
4
|
* Copyright (C) 2023-2026 WooriTech Inc.
|
|
5
5
|
* All Rights Reserved.
|
|
6
6
|
*/
|
|
7
|
-
import{extend as e,Body as s,ChartItem as t,isArray as i,maxv as o,pickNum as r,isObject as n,isNumber as h,isString as a,Legend as c,PaneContainer as l,RectElement as _,LayerElement as d,SectionView as p,BodyView as u,LegendView as g,RcControl as f}from"./index.mjs";class w{constructor(e,s){this.row=e,this.col=s,this._axes=[]}sort(e,s){const t=s&&!e||!s&&e;this._axes.length>1&&(t?this._axes.sort((e,s)=>{const t=e._posValue(),i=s._posValue();return t===i?t<0?s._index-e._index:t>0?e._index-s._index:e.row!==s.row?s.row-e.row:e.row<this.row?s._index-e._index:e._index-s._index:i-t}):this._axes.sort((e,s)=>{const t=e._posValue(),i=s._posValue();return t===i?t<0?e._index-s._index:t>0?s._index-e._index:e.col!==s.col?e.col-e.col:e.col<this.col?e._index-s._index:s._index-e._index:t-i}))}}class x{constructor(e,s){this.chart=e,this.isX=s}rows(){return this._matrix.length}cols(){return this._matrix[0].length}_prepare(e,s,t,i){this._doPrepare(e,s,t),this._matrix.forEach(e=>{e.forEach(e=>e.sort(this.isX,i))})}get(e,s){return this._matrix[e][s]}getRow(e){return this._matrix[e]}getColumn(e){return this._matrix.map(s=>s[e])}_buildTicks(e,s){const t=this.isX;this._matrix.forEach((i,o)=>{i.forEach((i,o)=>{i._axes.forEach(i=>{!i.isBased()&&(s<2||t)&&i._buildTicks(e[t?i.prop("col"):i.prop("row")],s)})})}),this._matrix.forEach((i,o)=>{i.forEach((i,o)=>{i._axes.forEach(i=>{i.isBased()&&(s<2||t)&&i._buildTicks(e[t?i.prop("col"):i.prop("row")],s)})})})}_calcPoints(e,s){const t=this.isX;this._matrix.forEach(i=>{i.forEach((i,o)=>{i._axes.forEach(i=>{if(s<2||t){const o=t?i.prop("col"):i.prop("row");i._calcPoints(e[o],s)}})})})}}class m extends x{constructor(e){super(e,!0)}_doPrepare(e,s,t){const i=this._matrix=new Array(s+1);for(let e=0;e<i.length;e++){i[e]=[];for(let s=0;s<t;s++)i[e].push(new w(e,s))}e.forEach(e=>{var t,o;const r=e.prop("position");let n=e.row;"opposite"===r?(n++,e._runPos=r):n<s-1&&"between"===r?(n++,e._runPos="normal"):e._runPos=r,null===(o=null===(t=i[n])||void 0===t?void 0:t[e.col])||void 0===o||o._axes.push(e)})}}class y extends x{constructor(e){super(e,!1)}_doPrepare(e,s,t){const i=this._matrix=new Array(s);for(let e=0;e<i.length;e++){i[e]=[];for(let s=0;s<=t;s++)i[e].push(new w(e,s))}e.forEach(e=>{var s,o;const r=e.prop("position");let n=e.col;"opposite"===r?(n++,e._runPos=r):e.col<t-1&&"between"===r?(n++,e._runPos="normal"):e._runPos=r,null===(o=null===(s=i[e.row])||void 0===s?void 0:s[n])||void 0===o||o._axes.push(e)})}}class b extends s{constructor(e){super(e.chart),this.pane=e}contains(e){return e.col===this.pane.col||e.row===this.pane.row}}b.defaults=e(s.defaults,{extended:!0,radius:void 0,centerX:void 0,centerY:void 0});class P extends c{constructor(e){super(e.chart),this.pane=e}_doPrepareRender(e){super._doPrepareRender(e),this._location="body"}_getLegendSources(){return this.prop("visible")?this.chart._getSeries().getLegendSources(this.pane.row,this.pane.col):[]}}class E extends t{constructor(e,s,t){super(e),this.row=s,this.col=t}_doInit(e){this._body=this._addChild("body",new b(this)),this._legend=this._addChild("legend",new P(this))}get body(){return this._body}get legend(){return this._legend}_prepareRender(){this._body._prepareRender(),this._legend._prepareRender()}}class z extends t{constructor(e){super(e),this._cols=1,this._rows=1,this._paneDic={},this._panes=[],this._xAxes=new m(e),this._yAxes=new y(e)}get count(){return this._rows*this._cols}get rowCount(){return this._rows}get colCount(){return this._cols}get paneCount(){return this._rows*this._cols}colSizes(){return this._colSizes}rowSizes(){return this._rowSizes}getPane(e,s){return this._panes[e][s]}getRow(e){return this._panes[e]}getColumn(e){return this._panes.map(s=>s[e])}getAxisOf(e,s){var t,i;const o=this.chart,r=e.body;if(r){const n=r.pane;return s?o._getXAxes().get(e.prop("xAxis"))||this._xAxes.get(n.row,n.col)._axes[0]||(null===(t=o._getSeries().getPaneSeries(n.row,n.col)[0])||void 0===t?void 0:t._xAxisObj):o._getXAxes().get(e.prop("yAxis"))||this._yAxes.get(r.pane.row,r.pane.col)._axes[0]||(null===(i=o._getSeries().getPaneSeries(n.row,n.col)[0])||void 0===i?void 0:i._yAxisObj)}}isValidAxis(e){return e&&e.row<this._rows&&e.col<this._cols}_doLoadProp(e,s){return["panes","cols","rows"].indexOf(e)>=0||super._doLoadProp(e,s)}_doSetSimple(e,s){const t=arguments.length<2?e:s;if(i(t)&&t.length>0){const e=o(1,+t[0]),s=o(1,r(+t[1],e));return e>0&&s>0&&(this.$_parsePanes(e,s),this.visible=!0),!0}return super._doSetSimple(e,t)}_load(e){return super._load(e),n(e)&&(this.$_parsePanes(e.rows,e.cols),this._paneDic=this.$_loadPanes(e.panes)),this}_doPrepareRender(e){this._panes=this.$_collectPanes(e),this._panes.forEach(e=>e.forEach(e=>e._prepareRender()))}_calcSizes(e,s){const t=e.length,i=new Array(t);let o=0;if(t>1){let r=s,n=0;for(o=0;o<t;o++){const s=e[o];h(s)?r-=i[o]=Math.max(0,Math.min(r,s)):n+=s.size}if(n>0)for(o=0;o<t;o++){const s=e[o];h(s)||(i[o]=r*s.size/n)}}else i[o]=s;return i}getXLens(e){return this._calcSizes(this._colSizes,e)}getYLens(e){return this._calcSizes(this._rowSizes,e)}measureAxes(e,s,t,i){const o=this.getXLens(t?s:e),r=this.getYLens(t?e:s);this._xAxes._buildTicks(o,i),this._yAxes._buildTicks(r,i),this.$_calcAxesPoints(o,r,i)}$_calcAxesPoints(e,s,t){this._xAxes._calcPoints(e,t),this._yAxes._calcPoints(s,t)}completeAxesPoints(e,s){this.$_calcAxesPoints(e,s,101)}getBodyAnnotation(e){for(const s in this._paneDic){const t=this._paneDic[s].body.getAnnotation(e);if(t)return t}}prepareRender(e,s){const t=this.chart.isInverted();this._prepareRender(),this._xAxes._prepare(e,this._rows,this._cols,t),this._yAxes._prepare(s,this._rows,this._cols,t)}$_parseSizes(e){let s;return s=i(e)&&e.length>0?e.slice(0):e>0?new Array(e).fill("*"):["*"],s.map(e=>{if(a(e)){const s=e.trim();return{size:"*"===s?1:r(parseFloat(s),1)}}return r(+e,1)})}$_parsePanes(e,s){this._colSizes=this.$_parseSizes(s),this._rowSizes=this.$_parseSizes(e),this._cols=this._colSizes.length,this._rows=this._rowSizes.length}$_loadPanes(e){const s=this.chart,t=this.prop("extendBody")?s._body._config:void 0,o={};if(e=i(e)?e:n(e)?[e]:null,i(e)&&e.forEach(e=>{const i=+e.row||0,r=+e.col||0;if(r>=0&&r<this._cols&&i>=0&&i<this._rows){const n=new E(s,i,r);let h=e;n.init(),!t||e&&e.body&&!1===e.body.extended||(e?(h=Object.assign({},e),e.body?!1!==e.body.extended&&(h.body=Object.assign({},t,e.body)):h.body=t):h={body:t}),n._load(h),o[i+","+r]=n}}),t)for(let e=0;e<this._rows;e++)for(let i=0;i<this._cols;i++){const r=e+","+i;if(!o[r]){const n=new E(s,e,i);n.init(),n._load({body:t}),o[r]=n}}return o}$_collectPanes(e){const s=[];for(let t=0;t<this._rows;t++){const i=[];for(let s=0;s<this._cols;s++){const o=this._paneDic[t+","+s]||new E(e,t,s)._initObject();i.push(o)}s.push(i)}return s}}z.defaults=e(t.defaults,{visible:!1,extendBody:!0,gap:0});class v extends p{constructor(){super(...arguments),this.views=[],this._gap=0}isEmpty(){return 0===this.views.length}prepare(e,s,t,i,o){const r=this.views,n=[];for(this.isX=i,o._axes.forEach(e=>{e.checkVisible()&&t.isValidAxis(e)&&n.push(e)});r.length<n.length;){const t=s.createAxisView(e);this.add(t),r.push(t)}for(;r.length>n.length;)r.pop().remove();if(r.forEach((e,s)=>{e.setModel(n[s])}),this.axes=n,this.setVis(r.length>0)){const e=r[0].model;this._gap=e.chart.getAxesGap()}}prepareGuides(e,s,t){const i=this.views,o=this.axes;i.forEach((t,i)=>{const r=o[i];s.forEach(s=>{s.forEach(s=>{s.isConnected(r)&&t.setVis(this.visible)&&(t.prepareGuides(e,s.row,s.col,s._guideContainer,s._frontGuideContainer),r._isHorz||(s._axes||(s._axes=[]),s._axes.push(r)))})})}),s.forEach(s=>{s.forEach(s=>{s._axes&&(s._gridRowContainer.addAll(e,s._axes),s._axes=[])})})}checkHeights(e,s,t){return this.views.length>0?this.$_checkHeights(this.views,e,s,t):0}$_checkHeights(e,s,t,i){let o=0;return e&&(e.forEach(e=>{o+=e.checkHeight(s,t,i)}),o+=(this.views.length-1)*this._gap),o}checkWidths(e,s,t){return this.views.length>0?this.$_checkWidths(this.views,e,s,t):0}$_checkWidths(e,s,t,i){let o=0;return e&&(e.forEach(e=>{o+=e.checkWidth(s,t,i)}),o+=(this.views.length-1)*this._gap),o}getScrollView(e){var s;for(const t of this.views)if(null===(s=t._scrollView)||void 0===s?void 0:s.contains(e))return t._scrollView}setMargins(e,s,t,i){this.views.forEach(o=>o.setMargins(e,s,t,i))}_setInverted(e){super._setInverted(e),this.isHorz=e&&!this.isX||!e&&this.isX}_doMeasure(e,s,t,i,o){const r=this.axes;if(this.isHorz){let s=0;return this.views.forEach((n,h)=>{s+=n.measure(e,r[h],t,i,o).height}),{width:t,height:s}}{let s=0;return this.views.forEach((n,h)=>{s+=n.measure(e,r[h],t,i,o).width}),{width:s,height:i}}}_doLayout(e){const s=this.views,t=this.width,i=this.height,o=s.length;let r=0,n=o-1;if(this.isHorz){let e,h,a=0;for(;r<o;r++){const e=s[r];if(e.model._posValue()<1)break;e.trans(0,a),a+=e.mh}for(e=a,a=i;n>=0;n--){const e=s[n];if(e.model._posValue()>-1)break;a-=e.mh,e.trans(0,a)}h=a;const c=h-e;let l=0;for(let e=r;e<=n;e++)l+=s[e].mh;e+=(c-l)/2;for(let t=r;t<=n;t++){const i=s[t];i.trans(0,e),e+=i.mh}s.forEach(e=>{e.resize(t,e.mh),e.model._calcPoints(t,999),e.layout()})}else{let e,h,a=0;for(;r<o;r++){const e=s[r];if(e.model._posValue()>-1)break;e.trans(a,0),a+=e.mw}for(e=a,a=t;n>=0;n--){const e=s[n];if(e.model._posValue()<1)break;a-=e.mw,e.trans(a,0)}h=a;const c=h-e;let l=0;for(let e=r;e<=n;e++)l+=s[e].mw;e+=(c-l)/2;for(let t=r;t<=n;t++){const i=s[t];i.trans(e,0),e+=i.mw}s.forEach(e=>{e.resize(e.mw,i),e.model._calcPoints(i,999),e.layout()})}}}class C extends p{constructor(e,s){super(e,"rct-axis-container"),this.isX=s,this.sections=[]}prepare(e,s,t,i,o,r){const n=this.isX?i.getRow(o):i.getColumn(o);for(;this.sections.length<n.length;){const s=new v(e);this.add(s),this.sections.push(s)}for(;this.sections.length>n.length;)this.sections.pop().remove();this.sections.forEach((i,r)=>{this.isX?(i.row=o,i.col=r):(i.col=o,i.row=r),i.prepare(e,s,t,this.isX,n[r])}),this._setInverted(r)}prepareGuides(e,s,t,i){const o=this.isX?t.getRow(i):t.getColumn(i);for(;this.sections.length<o.length;){const s=new v(e);this.add(s),this.sections.push(s)}for(;this.sections.length>o.length;)this.sections.pop().remove();this.sections.forEach((o,r)=>{this.isX?(o.row=i,o.col=r):(o.col=i,o.row=r),o.prepareGuides(e,s,t)})}checkWidths(e,s,t){return this.sections.length>0?this._isHorz?this.sections.reduce((i,o)=>i+o.checkWidths(e,s,t),0):this.sections.reduce((i,o)=>Math.max(i,o.checkWidths(e,s,t)),0):0}checkHeights(e,s,t){return this.sections.length>0?this._isHorz?this.sections.reduce((i,o)=>Math.max(i,o.checkHeights(e,s,t)),0):this.sections.reduce((i,o)=>i+o.checkHeights(e,s,t),0):0}_setInverted(e){super._setInverted(e),this._isHorz=e&&!this.isX||!e&&this.isX}_doMeasure(e,s,t,i,r){let n=0,h=0;return this._isHorz?this.sections.forEach(n=>{h=o(h,n.measure(e,s,t,i,r).height)}):this.sections.forEach(h=>{n=o(n,h.measure(e,s,t,i,r).width)}),{width:n,height:h}}_doLayout(e){this._isHorz?this.height>0&&this.sections.forEach((s,t)=>{s.resize(e[2*(t+1)]-e[2*(t+1)-1],this.height),s.trans(e[2*t+1]-e[1],0),s.layout()}):this.width>0&&this.sections.forEach((s,t)=>{s.resize(this.width,e[2*(t+1)]-e[2*(t+1)-1]),s.trans(0,this.height-(e[2*(t+1)]-e[1])),s.layout()})}layoutPanes(e,s){this.sections.forEach((t,i)=>{const[o,r]=e[i],n=r-o;this._isHorz?(t.resize(n,this.height),t.trans(o-s,0)):(t.resize(this.width,n),t.trans(0,this.height-(r-s))),t.layout()})}}class A extends u{constructor(e,s){super(e,s),this.row=0,this.col=0,this.add(this._legendView=new g(e))}getCol(){return this.col}getRow(){return this.row}getTooltipPos(){return{x:this.parent.parent.tx+this.tx,y:this.parent.parent.ty+this.ty}}prepareRender(e,s){const t=s.chart,i=s.depth.visible,o=this.row,r=this.col,n=t._split.getPane(o,r).body;this._animatable=f._animatable&&t.animatable(),this._prepareSeries(e,s,t._getSeries().getPaneSeries(o,r),i),this._prepareGauges(e,t,t._getGauges().getPaneVisibles(o,r)),this._prepareAnnotations(e,n.getAnnotations().concat(t._getAnnotations().getPaneVisibles(o,r)))}_doMeasure(e,s,t,i,o){return this._legendView.setVis(s.pane.legend.visible)&&this._legendView.measure(e,s.pane.legend,t,i,o),super._doMeasure(e,s,t,i,o)}_doLayout(){super._doLayout();const e=this._legendView;if(e.visible){this._seriesViews.forEach(s=>{if(s.needDecoreateLegend()){const t=e.legendOfSeries(s.model);t&&s.decoreateLegend(t)}});const s=e.model,t=s.prop("align"),i=s.prop("verticalAlign");let o=0,r=0,n=+s.prop("offsetX")||0;switch(t){case"right":o+=this.width-e.mw-n;break;case"center":o+=(this.width-e.mw)/2+n;break;default:o+=n}switch(n=+s.prop("offsetY")||0,i){case"bottom":r+=this.height-e.mh-n;break;case"middle":r+=(this.height-e.mh)/2+n;break;default:r+=n}e.trans(o,r).resize(e.mw,e.mh),e.layout()}}}class S extends l{constructor(e,s){super(e,S.STYLE_NAME),this._bodies=[],this._xContainers=[],this._yContainers=[],this._owner=s}get bodies(){return this._bodies}bodyViewOf(e){return this._bodies.find(s=>s.contains(e))}axisViewOf(e){for(const s of[this._xContainers,this._yContainers])for(const t of s)for(const s of t.sections){const t=s.views.find(s=>s.model===e);if(t)return t}}prepare(e,s){s.chart,this.$_init(e),this._model=s,this.$_prepareBodies(e,s)}measure(e,s,t,i,o){const r=s.chart,n=this._inverted=s.chart.isInverted(),h=s._xAxes,a=s._yAxes,c=t,l=i;this.$_prepareAxes(e,h,!0,n),this.$_prepareAxes(e,a,!1,n),s.measureAxes(t,i,n,o),n?(t-=this._xContainers.reduce((s,o)=>s+o.checkWidths(e,t,i),0),i-=this._yContainers.reduce((s,o)=>s+o.checkHeights(e,t,i),0)):(i-=this._xContainers.reduce((s,o)=>s+o.checkHeights(e,t,i),0),t-=this._yContainers.reduce((s,o)=>s+o.checkWidths(e,t,i),0)),s.measureAxes(t,i,n,o),this._xContainers.forEach(s=>s.measure(e,r,t,i,o)),this._yContainers.forEach(s=>s.measure(e,r,t,i,o)),t=c,i=l,n?(t-=this._xContainers.reduce((e,s)=>e+s.mw,0),i-=this._yContainers.reduce((e,s)=>e+s.mh,0)):(i-=this._xContainers.reduce((e,s)=>e+s.mh,0),t-=this._yContainers.reduce((e,s)=>e+s.mw,0)),o++,s.measureAxes(t,i,n,o),this.$_prepareAxisGuides(e,h,!0),this.$_prepareAxisGuides(e,a,!1),this._xContainers.forEach(s=>{s.measure(e,r,t,i,o)}),this._yContainers.forEach(s=>{s.measure(e,r,t,i,o)});const _=s.getXLens(n?i:t),d=s.getYLens(n?t:i);s.completeAxesPoints(_,d)}layout(){const e=this._model,s=this.width,t=this.height;this._back.resize(s,t),this.$_calcExtents(e,s,t),this.$_layoutAxes(e,!0,s,t),this.$_layoutAxes(e,!1,s,t),this.$_layoutBodies(e,s,t)}seriesByDom(e){for(const s of this._bodies){const t=s.seriesByDom(e);if(t)return t}}annotationByDom(e){for(const s of this._bodies){const t=s.annotationByDom(e);if(t)return t}}getSeries(e){for(const s of this.bodies){const t=s.findSeries(e);if(t)return t}}legendByDom(e){for(const s of this.bodies){const t=s._legendView.legendByDom(e);if(t)return t}}$_init(e){this._back||(this.add(this._back=new _(e)),this._back.setStyles({fill:"none"}),this.add(this._bodyContainer=new d(e,void 0)),this.add(this._axisContainer=new d(e,void 0)))}$_prepareBodies(e,s){s.chart;const t=s.paneCount,i=s.rowCount,o=s.colCount,r=this._bodies,n=this._bodyMap=[];for(;r.length<t;){const s=new A(e,this._owner);this._bodyContainer.add(s),r.push(s)}for(;r.length>t;)r.pop().remove();for(let e=0;e<i;e++){const s=[];for(let t=0;t<o;t++){const i=r[e*o+t];s.push(i),i.row=e,i.col=t}n.push(s)}r.forEach(t=>{t.prepareRender(e,s.getPane(t.row,t.col).body),t.prepareGuideContainers(),t._gridRowContainer.prepare()})}$_prepareAxes(e,s,t,i){const o=this._model.chart,r=t?this._xContainers:this._yContainers,n=t?s.rows():s.cols();for(;r.length<n;){const s=new C(e,t);this._axisContainer.add(s),r.push(s)}for(;r.length>n;)r.pop().remove();r.forEach((t,r)=>{t.prepare(e,this._owner,o,s,r,i)})}$_prepareAxisGuides(e,s,t){(t?this._xContainers:this._yContainers).forEach((t,i)=>{t.prepareGuides(e,this._bodyMap,s,i)})}$_calc(e,s,t,i){const o=t.length,n=new Array(2*(o+1)),h=Math.max(0,r(this._model.prop("gap"),0)),a=s-e.reduce((e,s)=>e+s[i],0)-(o>1?(o-1)*h:0),c=this._model._calcSizes(t,a);let l=0,_=0;for(_=0;_<o;_++)n[2*_]=l,n[2*_+1]=l+=e[_][i],l+=c[_],_<o-1&&(l+=h);return n[2*_]=l,n[2*_+1]=l+e[_][i],{pts:n,sizes:c}}$_paneBounds(e,s){return s.map((s,t)=>[e[2*t+1],e[2*t+1]+s])}$_calcExtents(e,s,t){if(this._inverted){const i=this.$_calc(this._xContainers,s,e.rowSizes(),"mw"),o=this.$_calc(this._yContainers,t,e.colSizes(),"mh");this._rowPoints=i.pts,this._colPoints=o.pts,this._rowPaneSizes=i.sizes,this._colPaneSizes=o.sizes}else{const i=this.$_calc(this._xContainers,t,e.rowSizes(),"mh"),o=this.$_calc(this._yContainers,s,e.colSizes(),"mw");this._rowPoints=i.pts,this._colPoints=o.pts,this._rowPaneSizes=i.sizes,this._colPaneSizes=o.sizes}}$_layoutAxes(e,s,t,i){const o=this.control._padding,r=this._rowPoints,n=this._colPoints,h=s?this._xContainers:this._yContainers;if(this._inverted)if(s){const e=n[1],s=n[n.length-2]-e;h.forEach((e,t)=>{e.resize(e.mw,s),e.trans(r[2*t],i-n[n.length-2]),e.layoutPanes(this.$_paneBounds(n,this._colPaneSizes),n[1])})}else{const e=r[1],s=r[r.length-2]-e;h.forEach((t,h)=>{const a=t.sections;for(let e=0,s=a.length;e<s;e++){const t=a[e],i=0===e?o.left:0,n=e===s-1?o.right:0;let h=0,c=0;s>1&&(h=r[2*e+1]-r[2*e],c=r[2*(e+1)+1]-r[2*(e+1)],0===e?a[e+1].isEmpty()?c=r[2*(e+1)]-r[2*(e+1)-1]:c/=2:e===s-1?a[e-1].isEmpty()?h=r[2*(e-1)]-r[2*(e-1)-1]:h/=2:(a[e-1].isEmpty()?h=r[2*(e-1)]-r[2*(e-1)-1]:h/=2,a[e+1].isEmpty()?c=r[2*(e+1)]-r[2*(e+1)-1]:c/=2)),t.setMargins(i,h,c,n)}t.resize(s,t.mh),t.trans(e,i-n[2*h+1]),t.layoutPanes(this.$_paneBounds(r,this._rowPaneSizes),r[1])})}else if(s){const e=n[1];t=n[n.length-2]-e,h.forEach((s,a)=>{const c=s.sections;for(let e=0,s=c.length;e<s;e++){const t=c[e],i=0===a?o.left:0,l=a===h.length-1?o.right:0;let _=0,d=0;s>1&&(_=n[2*e+1]-n[2*e],d=n[2*(e+1)+1]-n[2*(e+1)],0===e?c[e+1].isEmpty()?d=n[2*(e+1)]-n[2*(e+1)-1]:d/=2:e===s-1?c[e-1].isEmpty()?_=n[2*(e-1)]-n[2*(e-1)-1]:_/=2:(c[e-1].isEmpty()?_=n[2*(e-1)]-n[2*(e-1)-1]:_/=2,c[e+1].isEmpty()?d=n[2*(e+1)]-r[2*(e+1)-1]:d/=2)),t.setMargins(i,_,d,l)}s.resize(t,s.mh),s.trans(e,i-r[2*a+1]),s.layoutPanes(this.$_paneBounds(n,this._colPaneSizes),n[1])})}else{const e=r[r.length-2],s=e-r[1];h.forEach((t,o)=>{t.resize(t.mw,s),t.trans(n[2*o],i-e),t.layoutPanes(this.$_paneBounds(r,this._rowPaneSizes),r[1])})}}$_layoutBodies(e,s,t){const i=e.rowCount,o=e.colCount,r=this.$_paneBounds(this._rowPoints,this._rowPaneSizes),n=this.$_paneBounds(this._colPoints,this._colPaneSizes),h=this._bodies;if(this._inverted)for(let s=0;s<i;s++){const[t,i]=r[s];for(let r=0;r<o;r++){const a=h[s*o+r],[c,l]=n[r];a.measure(this.doc,e.getPane(s,r).body,i-t,l-c,1),a.resize(i-t,l-c),a.trans(t,this.height-l),a.layout()}}else for(let s=0;s<i;s++){const[i,a]=r[s];for(let r=0;r<o;r++){const c=h[s*o+r],[l,_]=n[r];c.measure(this.doc,e.getPane(s,r).body,_-l,a-i,1),c.resize(_-l,a-i),c.trans(l,t-a),c.layout()}}}}function $(e){(function(e){return e.Series&&e.SeriesView})(e)&&(e.ChartObject.registerSplitClass(z),e.ChartView.registerPaneClass(S))}S.STYLE_NAME="rct-panes";export{z as Split,$ as default,$ as registerSplit};
|
|
7
|
+
import*as e from"./index.mjs";import{extend as s,Body as t,ChartItem as i,isArray as o,maxv as r,pickNum as n,isObject as h,isNumber as a,isString as c,Legend as _,PaneContainer as l,RectElement as d,LayerElement as p,SectionView as u,BodyView as g,LegendView as f,RcControl as w}from"./index.mjs";class x{constructor(e,s){this.row=e,this.col=s,this._axes=[]}sort(e,s){const t=s&&!e||!s&&e;this._axes.length>1&&(t?this._axes.sort((e,s)=>{const t=e._posValue(),i=s._posValue();return t===i?t<0?s._index-e._index:t>0?e._index-s._index:e.row!==s.row?s.row-e.row:e.row<this.row?s._index-e._index:e._index-s._index:i-t}):this._axes.sort((e,s)=>{const t=e._posValue(),i=s._posValue();return t===i?t<0?e._index-s._index:t>0?s._index-e._index:e.col!==s.col?e.col-e.col:e.col<this.col?e._index-s._index:s._index-e._index:t-i}))}}class m{constructor(e,s){this.chart=e,this.isX=s}rows(){return this._matrix.length}cols(){return this._matrix[0].length}_prepare(e,s,t,i){this._doPrepare(e,s,t),this._matrix.forEach(e=>{e.forEach(e=>e.sort(this.isX,i))})}get(e,s){return this._matrix[e][s]}getRow(e){return this._matrix[e]}getColumn(e){return this._matrix.map(s=>s[e])}_buildTicks(e,s){const t=this.isX;this._matrix.forEach((i,o)=>{i.forEach((i,o)=>{i._axes.forEach(i=>{!i.isBased()&&(s<2||t)&&i._buildTicks(e[t?i.prop("col"):i.prop("row")],s)})})}),this._matrix.forEach((i,o)=>{i.forEach((i,o)=>{i._axes.forEach(i=>{i.isBased()&&(s<2||t)&&i._buildTicks(e[t?i.prop("col"):i.prop("row")],s)})})})}_calcPoints(e,s){const t=this.isX;this._matrix.forEach(i=>{i.forEach((i,o)=>{i._axes.forEach(i=>{if(s<2||t){const o=t?i.prop("col"):i.prop("row");i._calcPoints(e[o],s)}})})})}}class y extends m{constructor(e){super(e,!0)}_doPrepare(e,s,t){const i=this._matrix=new Array(s+1);for(let e=0;e<i.length;e++){i[e]=[];for(let s=0;s<t;s++)i[e].push(new x(e,s))}e.forEach(e=>{var t,o;const r=e.prop("position");let n=e.row;"opposite"===r?(n++,e._runPos=r):n<s-1&&"between"===r?(n++,e._runPos="normal"):e._runPos=r,null===(o=null===(t=i[n])||void 0===t?void 0:t[e.col])||void 0===o||o._axes.push(e)})}}class b extends m{constructor(e){super(e,!1)}_doPrepare(e,s,t){const i=this._matrix=new Array(s);for(let e=0;e<i.length;e++){i[e]=[];for(let s=0;s<=t;s++)i[e].push(new x(e,s))}e.forEach(e=>{var s,o;const r=e.prop("position");let n=e.col;"opposite"===r?(n++,e._runPos=r):e.col<t-1&&"between"===r?(n++,e._runPos="normal"):e._runPos=r,null===(o=null===(s=i[e.row])||void 0===s?void 0:s[n])||void 0===o||o._axes.push(e)})}}class P extends t{constructor(e){super(e.chart),this.pane=e}contains(e){return e.col===this.pane.col||e.row===this.pane.row}}P.defaults=s(t.defaults,{extended:!0,radius:void 0,centerX:void 0,centerY:void 0});class v extends _{constructor(e){super(e.chart),this.pane=e}_doPrepareRender(e){super._doPrepareRender(e),this._location="body"}_getLegendSources(){return this.prop("visible")?this.chart._getSeries().getLegendSources(this.pane.row,this.pane.col):[]}}class E extends i{constructor(e,s,t){super(e),this.row=s,this.col=t}_doInit(e){this._body=this._addChild("body",new P(this)),this._legend=this._addChild("legend",new v(this))}get body(){return this._body}get legend(){return this._legend}_prepareRender(){this._body._prepareRender(),this._legend._prepareRender()}}class z extends i{constructor(e){super(e),this._cols=1,this._rows=1,this._paneDic={},this._panes=[],this._xAxes=new y(e),this._yAxes=new b(e)}get count(){return this._rows*this._cols}get rowCount(){return this._rows}get colCount(){return this._cols}get paneCount(){return this._rows*this._cols}colSizes(){return this._colSizes}rowSizes(){return this._rowSizes}getPane(e,s){return this._panes[e][s]}getRow(e){return this._panes[e]}getColumn(e){return this._panes.map(s=>s[e])}getAxisOf(e,s){var t,i;const o=this.chart,r=e.body;if(r){const n=r.pane;return s?o._getXAxes().get(e.prop("xAxis"))||this._xAxes.get(n.row,n.col)._axes[0]||(null===(t=o._getSeries().getPaneSeries(n.row,n.col)[0])||void 0===t?void 0:t._xAxisObj):o._getXAxes().get(e.prop("yAxis"))||this._yAxes.get(r.pane.row,r.pane.col)._axes[0]||(null===(i=o._getSeries().getPaneSeries(n.row,n.col)[0])||void 0===i?void 0:i._yAxisObj)}}isValidAxis(e){return e&&e.row<this._rows&&e.col<this._cols}_doLoadProp(e,s){return"panes"===e||"cols"===e||"rows"===e||super._doLoadProp(e,s)}_doUpdateProp(e,s){return"rows"!==e&&"cols"!==e&&"panes"!==e?super._doUpdateProp(e,s):s!==this._op[e]&&(this._op[e]=s,"panes"===e?this._paneDic=this.$_loadPanes(s):this.$_parsePanes(this._op.rows,this._op.cols),!0)}_doSaveProp(e,s,t){return"rows"===s||"cols"===s||"panes"===s?(e[s]=t,!0):super._doSaveProp(e,s,t)}_doSetSimple(e,s){const t=arguments.length<2?e:s;if(o(t)&&t.length>0){const e=r(1,+t[0]),s=r(1,n(+t[1],e));return e>0&&s>0&&(this.$_parsePanes(e,s),this.visible=!0),!0}return super._doSetSimple(e,t)}_load(e){return super._load(e),h(e)&&(this.$_parsePanes(e.rows,e.cols),this._paneDic=this.$_loadPanes(e.panes)),this}_doPrepareRender(e){this._panes=this.$_collectPanes(e),this._panes.forEach(e=>e.forEach(e=>e._prepareRender()))}_calcSizes(e,s){const t=e.length,i=new Array(t);let o=0;if(t>1){let r=s,n=0;for(o=0;o<t;o++){const s=e[o];a(s)?r-=i[o]=Math.max(0,Math.min(r,s)):n+=s.size}if(n>0)for(o=0;o<t;o++){const s=e[o];a(s)||(i[o]=r*s.size/n)}}else i[o]=s;return i}getXLens(e){return this._calcSizes(this._colSizes,e)}getYLens(e){return this._calcSizes(this._rowSizes,e)}measureAxes(e,s,t,i){const o=this.getXLens(t?s:e),r=this.getYLens(t?e:s);this._xAxes._buildTicks(o,i),this._yAxes._buildTicks(r,i),this.$_calcAxesPoints(o,r,i)}$_calcAxesPoints(e,s,t){this._xAxes._calcPoints(e,t),this._yAxes._calcPoints(s,t)}completeAxesPoints(e,s){this.$_calcAxesPoints(e,s,101)}getBodyAnnotation(e){for(const s in this._paneDic){const t=this._paneDic[s].body.getAnnotation(e);if(t)return t}}prepareRender(e,s){const t=this.chart.isInverted();this._prepareRender(),this._xAxes._prepare(e,this._rows,this._cols,t),this._yAxes._prepare(s,this._rows,this._cols,t)}$_parseSizes(e){let s;return s=o(e)&&e.length>0?e.slice(0):e>0?new Array(e).fill("*"):["*"],s.map(e=>{if(c(e)){const s=e.trim();return{size:"*"===s?1:n(parseFloat(s),1)}}return n(+e,1)})}$_parsePanes(e,s){this._colSizes=this.$_parseSizes(s),this._rowSizes=this.$_parseSizes(e),this._cols=this._colSizes.length,this._rows=this._rowSizes.length}$_loadPanes(e){const s=this.chart,t=this.prop("extendBody")?s._body._config:void 0,i={};if(e=o(e)?e:h(e)?[e]:null,o(e)&&e.forEach(e=>{const o=+e.row||0,r=+e.col||0;if(r>=0&&r<this._cols&&o>=0&&o<this._rows){const n=new E(s,o,r);let h=e;n.init(),!t||e&&e.body&&!1===e.body.extended||(e?(h=Object.assign({},e),e.body?!1!==e.body.extended&&(h.body=Object.assign({},t,e.body)):h.body=t):h={body:t}),n._load(h),i[o+","+r]=n}}),t)for(let e=0;e<this._rows;e++)for(let o=0;o<this._cols;o++){const r=e+","+o;if(!i[r]){const n=new E(s,e,o);n.init(),n._load({body:t}),i[r]=n}}return i}$_collectPanes(e){const s=[];for(let t=0;t<this._rows;t++){const i=[];for(let s=0;s<this._cols;s++){const o=this._paneDic[t+","+s]||new E(e,t,s)._initObject();i.push(o)}s.push(i)}return s}}z.defaults=s(i.defaults,{visible:!1,extendBody:!0,gap:0});class C extends u{constructor(){super(...arguments),this.views=[],this._gap=0}isEmpty(){return 0===this.views.length}prepare(e,s,t,i,o){const r=this.views,n=[];for(this.isX=i,o._axes.forEach(e=>{e.checkVisible()&&t.isValidAxis(e)&&n.push(e)});r.length<n.length;){const t=s.createAxisView(e);this.add(t),r.push(t)}for(;r.length>n.length;)r.pop().remove();if(r.forEach((e,s)=>{e.setModel(n[s])}),this.axes=n,this.setVis(r.length>0)){const e=r[0].model;this._gap=e.chart.getAxesGap()}}prepareGuides(e,s,t){const i=this.views,o=this.axes;i.forEach((t,i)=>{const r=o[i];s.forEach(s=>{s.forEach(s=>{s.isConnected(r)&&t.setVis(this.visible)&&(t.prepareGuides(e,s.row,s.col,s._guideContainer,s._frontGuideContainer),r._isHorz||(s._axes||(s._axes=[]),s._axes.push(r)))})})}),s.forEach(s=>{s.forEach(s=>{s._axes&&(s._gridRowContainer.addAll(e,s._axes),s._axes=[])})})}checkHeights(e,s,t){return this.views.length>0?this.$_checkHeights(this.views,e,s,t):0}$_checkHeights(e,s,t,i){let o=0;return e&&(e.forEach(e=>{o+=e.checkHeight(s,t,i)}),o+=(this.views.length-1)*this._gap),o}checkWidths(e,s,t){return this.views.length>0?this.$_checkWidths(this.views,e,s,t):0}$_checkWidths(e,s,t,i){let o=0;return e&&(e.forEach(e=>{o+=e.checkWidth(s,t,i)}),o+=(this.views.length-1)*this._gap),o}getScrollView(e){var s;for(const t of this.views)if(null===(s=t._scrollView)||void 0===s?void 0:s.contains(e))return t._scrollView}setMargins(e,s,t,i){this.views.forEach(o=>o.setMargins(e,s,t,i))}_setInverted(e){super._setInverted(e),this.isHorz=e&&!this.isX||!e&&this.isX}_doMeasure(e,s,t,i,o){const r=this.axes;if(this.isHorz){let s=0;return this.views.forEach((n,h)=>{s+=n.measure(e,r[h],t,i,o).height}),{width:t,height:s}}{let s=0;return this.views.forEach((n,h)=>{s+=n.measure(e,r[h],t,i,o).width}),{width:s,height:i}}}_doLayout(e){const s=this.views,t=this.width,i=this.height,o=s.length;let r=0,n=o-1;if(this.isHorz){let e,h,a=0;for(;r<o;r++){const e=s[r];if(e.model._posValue()<1)break;e.trans(0,a),a+=e.mh}for(e=a,a=i;n>=0;n--){const e=s[n];if(e.model._posValue()>-1)break;a-=e.mh,e.trans(0,a)}h=a;const c=h-e;let _=0;for(let e=r;e<=n;e++)_+=s[e].mh;e+=(c-_)/2;for(let t=r;t<=n;t++){const i=s[t];i.trans(0,e),e+=i.mh}s.forEach(e=>{e.resize(t,e.mh),e.model._calcPoints(t,999),e.layout()})}else{let e,h,a=0;for(;r<o;r++){const e=s[r];if(e.model._posValue()>-1)break;e.trans(a,0),a+=e.mw}for(e=a,a=t;n>=0;n--){const e=s[n];if(e.model._posValue()<1)break;a-=e.mw,e.trans(a,0)}h=a;const c=h-e;let _=0;for(let e=r;e<=n;e++)_+=s[e].mw;e+=(c-_)/2;for(let t=r;t<=n;t++){const i=s[t];i.trans(e,0),e+=i.mw}s.forEach(e=>{e.resize(e.mw,i),e.model._calcPoints(i,999),e.layout()})}}}class A extends u{constructor(e,s){super(e,"rct-axis-container"),this.isX=s,this.sections=[]}prepare(e,s,t,i,o,r){const n=this.isX?i.getRow(o):i.getColumn(o);for(;this.sections.length<n.length;){const s=new C(e);this.add(s),this.sections.push(s)}for(;this.sections.length>n.length;)this.sections.pop().remove();this.sections.forEach((i,r)=>{this.isX?(i.row=o,i.col=r):(i.col=o,i.row=r),i.prepare(e,s,t,this.isX,n[r])}),this._setInverted(r)}prepareGuides(e,s,t,i){const o=this.isX?t.getRow(i):t.getColumn(i);for(;this.sections.length<o.length;){const s=new C(e);this.add(s),this.sections.push(s)}for(;this.sections.length>o.length;)this.sections.pop().remove();this.sections.forEach((o,r)=>{this.isX?(o.row=i,o.col=r):(o.col=i,o.row=r),o.prepareGuides(e,s,t)})}checkWidths(e,s,t){return this.sections.length>0?this._isHorz?this.sections.reduce((i,o)=>i+o.checkWidths(e,s,t),0):this.sections.reduce((i,o)=>Math.max(i,o.checkWidths(e,s,t)),0):0}checkHeights(e,s,t){return this.sections.length>0?this._isHorz?this.sections.reduce((i,o)=>Math.max(i,o.checkHeights(e,s,t)),0):this.sections.reduce((i,o)=>i+o.checkHeights(e,s,t),0):0}_setInverted(e){super._setInverted(e),this._isHorz=e&&!this.isX||!e&&this.isX}_doMeasure(e,s,t,i,o){let n=0,h=0;return this._isHorz?this.sections.forEach(n=>{h=r(h,n.measure(e,s,t,i,o).height)}):this.sections.forEach(h=>{n=r(n,h.measure(e,s,t,i,o).width)}),{width:n,height:h}}_doLayout(e){this._isHorz?this.height>0&&this.sections.forEach((s,t)=>{s.resize(e[2*(t+1)]-e[2*(t+1)-1],this.height),s.trans(e[2*t+1]-e[1],0),s.layout()}):this.width>0&&this.sections.forEach((s,t)=>{s.resize(this.width,e[2*(t+1)]-e[2*(t+1)-1]),s.trans(0,this.height-(e[2*(t+1)]-e[1])),s.layout()})}layoutPanes(e,s){this.sections.forEach((t,i)=>{const[o,r]=e[i],n=r-o;this._isHorz?(t.resize(n,this.height),t.trans(o-s,0)):(t.resize(this.width,n),t.trans(0,this.height-(r-s))),t.layout()})}}class S extends g{constructor(e,s){super(e,s),this.row=0,this.col=0,this.add(this._legendView=new f(e))}getCol(){return this.col}getRow(){return this.row}getTooltipPos(){return{x:this.parent.parent.tx+this.tx,y:this.parent.parent.ty+this.ty}}prepareRender(e,s){const t=s.chart,i=s.depth.visible,o=this.row,r=this.col,n=t._split.getPane(o,r).body;this._animatable=w._animatable&&t.animatable(),this._prepareSeries(e,s,t._getSeries().getPaneSeries(o,r),i),this._prepareGauges(e,t,t._getGauges().getPaneVisibles(o,r)),this._prepareAnnotations(e,n.getAnnotations().concat(t._getAnnotations().getPaneVisibles(o,r)))}_doMeasure(e,s,t,i,o){return this._legendView.setVis(s.pane.legend.visible)&&this._legendView.measure(e,s.pane.legend,t,i,o),super._doMeasure(e,s,t,i,o)}_doLayout(){super._doLayout();const e=this._legendView;if(e.visible){this._seriesViews.forEach(s=>{if(s.needDecoreateLegend()){const t=e.legendOfSeries(s.model);t&&s.decoreateLegend(t)}});const s=e.model,t=s.prop("align"),i=s.prop("verticalAlign");let o=0,r=0,n=+s.prop("offsetX")||0;switch(t){case"right":o+=this.width-e.mw-n;break;case"center":o+=(this.width-e.mw)/2+n;break;default:o+=n}switch(n=+s.prop("offsetY")||0,i){case"bottom":r+=this.height-e.mh-n;break;case"middle":r+=(this.height-e.mh)/2+n;break;default:r+=n}e.trans(o,r).resize(e.mw,e.mh),e.layout()}}}class $ extends l{constructor(e,s){super(e,$.STYLE_NAME),this._bodies=[],this._xContainers=[],this._yContainers=[],this._owner=s}get bodies(){return this._bodies}bodyViewOf(e){return this._bodies.find(s=>s.contains(e))}axisViewOf(e){for(const s of[this._xContainers,this._yContainers])for(const t of s)for(const s of t.sections){const t=s.views.find(s=>s.model===e);if(t)return t}}prepare(e,s){s.chart,this.$_init(e),this._model=s,this.$_prepareBodies(e,s)}measure(e,s,t,i,o){const r=s.chart,n=this._inverted=s.chart.isInverted(),h=s._xAxes,a=s._yAxes,c=t,_=i;this.$_prepareAxes(e,h,!0,n),this.$_prepareAxes(e,a,!1,n),s.measureAxes(t,i,n,o),n?(t-=this._xContainers.reduce((s,o)=>s+o.checkWidths(e,t,i),0),i-=this._yContainers.reduce((s,o)=>s+o.checkHeights(e,t,i),0)):(i-=this._xContainers.reduce((s,o)=>s+o.checkHeights(e,t,i),0),t-=this._yContainers.reduce((s,o)=>s+o.checkWidths(e,t,i),0)),s.measureAxes(t,i,n,o),this._xContainers.forEach(s=>s.measure(e,r,t,i,o)),this._yContainers.forEach(s=>s.measure(e,r,t,i,o)),t=c,i=_,n?(t-=this._xContainers.reduce((e,s)=>e+s.mw,0),i-=this._yContainers.reduce((e,s)=>e+s.mh,0)):(i-=this._xContainers.reduce((e,s)=>e+s.mh,0),t-=this._yContainers.reduce((e,s)=>e+s.mw,0)),o++,s.measureAxes(t,i,n,o),this.$_prepareAxisGuides(e,h,!0),this.$_prepareAxisGuides(e,a,!1),this._xContainers.forEach(s=>{s.measure(e,r,t,i,o)}),this._yContainers.forEach(s=>{s.measure(e,r,t,i,o)});const l=s.getXLens(n?i:t),d=s.getYLens(n?t:i);s.completeAxesPoints(l,d)}layout(){const e=this._model,s=this.width,t=this.height;this._back.resize(s,t),this.$_calcExtents(e,s,t),this.$_layoutAxes(e,!0,s,t),this.$_layoutAxes(e,!1,s,t),this.$_layoutBodies(e,s,t)}seriesByDom(e){for(const s of this._bodies){const t=s.seriesByDom(e);if(t)return t}}annotationByDom(e){for(const s of this._bodies){const t=s.annotationByDom(e);if(t)return t}}getSeries(e){for(const s of this.bodies){const t=s.findSeries(e);if(t)return t}}legendByDom(e){for(const s of this.bodies){const t=s._legendView.legendByDom(e);if(t)return t}}$_init(e){this._back||(this.add(this._back=new d(e)),this._back.setStyles({fill:"none"}),this.add(this._bodyContainer=new p(e,void 0)),this.add(this._axisContainer=new p(e,void 0)))}$_prepareBodies(e,s){s.chart;const t=s.paneCount,i=s.rowCount,o=s.colCount,r=this._bodies,n=this._bodyMap=[];for(;r.length<t;){const s=new S(e,this._owner);this._bodyContainer.add(s),r.push(s)}for(;r.length>t;)r.pop().remove();for(let e=0;e<i;e++){const s=[];for(let t=0;t<o;t++){const i=r[e*o+t];s.push(i),i.row=e,i.col=t}n.push(s)}r.forEach(t=>{t.prepareRender(e,s.getPane(t.row,t.col).body),t.prepareGuideContainers(),t._gridRowContainer.prepare()})}$_prepareAxes(e,s,t,i){const o=this._model.chart,r=t?this._xContainers:this._yContainers,n=t?s.rows():s.cols();for(;r.length<n;){const s=new A(e,t);this._axisContainer.add(s),r.push(s)}for(;r.length>n;)r.pop().remove();r.forEach((t,r)=>{t.prepare(e,this._owner,o,s,r,i)})}$_prepareAxisGuides(e,s,t){(t?this._xContainers:this._yContainers).forEach((t,i)=>{t.prepareGuides(e,this._bodyMap,s,i)})}$_calc(e,s,t,i){const o=t.length,r=new Array(2*(o+1)),h=Math.max(0,n(this._model.prop("gap"),0)),a=s-e.reduce((e,s)=>e+s[i],0)-(o>1?(o-1)*h:0),c=this._model._calcSizes(t,a);let _=0,l=0;for(l=0;l<o;l++)r[2*l]=_,r[2*l+1]=_+=e[l][i],_+=c[l],l<o-1&&(_+=h);return r[2*l]=_,r[2*l+1]=_+e[l][i],{pts:r,sizes:c}}$_paneBounds(e,s){return s.map((s,t)=>[e[2*t+1],e[2*t+1]+s])}$_calcExtents(e,s,t){if(this._inverted){const i=this.$_calc(this._xContainers,s,e.rowSizes(),"mw"),o=this.$_calc(this._yContainers,t,e.colSizes(),"mh");this._rowPoints=i.pts,this._colPoints=o.pts,this._rowPaneSizes=i.sizes,this._colPaneSizes=o.sizes}else{const i=this.$_calc(this._xContainers,t,e.rowSizes(),"mh"),o=this.$_calc(this._yContainers,s,e.colSizes(),"mw");this._rowPoints=i.pts,this._colPoints=o.pts,this._rowPaneSizes=i.sizes,this._colPaneSizes=o.sizes}}$_layoutAxes(e,s,t,i){const o=this.control._padding,r=this._rowPoints,n=this._colPoints,h=s?this._xContainers:this._yContainers;if(this._inverted)if(s){const e=n[1],s=n[n.length-2]-e;h.forEach((e,t)=>{e.resize(e.mw,s),e.trans(r[2*t],i-n[n.length-2]),e.layoutPanes(this.$_paneBounds(n,this._colPaneSizes),n[1])})}else{const e=r[1],s=r[r.length-2]-e;h.forEach((t,h)=>{const a=t.sections;for(let e=0,s=a.length;e<s;e++){const t=a[e],i=0===e?o.left:0,n=e===s-1?o.right:0;let h=0,c=0;s>1&&(h=r[2*e+1]-r[2*e],c=r[2*(e+1)+1]-r[2*(e+1)],0===e?a[e+1].isEmpty()?c=r[2*(e+1)]-r[2*(e+1)-1]:c/=2:e===s-1?a[e-1].isEmpty()?h=r[2*(e-1)]-r[2*(e-1)-1]:h/=2:(a[e-1].isEmpty()?h=r[2*(e-1)]-r[2*(e-1)-1]:h/=2,a[e+1].isEmpty()?c=r[2*(e+1)]-r[2*(e+1)-1]:c/=2)),t.setMargins(i,h,c,n)}t.resize(s,t.mh),t.trans(e,i-n[2*h+1]),t.layoutPanes(this.$_paneBounds(r,this._rowPaneSizes),r[1])})}else if(s){const e=n[1];t=n[n.length-2]-e,h.forEach((s,a)=>{const c=s.sections;for(let e=0,s=c.length;e<s;e++){const t=c[e],i=0===a?o.left:0,_=a===h.length-1?o.right:0;let l=0,d=0;s>1&&(l=n[2*e+1]-n[2*e],d=n[2*(e+1)+1]-n[2*(e+1)],0===e?c[e+1].isEmpty()?d=n[2*(e+1)]-n[2*(e+1)-1]:d/=2:e===s-1?c[e-1].isEmpty()?l=n[2*(e-1)]-n[2*(e-1)-1]:l/=2:(c[e-1].isEmpty()?l=n[2*(e-1)]-n[2*(e-1)-1]:l/=2,c[e+1].isEmpty()?d=n[2*(e+1)]-r[2*(e+1)-1]:d/=2)),t.setMargins(i,l,d,_)}s.resize(t,s.mh),s.trans(e,i-r[2*a+1]),s.layoutPanes(this.$_paneBounds(n,this._colPaneSizes),n[1])})}else{const e=r[r.length-2],s=e-r[1];h.forEach((t,o)=>{t.resize(t.mw,s),t.trans(n[2*o],i-e),t.layoutPanes(this.$_paneBounds(r,this._rowPaneSizes),r[1])})}}$_layoutBodies(e,s,t){const i=e.rowCount,o=e.colCount,r=this.$_paneBounds(this._rowPoints,this._rowPaneSizes),n=this.$_paneBounds(this._colPoints,this._colPaneSizes),h=this._bodies;if(this._inverted)for(let s=0;s<i;s++){const[t,i]=r[s];for(let r=0;r<o;r++){const a=h[s*o+r],[c,_]=n[r];a.measure(this.doc,e.getPane(s,r).body,i-t,_-c,1),a.resize(i-t,_-c),a.trans(t,this.height-_),a.layout()}}else for(let s=0;s<i;s++){const[i,a]=r[s];for(let r=0;r<o;r++){const c=h[s*o+r],[_,l]=n[r];c.measure(this.doc,e.getPane(s,r).body,l-_,a-i,1),c.resize(l-_,a-i),c.trans(_,t-a),c.layout()}}}}function k(e){(function(e){return!!(e&&e.ChartObject&&e.ChartView)})(e)&&(e.ChartObject.registerSplitClass(z),e.ChartView.registerPaneClass($))}$.STYLE_NAME="rct-panes",k(e);export{z as Split,k as default,k as registerSplit};
|
package/treemap.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
/**
|
|
3
|
-
* RealChart Treemap v1.
|
|
3
|
+
* RealChart Treemap v1.5.0
|
|
4
4
|
* Copyright (C) 2023-2026 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 r=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,r.get?r:{enumerable:!0,get:function(){return e[i]}})}}),t.default=e,Object.freeze(t)}var r=i(t);class s 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 r=i.length>3?1:0;r>0&&(this.x=i[t.pickNum(e.prop("xField"),0)]),this.y=i[t.pickNum(e.prop("yField"),0+r)],this.id=t.toStr(i[t.pickNum(e.prop("idField"),1+r)]),this.group=t.toStr(i[t.pickNum(e.prop("groupField"),2+r)])}}_readObject(e,i){super._readObject(e,i),this.id=t.toStr(i[e.prop("idField")]),this.group=t.toStr(i[e.prop("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,r){this.x=e,this.y=t,this.width=i,this.height=r}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 r(e){if(e.children){let i=0;e.children.forEach((e,t)=>{r(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 s="vertical"===this.prop("startDir")||i>e,h=this._leafs=[];let o=1;return this._roots.forEach((e,t)=>{r(e)}),this._roots=this._roots.sort((e,t)=>t.value-e.value),this._roots.forEach((e,t)=>{e.index=t}),(this[this.prop("algorithm")]||this.squarify).call(this,this._roots,e,i,s),this._levels=o,{roots:this._roots,leafs:this._leafs}}needAxes(){return!1}canMixWith(e){return!1}_createPoint(e){return new s(e)}_getLabeledPoints(){return this._leafs.map(e=>e.point)}_doPrepareRender(){super._doPrepareRender(),this._roots=this.$_buildTree(this._runPoints)}$_buildTree(e){const t=[],i=[],r=this._map;e.forEach(e=>{if(e.id||!e.isNull){const s=new o(e);e.id&&(r[e.id]=s),e.group?i.push(s):t.push(s)}});for(let e=i.length-1;e>=0;e--){const s=i[e],h=r[s.point.group];(s.parent=h)?(h.children||(h.children=[]),h.children.push(s),s.children&&i.splice(e,1)):(t.push(s),i.splice(e,1))}return t}$_squarifyRow(e,i,r,s){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===r?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,_=u*h/s,1===r?(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/s,1===r?(f=n,g=_/f):(g=o,f=_/g),c.forEach(e=>{1===r?(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===r?(i.x+=g,i.width-=g):(i.y+=f,i.height-=f),s-u;if(0===e.length)return _=h*u/s,1===r?(f=n,g=_/f):(g=o,f=_/g),c.push(p),c.forEach(e=>{1===r?(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,r){const s=e.slice(0);let h=i?1:0,o=e.reduce((e,t)=>e+t.value,0);do{o=this.$_squarifyRow(s,t,h,o),r&&(h=1-h)}while(o>0);e.forEach(e=>{e.children&&this.$_squarify(e.children,e.getArea(),!i,!0)})}squarify(e,t,i,r){this.$_squarify(e,{x:0,y:0,width:t,height:i},r,!0)}strip(e,t,i,r){this.$_squarify(e,{x:0,y:0,width:t,height:i},r,!1)}$_sliceNext(e,t,i,r){if(e.x=t.x,e.y=t.y,1===i){const i=t.height*e.value/r;e.width=t.width,e.height=i,t.y+=i,t.height-=i}else{const i=t.width*e.value/r;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,r){let s=e.reduce((e,t)=>e+t.value,0),h=i?1:0;e.forEach(e=>{this.$_sliceNext(e,t,h,s),s-=e.value,r&&(h=1-h)})}slice(e,t,i,r){this.$_slice(e,{x:0,y:0,width:t,height:i},r,!1)}sliceDice(e,t,i,r){this.$_slice(e,{x:0,y:0,width:t,height:i},r,!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.PointViewPool(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 r=this.model,s=r._xAxisObj,h=r._yAxisObj,o=this._inverted;r.pointLabel;const n=this._getGrowRate(),l=this._labelViews(),a=o?e:i,d=o?i:e,{roots:u,leafs:c}=r.buildMap(d,a),p=new t.Color(r._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,r,y,g),s.prop("reversed")&&(w.x=d-w.x-w.width),h.prop("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),this._layoutLabelRotation(f))}})}$_renderGroups(e,t){}}function d(e){(function(e){return
|
|
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 r=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,r.get?r:{enumerable:!0,get:function(){return e[i]}})}}),t.default=e,Object.freeze(t)}var r=i(t);class s 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 r=i.length>3?1:0;r>0&&(this.x=i[t.pickNum(e.prop("xField"),0)]),this.y=i[t.pickNum(e.prop("yField"),0+r)],this.id=t.toStr(i[t.pickNum(e.prop("idField"),1+r)]),this.group=t.toStr(i[t.pickNum(e.prop("groupField"),2+r)])}}_readObject(e,i){super._readObject(e,i),this.id=t.toStr(i[e.prop("idField")]),this.group=t.toStr(i[e.prop("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,r){this.x=e,this.y=t,this.width=i,this.height=r}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 r(e){if(e.children){let i=0;e.children.forEach((e,t)=>{r(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 s="vertical"===this.prop("startDir")||i>e,h=this._leafs=[];let o=1;return this._roots.forEach((e,t)=>{r(e)}),this._roots=this._roots.sort((e,t)=>t.value-e.value),this._roots.forEach((e,t)=>{e.index=t}),(this[this.prop("algorithm")]||this.squarify).call(this,this._roots,e,i,s),this._levels=o,{roots:this._roots,leafs:this._leafs}}needAxes(){return!1}canMixWith(e){return!1}_createPoint(e){return new s(e)}_getLabeledPoints(){return this._leafs.map(e=>e.point)}_doPrepareRender(){super._doPrepareRender(),this._roots=this.$_buildTree(this._runPoints)}$_buildTree(e){const t=[],i=[],r=this._map;e.forEach(e=>{if(e.id||!e.isNull){const s=new o(e);e.id&&(r[e.id]=s),e.group?i.push(s):t.push(s)}});for(let e=i.length-1;e>=0;e--){const s=i[e],h=r[s.point.group];(s.parent=h)?(h.children||(h.children=[]),h.children.push(s),s.children&&i.splice(e,1)):(t.push(s),i.splice(e,1))}return t}$_squarifyRow(e,i,r,s){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===r?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,_=u*h/s,1===r?(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/s,1===r?(f=n,g=_/f):(g=o,f=_/g),c.forEach(e=>{1===r?(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===r?(i.x+=g,i.width-=g):(i.y+=f,i.height-=f),s-u;if(0===e.length)return _=h*u/s,1===r?(f=n,g=_/f):(g=o,f=_/g),c.push(p),c.forEach(e=>{1===r?(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,r){const s=e.slice(0);let h=i?1:0,o=e.reduce((e,t)=>e+t.value,0);do{o=this.$_squarifyRow(s,t,h,o),r&&(h=1-h)}while(o>0);e.forEach(e=>{e.children&&this.$_squarify(e.children,e.getArea(),!i,!0)})}squarify(e,t,i,r){this.$_squarify(e,{x:0,y:0,width:t,height:i},r,!0)}strip(e,t,i,r){this.$_squarify(e,{x:0,y:0,width:t,height:i},r,!1)}$_sliceNext(e,t,i,r){if(e.x=t.x,e.y=t.y,1===i){const i=t.height*e.value/r;e.width=t.width,e.height=i,t.y+=i,t.height-=i}else{const i=t.width*e.value/r;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,r){let s=e.reduce((e,t)=>e+t.value,0),h=i?1:0;e.forEach(e=>{this.$_sliceNext(e,t,h,s),s-=e.value,r&&(h=1-h)})}slice(e,t,i,r){this.$_slice(e,{x:0,y:0,width:t,height:i},r,!1)}sliceDice(e,t,i,r){this.$_slice(e,{x:0,y:0,width:t,height:i},r,!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.PointViewPool(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 r=this.model,s=r._xAxisObj,h=r._yAxisObj,o=this._inverted;r.pointLabel;const n=this._getGrowRate(),l=this._labelViews(),a=o?e:i,d=o?i:e,{roots:u,leafs:c}=r.buildMap(d,a),p=new t.Color(r._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,r,y,g),s.prop("reversed")&&(w.x=d-w.x-w.width),h.prop("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),this._layoutLabelRotation(f))}})}$_renderGroups(e,t){}}function d(e){(function(e){return!!(e&&e.Series&&e.SeriesView)})(e)&&(e.Series.register(n),e.SeriesView.register([n,a]))}d(r),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
|
+
* RealChart Treemap v1.5.0
|
|
4
4
|
* Copyright (C) 2023-2026 WooriTech Inc.
|
|
5
5
|
* All Rights Reserved.
|
|
6
6
|
*/
|
|
7
|
-
import{extend as
|
|
7
|
+
import*as e from"./index.mjs";import{extend as t,ChartItem as i,TreemapSeriesType as s,Series as r,maxv as h,DataPoint as o,assignObj as l,pickNum as n,toStr as a,SeriesView as d,PointViewPool as u,SeriesAnimation as c,Color as p,RectElement as g}from"./index.mjs";class _ extends o{_assignTo(e){return l(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.prop("xField"),0)]),this.y=t[n(e.prop("yField"),0+i)],this.id=a(t[n(e.prop("idField"),1+i)]),this.group=a(t[n(e.prop("groupField"),2+i)])}}_readObject(e,t){super._readObject(e,t),this.id=a(t[e.prop("idField")]),this.group=a(t[e.prop("groupField")])}}(class extends i{constructor(e){super(e.chart),this.level=e,this.floating=!0}}).defaults=t(i.defaults,{visible:!1});class f{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 w extends r{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.prop("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.prop("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 r=new f(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,t,i,s){const r=t.width*t.height,o=t.width,l=t.height;let n=t.x,a=t.y,d=Number.MAX_VALUE,u=0;const c=[];if(2===e.length){return(1===i?o>l:o>=l)?e.forEach(e=>{e.setArea(n,a,o*e.value/s,l),n+=e.width}):e.forEach(e=>{e.setArea(n,a,o,l*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?(g=f/l,_=l*p.value/u):(_=f/o,g=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?(_=l,g=f/_):(g=o,_=f/g),c.forEach(e=>{1===i?(e.setArea(n,a,g,l*e.value/u),a+=e.height):(e.setArea(n,a,o*e.value/u,_),n+=e.width)}),1===i?(t.x+=g,t.width-=g):(t.y+=_,t.height-=_),s-u;if(0===e.length)return f=r*u/s,1===i?(_=l,g=f/_):(g=o,_=f/g),c.push(p),c.forEach(e=>{1===i?(e.setArea(n,a,g,l*e.value/u),a+=e.height):(e.setArea(n,a,o*e.value/u,_),n+=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)}}w.type=s,w.defaults=t(r.defaults,{idField:"id",groupField:"group",algorithm:"squarify",alternate:!0,groupMode:!0});class x extends g{constructor(e){super(e,d.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 y extends d{constructor(e){super(e,"rct-treemap-series"),this._nodeViews=new u(this._pointContainer,x)}_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&&c.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,r=i._yAxisObj,h=this._inverted;i.pointLabel;const o=this._getGrowRate(),l=this._labelViews(),n=h?e:t,a=h?t:e,{roots:d,leafs:u}=i.buildMap(a,n),c=new p(i._calcedColor),g=[{fill:""}];let _;null==l||l.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=c;y&&(!y._color&&y.point.color?v=y._color=new p(y.point.color):y._color&&(v=y._color)),e.node=w,g[0].fill=v.brighten(w.index/d).toString(),this._setPointStyle(e,i,x,g),s.prop("reversed")&&(w.x=a-w.x-w.width),r.prop("reversed")&&(w.y=n-w.y-w.height),h&&(w.y=w.y-n),e.render(o);let $=w.x+w.width/2,b=w.y+w.height/2;if(x.xPos=h?-w.y-w.height/2:$,x.yPos=h?a-w.x-w.width/2:b,l&&(_=l.get(x,0))){_.setContrast(e.dom).layout(f);const t=_.getBBox();_.setVis(w.width>=t.height&&w.height>=t.height)&&(h?($=-w.y-w.height/2-t.width/2,b=a-w.x-(w.width+t.height)/2):($-=t.width/2,b-=t.height/2),_.trans($,b),this._layoutLabelRotation(_))}})}$_renderGroups(e,t){}}function v(e){(function(e){return!!(e&&e.Series&&e.SeriesView)})(e)&&(e.Series.register(w),e.SeriesView.register([w,y]))}v(e);export{w as TreemapSeries,v as default};
|