realchart 1.1.13 → 1.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,11 +1,46 @@
1
1
  {
2
2
  "name": "realchart",
3
- "version": "1.1.13",
3
+ "version": "1.2.4",
4
4
  "description": "Wooritech charting library",
5
- "main": "./dist/index",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
+ "exports": {
8
+ "./*.css": "./*.css",
9
+ "./dist/*.css": "./*.css",
10
+ ".": {
11
+ "require": "./index.js",
12
+ "import": "./index.mjs",
13
+ "default": "./index.mjs"
14
+ },
15
+ "./gauge": {
16
+ "require": "./gauge.js",
17
+ "import": "./gauge.mjs",
18
+ "default": "./gauge.mjs"
19
+ },
20
+ "./heatmap": {
21
+ "require": "./heatmap.js",
22
+ "import": "./heatmap.mjs",
23
+ "default": "./heatmap.mjs"
24
+ },
25
+ "./split": {
26
+ "require": "./split.js",
27
+ "import": "./split.mjs",
28
+ "default": "./split.mjs"
29
+ },
30
+ "./treemap": {
31
+ "require": "./treemap.js",
32
+ "import": "./treemap.mjs",
33
+ "default": "./treemap.mjs"
34
+ },
35
+ "./vector": {
36
+ "require": "./vector.js",
37
+ "import": "./vector.mjs",
38
+ "default": "./vector.mjs"
39
+ }
40
+ },
6
41
  "author": {
7
42
  "name": "WooriTech",
8
- "url": "",
43
+ "url": "https://www.realchart.co.kr/",
9
44
  "email": "support@realgrid.com"
10
45
  },
11
46
  "keywords": [
@@ -20,8 +55,5 @@
20
55
  "charts",
21
56
  "realreport"
22
57
  ],
23
- "files": [
24
- "dist/**/*"
25
- ],
26
58
  "license": "license.txt"
27
59
  }
@@ -721,6 +721,7 @@
721
721
  /** bar series */
722
722
  .rct-bar-series {
723
723
  fill-opacity: 1;
724
+ stroke-width: 0;
724
725
  }
725
726
 
726
727
  /** circlebar series */
package/split.d.ts ADDED
@@ -0,0 +1,114 @@
1
+ import * as RealChart from 'realchart';
2
+ import { IChart, AxisCollection, Axis, ChartItem, SplitOptions, ISplit, Annotation, PaneOptions, ChartItemOptions, Body, PaneBodyOptions, GaugeBase, Series } from 'realchart';
3
+
4
+ declare class PaneAxes {
5
+ _axes: Axis[];
6
+ }
7
+ declare abstract class PaneAxisMatrix {
8
+ chart: IChart;
9
+ isX: boolean;
10
+ protected _matrix: PaneAxes[][];
11
+ constructor(chart: IChart, isX: boolean);
12
+ rows(): number;
13
+ cols(): number;
14
+ abstract _prepare(axes: AxisCollection, rows: number, cols: number): void;
15
+ get(row: number, col: number): PaneAxes;
16
+ getRow(row: number): PaneAxes[];
17
+ getColumn(col: number): PaneAxes[];
18
+ _buildTicks(lens: number[]): void;
19
+ _calcPoints(lens: number[], phase: number): void;
20
+ }
21
+
22
+ declare class PaneBody extends Body<PaneBodyOptions> {
23
+ pane: Pane;
24
+ static defaults: PaneBodyOptions;
25
+ constructor(pane: Pane);
26
+ base(): Body;
27
+ contains(obj: GaugeBase | Series): boolean;
28
+ }
29
+ declare class Pane extends ChartItem<PaneOptions> {
30
+ row: number;
31
+ col: number;
32
+ private _body;
33
+ constructor(chart: IChart, row: number, col: number);
34
+ protected _doInitChildren(op: {
35
+ [child: string]: ChartItemOptions;
36
+ }): void;
37
+ /**
38
+ * Body 모델.
39
+ */
40
+ get body(): PaneBody;
41
+ /**
42
+ */
43
+ width: number;
44
+ /**
45
+ */
46
+ height: number;
47
+ /**
48
+ */
49
+ inverted: boolean;
50
+ _prepareRender(): void;
51
+ }
52
+ /**
53
+ * 다중 분할 panes.<br/>
54
+ * 각 pane에 해당하는 x, y축이 반드시 존재해야 한다.
55
+ * axis는 {@page config.base.axis#row row}, {@page config.base.axis#col col} 속성으로 위치를 지정한다.
56
+ * 시리즈는 {@page config.base.series#row row}, {@page config.base.series#col col} 속성으로 지정하거나, 아니면 axis 위치에 따라 자동으로 결정된다.
57
+ * // 현재 문서 구조로 SeriesGroup을 가리킬 수 없음.
58
+ * // 시리즈그룹은 {@page SeriesGroup.row row}, {@page SeriesGroup.col col} 속성으로 지정하거나, 아니면 axis 위치에 따라 자동으로 결정된다.
59
+ *
60
+ * @modules split
61
+ */
62
+ declare class Split extends ChartItem<SplitOptions> implements ISplit {
63
+ static defaults: SplitOptions;
64
+ constructor(chart: IChart);
65
+ private _cols;
66
+ private _rows;
67
+ private _widths;
68
+ private _heights;
69
+ private _panes;
70
+ _xAxes: PaneAxisMatrix;
71
+ _yAxes: PaneAxisMatrix;
72
+ _vcols: number;
73
+ _vrows: number;
74
+ private _vwidths;
75
+ private _vheights;
76
+ private _vpanes;
77
+ count(): number;
78
+ rowCount(): number;
79
+ colCount(): number;
80
+ paneCount(): number;
81
+ getPane(row: number, col: number): Pane;
82
+ getRow(row: number): Pane[];
83
+ getColumn(col: number): Pane[];
84
+ protected _doLoadProp(prop: string, value: any): boolean;
85
+ protected _doSetSimple(source: any): boolean;
86
+ _load(source: any): ChartItem;
87
+ protected _doPrepareRender(chart: IChart): void;
88
+ getXLens(length: number): number[];
89
+ getYLens(length: number): number[];
90
+ layoutAxes(width: number, height: number, inverted: boolean, phase: number): void;
91
+ private $_calcAxesPoints;
92
+ calcAxesPoints(xLens: number[], yLens: number[]): void;
93
+ /**
94
+ * body들의 표시 크기를 계산한다.
95
+ */
96
+ calcSizes(width: number, height: number): void;
97
+ getAnnotation(name: string): Annotation;
98
+ prepareRender(xAxes: AxisCollection, yAxes: AxisCollection): void;
99
+ /**
100
+ * number | (`${number}*` | '*')[] // '*'은 '1*'과 동일.
101
+ */
102
+ private $_parseSizes;
103
+ private $_parsePanes;
104
+ private $_loadPanes;
105
+ /**
106
+ * 축이 연결되지 않은 pane들은 skip한다.
107
+ */
108
+ private $_collectPanes;
109
+ private $_calcSizes;
110
+ }
111
+
112
+ declare function registerSplit(chart: typeof RealChart): void;
113
+
114
+ export { Split, registerSplit as default };
package/split.js ADDED
@@ -0,0 +1,7 @@
1
+
2
+ /**
3
+ * RealChart Split v1.2.4
4
+ * Copyright (C) 2023-2024 WooriTech Inc.
5
+ * All Rights Reserved.
6
+ */
7
+ !function(t,s){"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("realchart")):"function"==typeof define&&define.amd?define(["exports","realchart"],s):s((t="undefined"!=typeof globalThis?globalThis:t||self).RealChartSplit={},t.RealChart)}(this,(function(t,s){"use strict";function e(t){var s=Object.create(null);return t&&Object.keys(t).forEach((function(e){if("default"!==e){var i=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(s,e,i.get?i:{enumerable:!0,get:function(){return t[e]}})}})),s.default=t,Object.freeze(s)}var i=e(s);class r{constructor(){this._axes=[]}}class o{constructor(t,s){this.chart=t,this.isX=s}rows(){return this._matrix.length}cols(){return this._matrix[0].length}get(t,s){return this._matrix[t][s]}getRow(t){return this._matrix[t]}getColumn(t){return this._matrix.map((s=>s[t]))}_buildTicks(t){const s=this.isX;this._matrix.forEach(((e,i)=>{e.forEach(((e,i)=>{e._axes.forEach((e=>{e.isBased()||e._buildTicks(t[s?e.options.col:e.options.row])}))}))})),this._matrix.forEach(((e,i)=>{e.forEach(((e,i)=>{e._axes.forEach((e=>{e.isBased()&&e._buildTicks(t[s?e.options.col:e.options.row])}))}))}))}_calcPoints(t,s){const e=this.isX;this._matrix.forEach((i=>{i.forEach(((i,r)=>{i._axes.forEach((i=>{const r=e?i.options.col:i.options.row;i._calcPoints(t[r],s)}))}))}))}}class n extends o{constructor(t){super(t,!0)}_prepare(t,s,e){const i=this._matrix=new Array(s+1);for(let t=0;t<i.length;t++){i[t]=[];for(let s=0;s<e;s++)i[t].push(new r)}t.forEach((t=>{const e=t.options.position;let r=t._row;"opposite"===e?(r++,t._runPos=e):r<s-1&&"between"===e?(r++,t._runPos="normal"):t._runPos=e,i[r][t._col]._axes.push(t)}))}}class h extends o{constructor(t){super(t,!1)}_prepare(t,s,e){const i=this._matrix=new Array(s);for(let t=0;t<i.length;t++){i[t]=[];for(let s=0;s<=e;s++)i[t].push(new r)}t.forEach((t=>{const s=t.options.position;let r=t._col;"opposite"===s?(r++,t._runPos=s):t._col<e-1&&"between"===s?(r++,t._runPos="normal"):t._runPos=s,i[t._row][r]._axes.push(t)}))}}class a extends s.Body{constructor(t){super(t.chart),this.pane=t}base(){return this.chart._body}contains(t){return t.options.col===this.pane.col||t.options.row===this.pane.row}}a.defaults=s.extend(s.Body.defaults,{radius:void 0,centerX:void 0,centerY:void 0});class c extends s.ChartItem{constructor(t,s,e){super(t),this.row=s,this.col=e}_doInitChildren(t){t.body=(this._body=new a(this)).init()}get body(){return this._body}_prepareRender(){this.body._prepareRender()}}class l extends s.ChartItem{constructor(t){super(t),this._cols=1,this._rows=1,this._panes={},this._vcols=1,this._vrows=1,this._vpanes=[],this._xAxes=new n(t),this._yAxes=new h(t)}count(){return this._vrows*this._vcols}rowCount(){return this._vrows}colCount(){return this._vcols}paneCount(){return this._vrows*this._vcols}getPane(t,s){return this._vpanes[t][s]}getRow(t){return this._vpanes[t]}getColumn(t){return this._vpanes.map((s=>s[t]))}_doLoadProp(t,s){return["panes","cols","rows"].indexOf(t)>=0||super._doLoadProp(t,s)}_doSetSimple(t){if(s.isArray(t)&&t.length>0){const e=this._op;return e.rows=s.maxv(1,+t[0]),e.cols=s.maxv(1,s.pickNum(+t[1],e.rows)),e.rows>0&&e.cols>0&&(this.$_parsePanes(e.rows,e.cols),this.visible=!0),!0}return super._doSetSimple(t)}_load(t){return super._load(t),s.isObject(t)&&(this.$_parsePanes(this._op.rows=t.rows,this._op.cols=t.cols),this._panes=this.$_loadPanes(t.panes)),this}_doPrepareRender(t){this._vpanes=this.$_collectPanes(t),this._vpanes.forEach((t=>t.forEach((t=>t._prepareRender()))))}getXLens(t){return new Array(this._vcols).fill(t/this._vcols)}getYLens(t){return new Array(this._vrows).fill(t/this._vrows)}layoutAxes(t,s,e,i){const r=this.getXLens(e?s:t),o=this.getYLens(e?t:s);this._xAxes._buildTicks(r),this._yAxes._buildTicks(o),this.$_calcAxesPoints(r,o,0)}$_calcAxesPoints(t,s,e){this._xAxes._calcPoints(t,e),this._yAxes._calcPoints(s,e)}calcAxesPoints(t,s){this.$_calcAxesPoints(t,s,101)}calcSizes(t,s){this._widths=this.$_calcSizes(t,this._widths),this._heights=this.$_calcSizes(s,this._heights)}getAnnotation(t){for(const s in this._panes){const e=this._panes[s].body.getAnnotation(t);if(e)return e}}prepareRender(t,s){this._prepareRender(),this._xAxes._prepare(t,this._vrows,this._vcols),this._yAxes._prepare(s,this._vrows,this._vcols)}$_parseSizes(t){let e;return e=s.isArray(t)&&t.length>0?t.slice(0):t>0?new Array(t).fill("*"):["*"],e.map((t=>{if(s.isString(t)){const s=t.trim();return{size:"*"===s?1:parseFloat(s)}}return+t||{size:1}}))}$_parsePanes(t,s){this._widths=this.$_parseSizes(s),this._heights=this.$_parseSizes(t),this._cols=this._widths.length,this._rows=this._heights.length}$_loadPanes(t){const e={};return t=s.isArray(t)?t:s.isObject(t)?[t]:null,s.isArray(t)&&t.forEach((t=>{const s=+t.row||0,i=+t.col||0;if(i>=0&&i<this._cols&&s>=0&&s<this._rows){const r=new c(this.chart,s,i);r.init(),r._load(t),e[s+","+i]=r}})),e}$_collectPanes(t){const s=t._getXAxes()._internalItems(),e=t._getYAxes()._internalItems(),i=[],r=[],o=[];s.concat(e).forEach((t=>{const s=t.options.row||0,e=t.options.col||0;t._row=s,t._col=e,e>=0&&e<this._cols&&i.indexOf(e)<0&&i.push(e),s>=0&&s<this._rows&&r.indexOf(s)<0&&r.push(s)})),i.sort(),r.sort();for(let s=0;s<r.length;s++){const e=[];for(let r=0;r<i.length;r++){const i=this._panes[s+","+r]||new c(t,s,r)._initObject();e.push(i)}o.push(e)}return this._vrows=o.length,this._vcols=o[0].length,o}$_calcSizes(t,s){}}l.defaults=s.extend(s.ChartItem.defaults,{visible:!1,gap:0});class _ extends s.SectionView{constructor(){super(...arguments),this.views=[],this._gap=0}isEmpty(){return 0===this.views.length}prepare(t,e,i,r,o){const n=this.views,h=[];for(this.isX=e,i&&i._axes.forEach((t=>{h.push(t)}));n.length<h.length;){const e=new s.AxisView(t);this.add(e),n.push(e)}for(;n.length>h.length;)n.pop().remove();if(n.forEach(((t,s)=>{h[s]._runPos,t.model=h[s]})),this.axes=h,this.setVis(n.length>0)){const t=n[0].model;this._gap=t.chart.getAxesGap()}}prepareGuides(t,s,e){const i=this.views,r=this.axes;i.forEach(((e,i)=>{const o=r[i];s.forEach((s=>{s.forEach((s=>{s.isConnected(o)&&e.setVis(this.visible)&&e.prepareGuides(t,s.row,s.col,s._guideContainer,s._frontGuideContainer)}))}))}))}checkHeights(t,s,e){return this.views.length>0?this.$_checkHeights(this.views,t,s,e):0}$_checkHeights(t,s,e,i){let r=0;return t&&(t.forEach((t=>{r+=t.checkHeight(s,e,i)})),r+=(this.views.length-1)*this._gap),r}checkWidths(t,s,e){return this.views.length>0?this.$_checkWidths(this.views,t,s,e):0}$_checkWidths(t,s,e,i){let r=0;return t&&(t.forEach((t=>{r+=t.checkWidth(s,e,i)})),r+=(this.views.length-1)*this._gap),r}getScrollView(t){var s;for(const e of this.views)if(null===(s=e._scrollView)||void 0===s?void 0:s.contains(t))return e._scrollView}setMargins(t,s,e,i){this.views.forEach((r=>r.setMargins(t,s,e,i)))}_setInverted(t){super._setInverted(t),this.isHorz=t&&!this.isX||!t&&this.isX}_doMeasure(t,s,e,i,r){const o=this.axes;if(this.isHorz){let s=0;return this.views.forEach(((n,h)=>{s+=n.measure(t,o[h],e,i,r).height})),{width:e,height:s}}{let s=0;return this.views.forEach(((n,h)=>{s+=n.measure(t,o[h],e,i,r).width})),{width:s,height:i}}}_doLayout(t){this.isHorz?this.views.forEach((t=>{t.resize(this.width,t.mh),t.layout()})):this.views.forEach((t=>{t.resize(t.mw,this.height),t.transX(this.width-t.mw),t.layout()}))}}class u extends s.SectionView{constructor(t,s){super(t,"rct-axis-container"),this.isX=s,this.sections=[]}prepare(t,s,e,i){const r=this.isX?e.getRow(i):e.getColumn(i);for(;this.sections.length<r.length;){const s=new _(t);this.add(s),this.sections.push(s)}for(;this.sections.length>r.length;)this.sections.pop().remove();this.sections.forEach(((o,n)=>{this.isX?(o.row=i,o.col=n):(o.col=i,o.row=n),o.prepare(t,this.isX,r[n],s,e)}))}prepareGuides(t,s,e,i){const r=this.isX?e.getRow(i):e.getColumn(i);for(;this.sections.length<r.length;){const s=new _(t);this.add(s),this.sections.push(s)}for(;this.sections.length>r.length;)this.sections.pop().remove();this.sections.forEach(((r,o)=>{this.isX?(r.row=i,r.col=o):(r.col=i,r.row=o),r.prepareGuides(t,s,e)}))}checkWidths(t,s,e){return this.sections.length>0?this.sections.reduce(((i,r)=>i+r.checkWidths(t,s,e)),0):0}checkHeights(t,s,e){return this.sections.length>0?this.sections.reduce(((i,r)=>i+r.checkHeights(t,s,e)),0):0}_setInverted(t){super._setInverted(t),this._isHorz=t&&!this.isX||!t&&this.isX}_doMeasure(t,e,i,r,o){let n=0,h=0;return this._isHorz?this.sections.forEach((n=>{h=s.maxv(h,n.measure(t,e,i,r,o).height)})):this.sections.forEach((h=>{n=s.maxv(n,h.measure(t,e,i,r,o).width)})),{width:n,height:h}}_doLayout(t){this._isHorz?this.height>0&&this.sections.forEach(((s,e)=>{s.resize(t[2*(e+1)]-t[2*(e+1)-1],this.height),s.trans(t[2*e+1]-t[1],0),s.layout()})):this.width>0&&this.sections.forEach(((s,e)=>{s.resize(this.width,t[2*(e+1)]-t[2*(e+1)-1]),s.trans(0,this.height-(t[2*(e+1)]-t[1])),s.layout()}))}}class p extends s.BodyView{constructor(){super(...arguments),this.row=0,this.col=0}prepareRender(t,e){const i=this.row,r=this.col,o=e._split.getPane(i,r).body,n=e._getSeries().getPaneSeries(i,r),h=e._getGauges().getPaneVisibles(i,r);this._animatable=s.RcControl._animatable&&e.animatable(),this._prepareSeries(t,e,n),this._prepareGauges(t,e,h),this._prepareAnnotations(t,o.getAnnotations())}getTooltipPos(){return{x:this.parent.parent.tx+this.tx,y:this.parent.parent.ty+this.ty}}}class d extends s.PaneContainer{constructor(t,s){super(t,d.STYLE_NAME),this._bodies=[],this._xContainers=[],this._yContainers=[],this._owner=s}get bodies(){return this._bodies}bodyViewOf(t){return this._bodies.find((s=>s.contains(t)))}prepare(t,s){s.chart,this.$_init(t),this._model=s,this.$_prepareBodies(t,s)}measure(t,s,e,i,r){const o=s.chart,n=this._inverted=s.chart.isInverted(),h=s._xAxes,a=s._yAxes,c=e,l=i;this.$_prepareAxes(t,h,!0),this.$_prepareAxes(t,a,!1),s.layoutAxes(e,i,n,r),n?(e-=this._xContainers.reduce(((s,r)=>s+r.checkWidths(t,e,i)),0),i-=this._yContainers.reduce(((s,r)=>s+r.checkHeights(t,e,i)),0)):(i-=this._xContainers.reduce(((s,r)=>s+r.checkHeights(t,e,i)),0),e-=this._yContainers.reduce(((s,r)=>s+r.checkWidths(t,e,i)),0)),s.layoutAxes(e,i,n,r),this._xContainers.forEach((s=>s.measure(t,o,e,i,r))),this._yContainers.forEach((s=>s.measure(t,o,e,i,r))),e=c,i=l,n?(e-=this._xContainers.reduce(((t,s)=>t+s.mw),0),i-=this._yContainers.reduce(((t,s)=>t+s.mh),0)):(i-=this._xContainers.reduce(((t,s)=>t+s.mh),0),e-=this._yContainers.reduce(((t,s)=>t+s.mw),0)),s.layoutAxes(e,i,n,r),this.$_prepareAxisGuides(t,h,!0),this.$_prepareAxisGuides(t,h,!1),this._xContainers.forEach((s=>s.measure(t,o,e,i,r))),this._yContainers.forEach((s=>s.measure(t,o,e,i,r)));const _=s.getXLens(n?i:e),u=s.getYLens(n?e:i);s.calcAxesPoints(_,u)}layout(){const t=this._model,s=this.width,e=this.height;this._back.resize(s,e),this.$_calcExtents(t,s,e),this.$_layoutAxes(t,!0,s,e),this.$_layoutAxes(t,!1,s,e),this.$_layoutBodies(t,s,e)}seriesByDom(t){for(const s of this._bodies){const e=s.seriesByDom(t);if(e)return e}}getSeries(t){for(const s of this.bodies){const e=s.findSeries(t);if(e)return e}}$_init(t){this._back||(this.add(this._back=new s.RectElement(t)),this._back.setStyles({fill:"none"}),this.add(this._bodyContainer=new s.LayerElement(t,void 0)),this.add(this._axisContainer=new s.LayerElement(t,void 0)))}$_prepareBodies(t,s){const e=s.chart,i=s.paneCount(),r=this._bodies,o=this._bodyMap=[];for(;r.length<i;){const s=new p(t,this._owner);this._bodyContainer.add(s),r.push(s)}for(;r.length>i;)r.pop().remove();for(let t=0;t<s.rowCount();t++){const e=[];for(let i=0;i<s.colCount();i++){const o=r[t*s.colCount()+i];e.push(o),o.row=t,o.col=i}o.push(e)}r.forEach((s=>{s.prepareRender(t,e),s.prepareGuideContainers(),s._gridRowContainer.prepare()}))}$_prepareAxes(t,s,e){const i=e?this._xContainers:this._yContainers,r=e?s.rows():s.cols();for(;i.length<r;){const s=new u(t,e);this._axisContainer.add(s),i.push(s)}for(;i.length>r;)i.pop().remove();i.forEach(((e,i)=>{e.prepare(t,this._bodyMap,s,i)}))}$_prepareAxisGuides(t,s,e){(e?this._xContainers:this._yContainers).forEach(((e,i)=>{e.prepareGuides(t,this._bodyMap,s,i)}))}$_calc(t,s,e,i){const r=new Array(2*(s+1)),o=e-t.reduce(((t,s)=>t+s[i]),0),n=new Array(s);let h=0,a=0;for(a=0;a<s;a++)n[a]=o/s;for(a=0;a<s;a++)r[2*a]=h,r[2*a+1]=h+=t[a][i],h+=n[a];return r[2*a]=h,r[2*a+1]=h+t[a][i],r}$_calcExtents(t,s,e){this._inverted?(this._rowPoints=this.$_calc(this._xContainers,t.rowCount(),s,"mw"),this._colPoints=this.$_calc(this._yContainers,t.colCount(),e,"mh")):(this._rowPoints=this.$_calc(this._xContainers,t.rowCount(),e,"mh"),this._colPoints=this.$_calc(this._yContainers,t.colCount(),s,"mw"))}$_layoutAxes(t,s,e,i){const r=this.control._padding,o=this._rowPoints,n=this._colPoints,h=s?this._xContainers:this._yContainers;if(this._inverted)if(s){const t=n[1],s=n[n.length-2]-t;h.forEach(((t,e)=>{t.resize(t.mw,s),t.trans(o[2*e],i-n[n.length-2]),t.layout(n)}))}else{const t=o[1],s=o[o.length-2]-t;h.forEach(((e,h)=>{const a=e.sections;for(let t=0,s=a.length;t<s;t++){const e=a[t],i=0===t?r.left:0,n=t===s-1?r.right:0;let h=0,c=0;s>1&&(h=o[2*t+1]-o[2*t],c=o[2*(t+1)+1]-o[2*(t+1)],0===t?a[t+1].isEmpty()?c=o[2*(t+1)]-o[2*(t+1)-1]:c/=2:t===s-1?a[t-1].isEmpty()?h=o[2*(t-1)]-o[2*(t-1)-1]:h/=2:(a[t-1].isEmpty()?h=o[2*(t-1)]-o[2*(t-1)-1]:h/=2,a[t+1].isEmpty()?c=o[2*(t+1)]-o[2*(t+1)-1]:c/=2)),e.setMargins(i,h,c,n)}e.resize(s,e.mh),e.trans(t,i-n[2*h+1]),e.layout(o)}))}else if(s){const t=n[1];e=n[n.length-2]-t,h.forEach(((s,a)=>{const c=s.sections;for(let t=0,s=c.length;t<s;t++){const e=c[t],i=0===a?r.left:0,l=a===h.length-1?r.right:0;let _=0,u=0;s>1&&(_=n[2*t+1]-n[2*t],u=n[2*(t+1)+1]-n[2*(t+1)],0===t?c[t+1].isEmpty()?u=n[2*(t+1)]-n[2*(t+1)-1]:u/=2:t===s-1?c[t-1].isEmpty()?_=n[2*(t-1)]-n[2*(t-1)-1]:_/=2:(c[t-1].isEmpty()?_=n[2*(t-1)]-n[2*(t-1)-1]:_/=2,c[t+1].isEmpty()?u=n[2*(t+1)]-o[2*(t+1)-1]:u/=2)),e.setMargins(i,_,u,l)}s.resize(e,s.mh),s.trans(t,i-o[2*a+1]),s.layout(n)}))}else{const t=o[o.length-2],s=t-o[1];h.forEach(((e,r)=>{e.resize(e.mw,s),e.trans(n[2*r],i-t),e.layout(o)}))}}$_layoutBodies(t,s,e){t.chart._body;const i=t.rowCount(),r=t.colCount(),o=this._rowPoints,n=this._colPoints,h=this._bodies;if(this._inverted)for(let s=0;s<i;s++){const e=o[2*(s+1)-1],i=o[2*(s+1)];for(let o=0;o<r;o++){const a=h[s*r+o],c=n[2*o+1],l=n[2*(o+1)];a.measure(this.doc,t.getPane(s,o).body,i-e,l-c,1),a.resize(i-e,l-c),a.trans(e,this.height-l),a.layout()}}else for(let s=0;s<i;s++){const i=o[2*(s+1)-1],a=o[2*(s+1)];for(let o=0;o<r;o++){const c=h[s*r+o],l=n[2*(o+1)-1],_=n[2*(o+1)];c.measure(this.doc,t.getPane(s,o).body,_-l,a-i,1),c.resize(_-l,a-i),c.trans(l,e-a),c.layout()}}}}function f(t){(function(t){return t.Series&&t.SeriesView})(t)&&(t.ChartObject.registerSplitClass(l),t.ChartView.registerPaneClass(d))}d.STYLE_NAME="rct-panes",f(i),t.Split=l,t.default=f,Object.defineProperty(t,"__esModule",{value:!0})}));
package/split.mjs ADDED
@@ -0,0 +1,7 @@
1
+
2
+ /**
3
+ * RealChart Split v1.2.4
4
+ * Copyright (C) 2023-2024 WooriTech Inc.
5
+ * All Rights Reserved.
6
+ */
7
+ import{extend as s,Body as t,ChartItem as e,isArray as i,maxv as o,pickNum as r,isObject as n,isString as h,PaneContainer as a,RectElement as c,LayerElement as _,SectionView as l,BodyView as p,RcControl as u,AxisView as d}from"./index.mjs";class w{constructor(){this._axes=[]}}class g{constructor(s,t){this.chart=s,this.isX=t}rows(){return this._matrix.length}cols(){return this._matrix[0].length}get(s,t){return this._matrix[s][t]}getRow(s){return this._matrix[s]}getColumn(s){return this._matrix.map((t=>t[s]))}_buildTicks(s){const t=this.isX;this._matrix.forEach(((e,i)=>{e.forEach(((e,i)=>{e._axes.forEach((e=>{e.isBased()||e._buildTicks(s[t?e.options.col:e.options.row])}))}))})),this._matrix.forEach(((e,i)=>{e.forEach(((e,i)=>{e._axes.forEach((e=>{e.isBased()&&e._buildTicks(s[t?e.options.col:e.options.row])}))}))}))}_calcPoints(s,t){const e=this.isX;this._matrix.forEach((i=>{i.forEach(((i,o)=>{i._axes.forEach((i=>{const o=e?i.options.col:i.options.row;i._calcPoints(s[o],t)}))}))}))}}class f extends g{constructor(s){super(s,!0)}_prepare(s,t,e){const i=this._matrix=new Array(t+1);for(let s=0;s<i.length;s++){i[s]=[];for(let t=0;t<e;t++)i[s].push(new w)}s.forEach((s=>{const e=s.options.position;let o=s._row;"opposite"===e?(o++,s._runPos=e):o<t-1&&"between"===e?(o++,s._runPos="normal"):s._runPos=e,i[o][s._col]._axes.push(s)}))}}class x extends g{constructor(s){super(s,!1)}_prepare(s,t,e){const i=this._matrix=new Array(t);for(let s=0;s<i.length;s++){i[s]=[];for(let t=0;t<=e;t++)i[s].push(new w)}s.forEach((s=>{const t=s.options.position;let o=s._col;"opposite"===t?(o++,s._runPos=t):s._col<e-1&&"between"===t?(o++,s._runPos="normal"):s._runPos=t,i[s._row][o]._axes.push(s)}))}}class y extends t{constructor(s){super(s.chart),this.pane=s}base(){return this.chart._body}contains(s){return s.options.col===this.pane.col||s.options.row===this.pane.row}}y.defaults=s(t.defaults,{radius:void 0,centerX:void 0,centerY:void 0});class m extends e{constructor(s,t,e){super(s),this.row=t,this.col=e}_doInitChildren(s){s.body=(this._body=new y(this)).init()}get body(){return this._body}_prepareRender(){this.body._prepareRender()}}class v extends e{constructor(s){super(s),this._cols=1,this._rows=1,this._panes={},this._vcols=1,this._vrows=1,this._vpanes=[],this._xAxes=new f(s),this._yAxes=new x(s)}count(){return this._vrows*this._vcols}rowCount(){return this._vrows}colCount(){return this._vcols}paneCount(){return this._vrows*this._vcols}getPane(s,t){return this._vpanes[s][t]}getRow(s){return this._vpanes[s]}getColumn(s){return this._vpanes.map((t=>t[s]))}_doLoadProp(s,t){return["panes","cols","rows"].indexOf(s)>=0||super._doLoadProp(s,t)}_doSetSimple(s){if(i(s)&&s.length>0){const t=this._op;return t.rows=o(1,+s[0]),t.cols=o(1,r(+s[1],t.rows)),t.rows>0&&t.cols>0&&(this.$_parsePanes(t.rows,t.cols),this.visible=!0),!0}return super._doSetSimple(s)}_load(s){return super._load(s),n(s)&&(this.$_parsePanes(this._op.rows=s.rows,this._op.cols=s.cols),this._panes=this.$_loadPanes(s.panes)),this}_doPrepareRender(s){this._vpanes=this.$_collectPanes(s),this._vpanes.forEach((s=>s.forEach((s=>s._prepareRender()))))}getXLens(s){return new Array(this._vcols).fill(s/this._vcols)}getYLens(s){return new Array(this._vrows).fill(s/this._vrows)}layoutAxes(s,t,e,i){const o=this.getXLens(e?t:s),r=this.getYLens(e?s:t);this._xAxes._buildTicks(o),this._yAxes._buildTicks(r),this.$_calcAxesPoints(o,r,0)}$_calcAxesPoints(s,t,e){this._xAxes._calcPoints(s,e),this._yAxes._calcPoints(t,e)}calcAxesPoints(s,t){this.$_calcAxesPoints(s,t,101)}calcSizes(s,t){this._widths=this.$_calcSizes(s,this._widths),this._heights=this.$_calcSizes(t,this._heights)}getAnnotation(s){for(const t in this._panes){const e=this._panes[t].body.getAnnotation(s);if(e)return e}}prepareRender(s,t){this._prepareRender(),this._xAxes._prepare(s,this._vrows,this._vcols),this._yAxes._prepare(t,this._vrows,this._vcols)}$_parseSizes(s){let t;return t=i(s)&&s.length>0?s.slice(0):s>0?new Array(s).fill("*"):["*"],t.map((s=>{if(h(s)){const t=s.trim();return{size:"*"===t?1:parseFloat(t)}}return+s||{size:1}}))}$_parsePanes(s,t){this._widths=this.$_parseSizes(t),this._heights=this.$_parseSizes(s),this._cols=this._widths.length,this._rows=this._heights.length}$_loadPanes(s){const t={};return s=i(s)?s:n(s)?[s]:null,i(s)&&s.forEach((s=>{const e=+s.row||0,i=+s.col||0;if(i>=0&&i<this._cols&&e>=0&&e<this._rows){const o=new m(this.chart,e,i);o.init(),o._load(s),t[e+","+i]=o}})),t}$_collectPanes(s){const t=s._getXAxes()._internalItems(),e=s._getYAxes()._internalItems(),i=[],o=[],r=[];t.concat(e).forEach((s=>{const t=s.options.row||0,e=s.options.col||0;s._row=t,s._col=e,e>=0&&e<this._cols&&i.indexOf(e)<0&&i.push(e),t>=0&&t<this._rows&&o.indexOf(t)<0&&o.push(t)})),i.sort(),o.sort();for(let t=0;t<o.length;t++){const e=[];for(let o=0;o<i.length;o++){const i=this._panes[t+","+o]||new m(s,t,o)._initObject();e.push(i)}r.push(e)}return this._vrows=r.length,this._vcols=r[0].length,r}$_calcSizes(s,t){}}v.defaults=s(e.defaults,{visible:!1,gap:0});class E extends l{constructor(){super(...arguments),this.views=[],this._gap=0}isEmpty(){return 0===this.views.length}prepare(s,t,e,i,o){const r=this.views,n=[];for(this.isX=t,e&&e._axes.forEach((s=>{n.push(s)}));r.length<n.length;){const t=new d(s);this.add(t),r.push(t)}for(;r.length>n.length;)r.pop().remove();if(r.forEach(((s,t)=>{n[t]._runPos,s.model=n[t]})),this.axes=n,this.setVis(r.length>0)){const s=r[0].model;this._gap=s.chart.getAxesGap()}}prepareGuides(s,t,e){const i=this.views,o=this.axes;i.forEach(((e,i)=>{const r=o[i];t.forEach((t=>{t.forEach((t=>{t.isConnected(r)&&e.setVis(this.visible)&&e.prepareGuides(s,t.row,t.col,t._guideContainer,t._frontGuideContainer)}))}))}))}checkHeights(s,t,e){return this.views.length>0?this.$_checkHeights(this.views,s,t,e):0}$_checkHeights(s,t,e,i){let o=0;return s&&(s.forEach((s=>{o+=s.checkHeight(t,e,i)})),o+=(this.views.length-1)*this._gap),o}checkWidths(s,t,e){return this.views.length>0?this.$_checkWidths(this.views,s,t,e):0}$_checkWidths(s,t,e,i){let o=0;return s&&(s.forEach((s=>{o+=s.checkWidth(t,e,i)})),o+=(this.views.length-1)*this._gap),o}getScrollView(s){var t;for(const e of this.views)if(null===(t=e._scrollView)||void 0===t?void 0:t.contains(s))return e._scrollView}setMargins(s,t,e,i){this.views.forEach((o=>o.setMargins(s,t,e,i)))}_setInverted(s){super._setInverted(s),this.isHorz=s&&!this.isX||!s&&this.isX}_doMeasure(s,t,e,i,o){const r=this.axes;if(this.isHorz){let t=0;return this.views.forEach(((n,h)=>{t+=n.measure(s,r[h],e,i,o).height})),{width:e,height:t}}{let t=0;return this.views.forEach(((n,h)=>{t+=n.measure(s,r[h],e,i,o).width})),{width:t,height:i}}}_doLayout(s){this.isHorz?this.views.forEach((s=>{s.resize(this.width,s.mh),s.layout()})):this.views.forEach((s=>{s.resize(s.mw,this.height),s.transX(this.width-s.mw),s.layout()}))}}class C extends l{constructor(s,t){super(s,"rct-axis-container"),this.isX=t,this.sections=[]}prepare(s,t,e,i){const o=this.isX?e.getRow(i):e.getColumn(i);for(;this.sections.length<o.length;){const t=new E(s);this.add(t),this.sections.push(t)}for(;this.sections.length>o.length;)this.sections.pop().remove();this.sections.forEach(((r,n)=>{this.isX?(r.row=i,r.col=n):(r.col=i,r.row=n),r.prepare(s,this.isX,o[n],t,e)}))}prepareGuides(s,t,e,i){const o=this.isX?e.getRow(i):e.getColumn(i);for(;this.sections.length<o.length;){const t=new E(s);this.add(t),this.sections.push(t)}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(s,t,e)}))}checkWidths(s,t,e){return this.sections.length>0?this.sections.reduce(((i,o)=>i+o.checkWidths(s,t,e)),0):0}checkHeights(s,t,e){return this.sections.length>0?this.sections.reduce(((i,o)=>i+o.checkHeights(s,t,e)),0):0}_setInverted(s){super._setInverted(s),this._isHorz=s&&!this.isX||!s&&this.isX}_doMeasure(s,t,e,i,r){let n=0,h=0;return this._isHorz?this.sections.forEach((n=>{h=o(h,n.measure(s,t,e,i,r).height)})):this.sections.forEach((h=>{n=o(n,h.measure(s,t,e,i,r).width)})),{width:n,height:h}}_doLayout(s){this._isHorz?this.height>0&&this.sections.forEach(((t,e)=>{t.resize(s[2*(e+1)]-s[2*(e+1)-1],this.height),t.trans(s[2*e+1]-s[1],0),t.layout()})):this.width>0&&this.sections.forEach(((t,e)=>{t.resize(this.width,s[2*(e+1)]-s[2*(e+1)-1]),t.trans(0,this.height-(s[2*(e+1)]-s[1])),t.layout()}))}}class b extends p{constructor(){super(...arguments),this.row=0,this.col=0}prepareRender(s,t){const e=this.row,i=this.col,o=t._split.getPane(e,i).body,r=t._getSeries().getPaneSeries(e,i),n=t._getGauges().getPaneVisibles(e,i);this._animatable=u._animatable&&t.animatable(),this._prepareSeries(s,t,r),this._prepareGauges(s,t,n),this._prepareAnnotations(s,o.getAnnotations())}getTooltipPos(){return{x:this.parent.parent.tx+this.tx,y:this.parent.parent.ty+this.ty}}}class A extends a{constructor(s,t){super(s,A.STYLE_NAME),this._bodies=[],this._xContainers=[],this._yContainers=[],this._owner=t}get bodies(){return this._bodies}bodyViewOf(s){return this._bodies.find((t=>t.contains(s)))}prepare(s,t){t.chart,this.$_init(s),this._model=t,this.$_prepareBodies(s,t)}measure(s,t,e,i,o){const r=t.chart,n=this._inverted=t.chart.isInverted(),h=t._xAxes,a=t._yAxes,c=e,_=i;this.$_prepareAxes(s,h,!0),this.$_prepareAxes(s,a,!1),t.layoutAxes(e,i,n,o),n?(e-=this._xContainers.reduce(((t,o)=>t+o.checkWidths(s,e,i)),0),i-=this._yContainers.reduce(((t,o)=>t+o.checkHeights(s,e,i)),0)):(i-=this._xContainers.reduce(((t,o)=>t+o.checkHeights(s,e,i)),0),e-=this._yContainers.reduce(((t,o)=>t+o.checkWidths(s,e,i)),0)),t.layoutAxes(e,i,n,o),this._xContainers.forEach((t=>t.measure(s,r,e,i,o))),this._yContainers.forEach((t=>t.measure(s,r,e,i,o))),e=c,i=_,n?(e-=this._xContainers.reduce(((s,t)=>s+t.mw),0),i-=this._yContainers.reduce(((s,t)=>s+t.mh),0)):(i-=this._xContainers.reduce(((s,t)=>s+t.mh),0),e-=this._yContainers.reduce(((s,t)=>s+t.mw),0)),t.layoutAxes(e,i,n,o),this.$_prepareAxisGuides(s,h,!0),this.$_prepareAxisGuides(s,h,!1),this._xContainers.forEach((t=>t.measure(s,r,e,i,o))),this._yContainers.forEach((t=>t.measure(s,r,e,i,o)));const l=t.getXLens(n?i:e),p=t.getYLens(n?e:i);t.calcAxesPoints(l,p)}layout(){const s=this._model,t=this.width,e=this.height;this._back.resize(t,e),this.$_calcExtents(s,t,e),this.$_layoutAxes(s,!0,t,e),this.$_layoutAxes(s,!1,t,e),this.$_layoutBodies(s,t,e)}seriesByDom(s){for(const t of this._bodies){const e=t.seriesByDom(s);if(e)return e}}getSeries(s){for(const t of this.bodies){const e=t.findSeries(s);if(e)return e}}$_init(s){this._back||(this.add(this._back=new c(s)),this._back.setStyles({fill:"none"}),this.add(this._bodyContainer=new _(s,void 0)),this.add(this._axisContainer=new _(s,void 0)))}$_prepareBodies(s,t){const e=t.chart,i=t.paneCount(),o=this._bodies,r=this._bodyMap=[];for(;o.length<i;){const t=new b(s,this._owner);this._bodyContainer.add(t),o.push(t)}for(;o.length>i;)o.pop().remove();for(let s=0;s<t.rowCount();s++){const e=[];for(let i=0;i<t.colCount();i++){const r=o[s*t.colCount()+i];e.push(r),r.row=s,r.col=i}r.push(e)}o.forEach((t=>{t.prepareRender(s,e),t.prepareGuideContainers(),t._gridRowContainer.prepare()}))}$_prepareAxes(s,t,e){const i=e?this._xContainers:this._yContainers,o=e?t.rows():t.cols();for(;i.length<o;){const t=new C(s,e);this._axisContainer.add(t),i.push(t)}for(;i.length>o;)i.pop().remove();i.forEach(((e,i)=>{e.prepare(s,this._bodyMap,t,i)}))}$_prepareAxisGuides(s,t,e){(e?this._xContainers:this._yContainers).forEach(((e,i)=>{e.prepareGuides(s,this._bodyMap,t,i)}))}$_calc(s,t,e,i){const o=new Array(2*(t+1)),r=e-s.reduce(((s,t)=>s+t[i]),0),n=new Array(t);let h=0,a=0;for(a=0;a<t;a++)n[a]=r/t;for(a=0;a<t;a++)o[2*a]=h,o[2*a+1]=h+=s[a][i],h+=n[a];return o[2*a]=h,o[2*a+1]=h+s[a][i],o}$_calcExtents(s,t,e){this._inverted?(this._rowPoints=this.$_calc(this._xContainers,s.rowCount(),t,"mw"),this._colPoints=this.$_calc(this._yContainers,s.colCount(),e,"mh")):(this._rowPoints=this.$_calc(this._xContainers,s.rowCount(),e,"mh"),this._colPoints=this.$_calc(this._yContainers,s.colCount(),t,"mw"))}$_layoutAxes(s,t,e,i){const o=this.control._padding,r=this._rowPoints,n=this._colPoints,h=t?this._xContainers:this._yContainers;if(this._inverted)if(t){const s=n[1],t=n[n.length-2]-s;h.forEach(((s,e)=>{s.resize(s.mw,t),s.trans(r[2*e],i-n[n.length-2]),s.layout(n)}))}else{const s=r[1],t=r[r.length-2]-s;h.forEach(((e,h)=>{const a=e.sections;for(let s=0,t=a.length;s<t;s++){const e=a[s],i=0===s?o.left:0,n=s===t-1?o.right:0;let h=0,c=0;t>1&&(h=r[2*s+1]-r[2*s],c=r[2*(s+1)+1]-r[2*(s+1)],0===s?a[s+1].isEmpty()?c=r[2*(s+1)]-r[2*(s+1)-1]:c/=2:s===t-1?a[s-1].isEmpty()?h=r[2*(s-1)]-r[2*(s-1)-1]:h/=2:(a[s-1].isEmpty()?h=r[2*(s-1)]-r[2*(s-1)-1]:h/=2,a[s+1].isEmpty()?c=r[2*(s+1)]-r[2*(s+1)-1]:c/=2)),e.setMargins(i,h,c,n)}e.resize(t,e.mh),e.trans(s,i-n[2*h+1]),e.layout(r)}))}else if(t){const s=n[1];e=n[n.length-2]-s,h.forEach(((t,a)=>{const c=t.sections;for(let s=0,t=c.length;s<t;s++){const e=c[s],i=0===a?o.left:0,_=a===h.length-1?o.right:0;let l=0,p=0;t>1&&(l=n[2*s+1]-n[2*s],p=n[2*(s+1)+1]-n[2*(s+1)],0===s?c[s+1].isEmpty()?p=n[2*(s+1)]-n[2*(s+1)-1]:p/=2:s===t-1?c[s-1].isEmpty()?l=n[2*(s-1)]-n[2*(s-1)-1]:l/=2:(c[s-1].isEmpty()?l=n[2*(s-1)]-n[2*(s-1)-1]:l/=2,c[s+1].isEmpty()?p=n[2*(s+1)]-r[2*(s+1)-1]:p/=2)),e.setMargins(i,l,p,_)}t.resize(e,t.mh),t.trans(s,i-r[2*a+1]),t.layout(n)}))}else{const s=r[r.length-2],t=s-r[1];h.forEach(((e,o)=>{e.resize(e.mw,t),e.trans(n[2*o],i-s),e.layout(r)}))}}$_layoutBodies(s,t,e){s.chart._body;const i=s.rowCount(),o=s.colCount(),r=this._rowPoints,n=this._colPoints,h=this._bodies;if(this._inverted)for(let t=0;t<i;t++){const e=r[2*(t+1)-1],i=r[2*(t+1)];for(let r=0;r<o;r++){const a=h[t*o+r],c=n[2*r+1],_=n[2*(r+1)];a.measure(this.doc,s.getPane(t,r).body,i-e,_-c,1),a.resize(i-e,_-c),a.trans(e,this.height-_),a.layout()}}else for(let t=0;t<i;t++){const i=r[2*(t+1)-1],a=r[2*(t+1)];for(let r=0;r<o;r++){const c=h[t*o+r],_=n[2*(r+1)-1],l=n[2*(r+1)];c.measure(this.doc,s.getPane(t,r).body,l-_,a-i,1),c.resize(l-_,a-i),c.trans(_,e-a),c.layout()}}}}function P(s){(function(s){return s.Series&&s.SeriesView})(s)&&(s.ChartObject.registerSplitClass(v),s.ChartView.registerPaneClass(A))}A.STYLE_NAME="rct-panes";export{v as Split,P as default,P as registerSplit};
package/treemap.d.ts ADDED
@@ -0,0 +1,82 @@
1
+ import * as RealChart from 'realchart';
2
+ import { Series, TreemapSeriesOptions, IPlottingItem, DataPoint, Color } from 'realchart';
3
+
4
+ /**
5
+ * [y, id, group]
6
+ * [x, y, id, group]
7
+ */
8
+ declare class TreemapSeriesPoint extends DataPoint {
9
+ id: string;
10
+ group: string;
11
+ protected _assignTo(proxy: any): any;
12
+ protected _readArray(series: TreemapSeries, v: any[]): void;
13
+ protected _readObject(series: TreemapSeries, v: any): void;
14
+ }
15
+ interface IArea {
16
+ x: number;
17
+ y: number;
18
+ width: number;
19
+ height: number;
20
+ }
21
+ declare class TreeNode {
22
+ point: TreemapSeriesPoint;
23
+ parent: TreeNode;
24
+ expaned: boolean;
25
+ children: TreeNode[];
26
+ index: number;
27
+ value: number;
28
+ x: number;
29
+ y: number;
30
+ width: number;
31
+ height: number;
32
+ _color: Color;
33
+ constructor(point: TreemapSeriesPoint);
34
+ level(): number;
35
+ getArea(): IArea;
36
+ setArea(x: number, y: number, w: number, h: number): void;
37
+ getTotal(): number;
38
+ }
39
+ /**
40
+ * Treemap 시리즈.<br/>
41
+ * {@page op.SeriesOptions#type}은 {@page config.series.treemap 'treemap'}이고,
42
+ * {@page options 설정} 모델은 {@page op.TreemapSeriesOptions}이다.
43
+ *
44
+ * @modules treemap
45
+ */
46
+ declare class TreemapSeries extends Series<TreemapSeriesOptions> {
47
+ static readonly type = "treemap";
48
+ static defaults: TreemapSeriesOptions;
49
+ _roots: TreeNode[];
50
+ _leafs: TreeNode[];
51
+ private _map;
52
+ private _levels;
53
+ /**
54
+ * group mode일 때 group 레벨별 표시 방식 지정.
55
+ * TODO: 구현할 것!
56
+ */
57
+ /**
58
+ * @internal
59
+ */
60
+ buildMap(width: number, height: number): {
61
+ roots: TreeNode[];
62
+ leafs: TreeNode[];
63
+ };
64
+ needAxes(): boolean;
65
+ canMixWith(other: IPlottingItem): boolean;
66
+ protected _createPoint(source: any): DataPoint;
67
+ _getLabeledPoints(): DataPoint[];
68
+ protected _doPrepareRender(): void;
69
+ private $_buildTree;
70
+ private $_squarifyRow;
71
+ private $_squarify;
72
+ private squarify;
73
+ private strip;
74
+ private $_sliceNext;
75
+ private $_slice;
76
+ private slice;
77
+ private sliceDice;
78
+ }
79
+
80
+ declare function registerSeries(chart: typeof RealChart): void;
81
+
82
+ export { TreemapSeries, registerSeries as default };
package/treemap.js ADDED
@@ -0,0 +1,7 @@
1
+
2
+ /**
3
+ * RealChart Treemap v1.2.4
4
+ * Copyright (C) 2023-2024 WooriTech Inc.
5
+ * All Rights Reserved.
6
+ */
7
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("realchart")):"function"==typeof define&&define.amd?define(["exports","realchart"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).RealChartTreemap={},e.RealChart)}(this,(function(e,t){"use strict";function i(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(i){if("default"!==i){var s=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,s.get?s:{enumerable:!0,get:function(){return e[i]}})}})),t.default=e,Object.freeze(t)}var s=i(t);class r extends t.DataPoint{_assignTo(e){return t.assignObj(super._assignTo(e),{id:this.id,group:this.group})}_readArray(e,i){if(i.length<=2)this.isNull=!0;else{const s=i.length>3?1:0;s>0&&(this.x=i[t.pickNum(e.options.xField,0)]),this.y=i[t.pickNum(e.options.yField,0+s)],this.id=t.toStr(i[t.pickNum(e.options.idField,1+s)]),this.group=t.toStr(i[t.pickNum(e.options.groupField,2+s)])}}_readObject(e,i){super._readObject(e,i),this.id=t.toStr(i[e.options.idField]),this.group=t.toStr(i[e.options.groupField])}}class h extends t.ChartItem{constructor(e){super(e.chart),this.level=e,this.floating=!0}}h.defaults=t.extend(t.ChartItem.defaults,{visible:!1});class o{constructor(e){this.point=e}level(){return this.parent?this.parent.level()+1:0}getArea(){return{x:this.x,y:this.y,width:this.width,height:this.height}}setArea(e,t,i,s){this.x=e,this.y=t,this.width=i,this.height=s}getTotal(){return this.children.reduce(((e,t)=>e+t.value),0)}}class n extends t.Series{constructor(){super(...arguments),this._map={},this._levels=1}buildMap(e,i){function s(e){if(e.children){let i=0;e.children.forEach(((e,t)=>{s(e),i+=e.value})),e.value=i,e.children=e.children.sort(((e,t)=>t.value-e.value)),e.children.forEach(((e,t)=>{e.index=t})),o=t.maxv(o,e.level()+1+1)}else h.push(e),e.value=e.point?e.point.yValue:0}const r="vertical"===this._op.startDir||i>e,h=this._leafs=[];let o=1;return this._roots.forEach(((e,t)=>{s(e)})),this._roots=this._roots.sort(((e,t)=>t.value-e.value)),this._roots.forEach(((e,t)=>{e.index=t})),(this[this._op.algorithm]||this.squarify).call(this,this._roots,e,i,r),this._levels=o,{roots:this._roots,leafs:this._leafs}}needAxes(){return!1}canMixWith(e){return!1}_createPoint(e){return new r(e)}_getLabeledPoints(){return this._leafs.map((e=>e.point))}_doPrepareRender(){super._doPrepareRender(),this._roots=this.$_buildTree(this._runPoints)}$_buildTree(e){const t=[],i=[],s=this._map;e.forEach((e=>{if(e.id||!e.isNull){const r=new o(e);e.id&&(s[e.id]=r),e.group?i.push(r):t.push(r)}}));for(let e=i.length-1;e>=0;e--){const r=i[e],h=s[r.point.group];(r.parent=h)?(h.children||(h.children=[]),h.children.push(r),r.children&&i.splice(e,1)):(t.push(r),i.splice(e,1))}return t}$_squarifyRow(e,i,s,r){const h=i.width*i.height,o=i.width,n=i.height;let l=i.x,a=i.y,d=Number.MAX_VALUE,u=0;const c=[];if(2===e.length){return(1===s?o>n:o>=n)?e.forEach((e=>{e.setArea(l,a,o*e.value/r,n),l+=e.width})):e.forEach((e=>{e.setArea(l,a,o,n*e.value/r),a+=e.height})),0}for(;e.length>0;){let p,g,f,_,w;if(p=e.shift(),u+=p.value,_=u*h/r,1===s?(g=_/n,f=n*p.value/u):(f=_/o,g=o*p.value/u),w=t.maxv(g/f,f/g),e.length>0&&w>d)return e.unshift(p),u-=p.value,_=h*u/r,1===s?(f=n,g=_/f):(g=o,f=_/g),c.forEach((e=>{1===s?(e.setArea(l,a,g,n*e.value/u),a+=e.height):(e.setArea(l,a,o*e.value/u,f),l+=e.width)})),1===s?(i.x+=g,i.width-=g):(i.y+=f,i.height-=f),r-u;if(0===e.length)return _=h*u/r,1===s?(f=n,g=_/f):(g=o,f=_/g),c.push(p),c.forEach((e=>{1===s?(e.setArea(l,a,g,n*e.value/u),a+=e.height):(e.setArea(l,a,o*e.value/u,f),l+=e.width)})),0;d=w,c.push(p)}}$_squarify(e,t,i,s){const r=e.slice(0);let h=i?1:0,o=e.reduce(((e,t)=>e+t.value),0);do{o=this.$_squarifyRow(r,t,h,o),s&&(h=1-h)}while(o>0);e.forEach((e=>{e.children&&this.$_squarify(e.children,e.getArea(),!i,!0)}))}squarify(e,t,i,s){this.$_squarify(e,{x:0,y:0,width:t,height:i},s,!0)}strip(e,t,i,s){this.$_squarify(e,{x:0,y:0,width:t,height:i},s,!1)}$_sliceNext(e,t,i,s){if(e.x=t.x,e.y=t.y,1===i){const i=t.height*e.value/s;e.width=t.width,e.height=i,t.y+=i,t.height-=i}else{const i=t.width*e.value/s;e.height=t.height,e.width=i,t.x+=i,t.width-=i}e.children&&this.$_slice(e.children,e.getArea(),0===i,!0)}$_slice(e,t,i,s){let r=e.reduce(((e,t)=>e+t.value),0),h=i?1:0;e.forEach((e=>{this.$_sliceNext(e,t,h,r),r-=e.value,s&&(h=1-h)}))}slice(e,t,i,s){this.$_slice(e,{x:0,y:0,width:t,height:i},s,!1)}sliceDice(e,t,i,s){this.$_slice(e,{x:0,y:0,width:t,height:i},s,!0)}}n.type=t.TreemapSeriesType,n.defaults=t.extend(t.ChartItem.defaults,{idField:"id",groupField:"group",algorithm:"squarify",alternate:!0,groupMode:!0});class l extends t.RectElement{constructor(e){super(e,t.SeriesView.POINT_CLASS)}get point(){return this.node.point}render(e){if(1!==e){const t=Object.assign({},this.node);t.width*=e,t.height*=e,t.x+=(this.node.width-t.width)/2,t.y+=(this.node.height-t.height)/2,this.setRect(t)}else this.setRect(this.node)}}class a extends t.SeriesView{constructor(e){super(e,"rct-treemap-series"),this._nodeViews=new t.ElementPool(this._pointContainer,l)}_lazyPrepareLabels(){return!0}_getPointPool(){return this._nodeViews}_prepareSeries(e,t){}_renderSeries(e,t){this._pointContainer.invert(this._inverted,t),this._rootView?this.$_renderGroups(e,t):this.$_renderLeafs(e,t)}_runShowEffect(e){e&&t.SeriesAnimation.grow(this)}_doViewRateChanged(e){this._rootView?this.$_renderGroups(this.width,this.height):this.$_renderLeafs(this.width,this.height)}$_renderLeafs(e,i){const s=this.model,r=s._xAxisObj,h=s._yAxisObj,o=this._inverted;s.pointLabel;const n=this._getGrowRate(),l=this._labelViews(),a=o?e:i,d=o?i:e,{roots:u,leafs:c}=s.buildMap(d,a),p=new t.Color(s._calcedColor),g=[{fill:""}];let f;null==l||l.prepare(this.doc,this);const _=this._labelContainer._textAlign;this._nodeViews.prepare(c.length,((e,i,u)=>{const w=c[i],y=w.point,x=w.parent;let v=p;x&&(!x._color&&x.point.color?v=x._color=new t.Color(x.point.color):x._color&&(v=x._color)),e.node=w,g[0].fill=v.brighten(w.index/u).toString(),this._setPointStyle(e,s,y,g),r.options.reversed&&(w.x=d-w.x-w.width),h.options.reversed&&(w.y=a-w.y-w.height),o&&(w.y=w.y-a),e.render(n);let b=w.x+w.width/2,m=w.y+w.height/2;if(y.xPos=o?-w.y-w.height/2:b,y.yPos=o?d-w.x-w.width/2:m,l&&(f=l.get(y,0))){f.setContrast(e.dom).layout(_);const t=f.getBBox();f.setVis(w.width>=t.height&&w.height>=t.height)&&(o?(b=-w.y-w.height/2-t.width/2,m=d-w.x-(w.width+t.height)/2):(b-=t.width/2,m-=t.height/2),f.trans(b,m))}}))}$_renderGroups(e,t){}}function d(e){(function(e){return e.Series&&e.SeriesView})(e)&&(e.Series.register(n),e.SeriesView.register([n,a]))}d(s),e.TreemapSeries=n,e.default=d,Object.defineProperty(e,"__esModule",{value:!0})}));
package/treemap.mjs ADDED
@@ -0,0 +1,7 @@
1
+
2
+ /**
3
+ * RealChart Treemap v1.2.4
4
+ * Copyright (C) 2023-2024 WooriTech Inc.
5
+ * All Rights Reserved.
6
+ */
7
+ import{extend as e,ChartItem as t,TreemapSeriesType as i,Series as s,maxv as h,DataPoint as r,assignObj as o,pickNum as n,toStr as l,SeriesView as a,ElementPool as d,SeriesAnimation as u,Color as c,RectElement as p}from"./index.mjs";class _ extends r{_assignTo(e){return o(super._assignTo(e),{id:this.id,group:this.group})}_readArray(e,t){if(t.length<=2)this.isNull=!0;else{const i=t.length>3?1:0;i>0&&(this.x=t[n(e.options.xField,0)]),this.y=t[n(e.options.yField,0+i)],this.id=l(t[n(e.options.idField,1+i)]),this.group=l(t[n(e.options.groupField,2+i)])}}_readObject(e,t){super._readObject(e,t),this.id=l(t[e.options.idField]),this.group=l(t[e.options.groupField])}}(class extends t{constructor(e){super(e.chart),this.level=e,this.floating=!0}}).defaults=e(t.defaults,{visible:!1});class g{constructor(e){this.point=e}level(){return this.parent?this.parent.level()+1:0}getArea(){return{x:this.x,y:this.y,width:this.width,height:this.height}}setArea(e,t,i,s){this.x=e,this.y=t,this.width=i,this.height=s}getTotal(){return this.children.reduce(((e,t)=>e+t.value),0)}}class f extends s{constructor(){super(...arguments),this._map={},this._levels=1}buildMap(e,t){function i(e){if(e.children){let t=0;e.children.forEach(((e,s)=>{i(e),t+=e.value})),e.value=t,e.children=e.children.sort(((e,t)=>t.value-e.value)),e.children.forEach(((e,t)=>{e.index=t})),o=h(o,e.level()+1+1)}else r.push(e),e.value=e.point?e.point.yValue:0}const s="vertical"===this._op.startDir||t>e,r=this._leafs=[];let o=1;return this._roots.forEach(((e,t)=>{i(e)})),this._roots=this._roots.sort(((e,t)=>t.value-e.value)),this._roots.forEach(((e,t)=>{e.index=t})),(this[this._op.algorithm]||this.squarify).call(this,this._roots,e,t,s),this._levels=o,{roots:this._roots,leafs:this._leafs}}needAxes(){return!1}canMixWith(e){return!1}_createPoint(e){return new _(e)}_getLabeledPoints(){return this._leafs.map((e=>e.point))}_doPrepareRender(){super._doPrepareRender(),this._roots=this.$_buildTree(this._runPoints)}$_buildTree(e){const t=[],i=[],s=this._map;e.forEach((e=>{if(e.id||!e.isNull){const h=new g(e);e.id&&(s[e.id]=h),e.group?i.push(h):t.push(h)}}));for(let e=i.length-1;e>=0;e--){const h=i[e],r=s[h.point.group];(h.parent=r)?(r.children||(r.children=[]),r.children.push(h),h.children&&i.splice(e,1)):(t.push(h),i.splice(e,1))}return t}$_squarifyRow(e,t,i,s){const r=t.width*t.height,o=t.width,n=t.height;let l=t.x,a=t.y,d=Number.MAX_VALUE,u=0;const c=[];if(2===e.length){return(1===i?o>n:o>=n)?e.forEach((e=>{e.setArea(l,a,o*e.value/s,n),l+=e.width})):e.forEach((e=>{e.setArea(l,a,o,n*e.value/s),a+=e.height})),0}for(;e.length>0;){let p,_,g,f,w;if(p=e.shift(),u+=p.value,f=u*r/s,1===i?(_=f/n,g=n*p.value/u):(g=f/o,_=o*p.value/u),w=h(_/g,g/_),e.length>0&&w>d)return e.unshift(p),u-=p.value,f=r*u/s,1===i?(g=n,_=f/g):(_=o,g=f/_),c.forEach((e=>{1===i?(e.setArea(l,a,_,n*e.value/u),a+=e.height):(e.setArea(l,a,o*e.value/u,g),l+=e.width)})),1===i?(t.x+=_,t.width-=_):(t.y+=g,t.height-=g),s-u;if(0===e.length)return f=r*u/s,1===i?(g=n,_=f/g):(_=o,g=f/_),c.push(p),c.forEach((e=>{1===i?(e.setArea(l,a,_,n*e.value/u),a+=e.height):(e.setArea(l,a,o*e.value/u,g),l+=e.width)})),0;d=w,c.push(p)}}$_squarify(e,t,i,s){const h=e.slice(0);let r=i?1:0,o=e.reduce(((e,t)=>e+t.value),0);do{o=this.$_squarifyRow(h,t,r,o),s&&(r=1-r)}while(o>0);e.forEach((e=>{e.children&&this.$_squarify(e.children,e.getArea(),!i,!0)}))}squarify(e,t,i,s){this.$_squarify(e,{x:0,y:0,width:t,height:i},s,!0)}strip(e,t,i,s){this.$_squarify(e,{x:0,y:0,width:t,height:i},s,!1)}$_sliceNext(e,t,i,s){if(e.x=t.x,e.y=t.y,1===i){const i=t.height*e.value/s;e.width=t.width,e.height=i,t.y+=i,t.height-=i}else{const i=t.width*e.value/s;e.height=t.height,e.width=i,t.x+=i,t.width-=i}e.children&&this.$_slice(e.children,e.getArea(),0===i,!0)}$_slice(e,t,i,s){let h=e.reduce(((e,t)=>e+t.value),0),r=i?1:0;e.forEach((e=>{this.$_sliceNext(e,t,r,h),h-=e.value,s&&(r=1-r)}))}slice(e,t,i,s){this.$_slice(e,{x:0,y:0,width:t,height:i},s,!1)}sliceDice(e,t,i,s){this.$_slice(e,{x:0,y:0,width:t,height:i},s,!0)}}f.type=i,f.defaults=e(t.defaults,{idField:"id",groupField:"group",algorithm:"squarify",alternate:!0,groupMode:!0});class w extends p{constructor(e){super(e,a.POINT_CLASS)}get point(){return this.node.point}render(e){if(1!==e){const t=Object.assign({},this.node);t.width*=e,t.height*=e,t.x+=(this.node.width-t.width)/2,t.y+=(this.node.height-t.height)/2,this.setRect(t)}else this.setRect(this.node)}}class x extends a{constructor(e){super(e,"rct-treemap-series"),this._nodeViews=new d(this._pointContainer,w)}_lazyPrepareLabels(){return!0}_getPointPool(){return this._nodeViews}_prepareSeries(e,t){}_renderSeries(e,t){this._pointContainer.invert(this._inverted,t),this._rootView?this.$_renderGroups(e,t):this.$_renderLeafs(e,t)}_runShowEffect(e){e&&u.grow(this)}_doViewRateChanged(e){this._rootView?this.$_renderGroups(this.width,this.height):this.$_renderLeafs(this.width,this.height)}$_renderLeafs(e,t){const i=this.model,s=i._xAxisObj,h=i._yAxisObj,r=this._inverted;i.pointLabel;const o=this._getGrowRate(),n=this._labelViews(),l=r?e:t,a=r?t:e,{roots:d,leafs:u}=i.buildMap(a,l),p=new c(i._calcedColor),_=[{fill:""}];let g;null==n||n.prepare(this.doc,this);const f=this._labelContainer._textAlign;this._nodeViews.prepare(u.length,((e,t,d)=>{const w=u[t],x=w.point,y=w.parent;let v=p;y&&(!y._color&&y.point.color?v=y._color=new c(y.point.color):y._color&&(v=y._color)),e.node=w,_[0].fill=v.brighten(w.index/d).toString(),this._setPointStyle(e,i,x,_),s.options.reversed&&(w.x=a-w.x-w.width),h.options.reversed&&(w.y=l-w.y-w.height),r&&(w.y=w.y-l),e.render(o);let $=w.x+w.width/2,A=w.y+w.height/2;if(x.xPos=r?-w.y-w.height/2:$,x.yPos=r?a-w.x-w.width/2:A,n&&(g=n.get(x,0))){g.setContrast(e.dom).layout(f);const t=g.getBBox();g.setVis(w.width>=t.height&&w.height>=t.height)&&(r?($=-w.y-w.height/2-t.width/2,A=a-w.x-(w.width+t.height)/2):($-=t.width/2,A-=t.height/2),g.trans($,A))}}))}$_renderGroups(e,t){}}function y(e){(function(e){return e.Series&&e.SeriesView})(e)&&(e.Series.register(f),e.SeriesView.register([f,x]))}export{f as TreemapSeries,y as default};
package/vector.d.ts ADDED
@@ -0,0 +1,21 @@
1
+ import * as RealChart from 'realchart';
2
+ import { ConnectableSeries, VectorSeriesOptions, DataPoint, RcElement } from 'realchart';
3
+
4
+ /**
5
+ * Vector 시리즈 모델.<br/>
6
+ * {@page op.SeriesOptions#type}은 {@page config.series.vecotor 'vector'}이고,
7
+ * {@page options 설정} 모델은 {@page op.VectorSeriesOptions}이다.
8
+ *
9
+ * @modules Vector
10
+ */
11
+ declare class VectorSeries extends ConnectableSeries<VectorSeriesOptions> {
12
+ static readonly type = "vector";
13
+ static defaults: VectorSeriesOptions;
14
+ protected _createPoint(source: any): DataPoint;
15
+ protected _doPrepareRender(): void;
16
+ protected _createLegendMarker(doc: Document, size: number): RcElement;
17
+ }
18
+
19
+ declare function registerSeries(chart: typeof RealChart): void;
20
+
21
+ export { VectorSeries, registerSeries as default };
package/vector.js ADDED
@@ -0,0 +1,7 @@
1
+
2
+ /**
3
+ * RealChart Vector v1.2.4
4
+ * Copyright (C) 2023-2024 WooriTech Inc.
5
+ * All Rights Reserved.
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).RealChartVector={},e.RealChart)}(this,(function(e,t){"use strict";function s(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(s){if("default"!==s){var n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:function(){return e[s]}})}})),t.default=e,Object.freeze(t)}var n=s(t);class i extends t.DataPoint{_assignTo(e){return t.assignObj(super._assignTo(e),{length:this.length,angle:this.angle,lengthValue:this.lengthValue,angleValue:this.angleValue})}_valuesChangd(e){return this.length!==e.length||this.angle!==e.angle||super._valuesChangd(e)}_readArray(e,s){if(s.length<=2)this.isNull=!0;else{const n=s.length>3?1:0;n>0&&(this.x=s[t.pickNum(e.options.xField,0)]),this.y=s[t.pickNum(e.options.yField,0+n)],this.length=s[t.pickNum(e.options.lengthField,1+n)],this.angle=s[t.pickNum(e.options.angleField,2+n)]}}_readObject(e,s){super._readObject(e,s),this.length=t.pickProp(s[e.options.lengthField],s.length),this.angle=t.pickProp(s[e.options.angleField],s.angle),this.y=t.pickProp3(e._yFielder(s),s.y,s.value)}_readSingle(e){super._readSingle(e),this.length=this.angle=this.y}parse(e){super.parse(e),this.isNull||(this.isNull=isNaN(this.lengthValue)||isNaN(this.angleValue))}initValues(){this.lengthValue=parseFloat(this.length),this.angleValue=parseFloat(this.angle)}initPrev(e,t){t.yValue=this.yValue,t.lengthValue=.001}applyValueRate(e,s){this.lengthValue=t.incv(e.lengthValue,this.lengthValue,s)}}class r extends t.ConnectableSeries{_createPoint(e){return new i(e)}_doPrepareRender(){super._doPrepareRender();const e=this._runPoints;if(e.length>0){const s=this._op.maxLength,n=this._op.origin,i=e.map((e=>e.length)).reduce(((e,s)=>t.maxv(e,s)));e.forEach((e=>{const t=e.length/i;switch(e._len=t*s,n){case"start":e._off=-e._len/2;break;case"end":e._off=e._len/2;break;default:e._off=0}}))}}_createLegendMarker(e,s){const n=.3,i=.7*s,r=[0,-n*s,-.2*s,-n*s,0,-.6*s,.2*s,-n*s,0,-n*s,0,.6*s],a=["M",r[0],r[1]+i];for(let e=2;e<r.length;e+=2)a.push("L",r[e],r[e+1]+i);const o=new t.PathElement(e,t.Series.LEGEND_MARKER,a);return o.setStyle("strokeWidth","2px"),o.rotation=30,o}}r.type=t.VectorSeriesType,r.defaults=t.extend(t.Series.defaults,{origin:"center",maxLength:20,startAngle:0,arrowHead:"close"});class a extends t.PointElement{layout(e,t,s){const n=this.point._len,i=n*s,r=.5;let a,o=(n-i)/2;switch(e){case"none":a=[0,o-r*i,0,o+r*i];break;case"open":const e=.15,t=.45,s=.2;a=[0,o-t*i,0-e*i,o-s*i,0,o-r*i,0+e*i,o-s*i,0,o-t*i,0,o+r*i];break;default:const n=.1,l=.3;a=[0,o-l*i,0-n*i,o-l*i,0,o-r*i,0+n*i,o-l*i,0,o-l*i,0,o+r*i]}const l=this.point._off*s,h=["M",a[0],a[1]+l];for(let e=2;e<a.length;e+=2)h.push("L",a[e],a[e+1]+l);this.rotation=t,this.setPath(h)}}class o extends t.SeriesView{constructor(e){super(e,"rct-vector-series"),this._arrows=new t.ElementPool(this._pointContainer,a)}_getPointPool(){return this._arrows}_prepareSeries(e,t){this.$_prepareArrows(t,this._visPoints)}_renderSeries(e,t){const s=this.model;let n=s.options.startAngle;const i=s.options.arrowHead,r=s._xAxisObj,a=s._yAxisObj,o=this._inverted,l=o?e:t,h=o?t:e,u=this._getGrowRate(),g=o?0:t,c=r.options.reversed?-1:1,p=a.options.reversed;this._pointContainer.invert(o,t),this._arrows.forEach((e=>{const t=e.point;if(e.setVis(!t.isNull)){const s=r.getPos(h,t.xValue),d=g-a.getPos(l,t.yValue);let _=n+t.angleValue*c;p&&(_=180-_),t.xPos=o?g+a.getPos(l,t.yValue):s,t.yPos=o?h-r.getPos(h,t.xValue):d,e.trans(s,d),e.layout(i,_,u)}}))}_runShowEffect(e){e&&t.SeriesAnimation.grow(this)}_doViewRateChanged(e){this._renderSeries(this.width,this.height)}getPointsAt(e,t){return[]}$_prepareArrows(e,t){this._arrows.prepare(t.length,((s,n)=>{const i=s.point=t[n];this._setPointStyle(s,e,i)}))}}function l(e){(function(e){return e.Series&&e.SeriesView})(e)&&(e.Series.register(r),e.SeriesView.register([r,o]))}l(n),e.VectorSeries=r,e.default=l,Object.defineProperty(e,"__esModule",{value:!0})}));
package/vector.mjs ADDED
@@ -0,0 +1,7 @@
1
+
2
+ /**
3
+ * RealChart Vector v1.2.4
4
+ * Copyright (C) 2023-2024 WooriTech Inc.
5
+ * All Rights Reserved.
6
+ */
7
+ import{VectorSeriesType as e,extend as t,Series as s,ConnectableSeries as n,maxv as i,PathElement as r,DataPoint as l,assignObj as a,pickNum as o,pickProp as h,pickProp3 as g,incv as u,SeriesView as p,ElementPool as _,SeriesAnimation as d,PointElement as c}from"./index.mjs";class f extends l{_assignTo(e){return a(super._assignTo(e),{length:this.length,angle:this.angle,lengthValue:this.lengthValue,angleValue:this.angleValue})}_valuesChangd(e){return this.length!==e.length||this.angle!==e.angle||super._valuesChangd(e)}_readArray(e,t){if(t.length<=2)this.isNull=!0;else{const s=t.length>3?1:0;s>0&&(this.x=t[o(e.options.xField,0)]),this.y=t[o(e.options.yField,0+s)],this.length=t[o(e.options.lengthField,1+s)],this.angle=t[o(e.options.angleField,2+s)]}}_readObject(e,t){super._readObject(e,t),this.length=h(t[e.options.lengthField],t.length),this.angle=h(t[e.options.angleField],t.angle),this.y=g(e._yFielder(t),t.y,t.value)}_readSingle(e){super._readSingle(e),this.length=this.angle=this.y}parse(e){super.parse(e),this.isNull||(this.isNull=isNaN(this.lengthValue)||isNaN(this.angleValue))}initValues(){this.lengthValue=parseFloat(this.length),this.angleValue=parseFloat(this.angle)}initPrev(e,t){t.yValue=this.yValue,t.lengthValue=.001}applyValueRate(e,t){this.lengthValue=u(e.lengthValue,this.lengthValue,t)}}class V extends n{_createPoint(e){return new f(e)}_doPrepareRender(){super._doPrepareRender();const e=this._runPoints;if(e.length>0){const t=this._op.maxLength,s=this._op.origin,n=e.map((e=>e.length)).reduce(((e,t)=>i(e,t)));e.forEach((e=>{const i=e.length/n;switch(e._len=i*t,s){case"start":e._off=-e._len/2;break;case"end":e._off=e._len/2;break;default:e._off=0}}))}}_createLegendMarker(e,t){const n=.3,i=.7*t,l=[0,-n*t,-.2*t,-n*t,0,-.6*t,.2*t,-n*t,0,-n*t,0,.6*t],a=["M",l[0],l[1]+i];for(let e=2;e<l.length;e+=2)a.push("L",l[e],l[e+1]+i);const o=new r(e,s.LEGEND_MARKER,a);return o.setStyle("strokeWidth","2px"),o.rotation=30,o}}V.type=e,V.defaults=t(s.defaults,{origin:"center",maxLength:20,startAngle:0,arrowHead:"close"});class w extends c{layout(e,t,s){const n=this.point._len,i=n*s,r=.5;let l,a=(n-i)/2;switch(e){case"none":l=[0,a-r*i,0,a+r*i];break;case"open":const e=.15,t=.45,s=.2;l=[0,a-t*i,0-e*i,a-s*i,0,a-r*i,0+e*i,a-s*i,0,a-t*i,0,a+r*i];break;default:const n=.1,o=.3;l=[0,a-o*i,0-n*i,a-o*i,0,a-r*i,0+n*i,a-o*i,0,a-o*i,0,a+r*i]}const o=this.point._off*s,h=["M",l[0],l[1]+o];for(let e=2;e<l.length;e+=2)h.push("L",l[e],l[e+1]+o);this.rotation=t,this.setPath(h)}}class y extends p{constructor(e){super(e,"rct-vector-series"),this._arrows=new _(this._pointContainer,w)}_getPointPool(){return this._arrows}_prepareSeries(e,t){this.$_prepareArrows(t,this._visPoints)}_renderSeries(e,t){const s=this.model;let n=s.options.startAngle;const i=s.options.arrowHead,r=s._xAxisObj,l=s._yAxisObj,a=this._inverted,o=a?e:t,h=a?t:e,g=this._getGrowRate(),u=a?0:t,p=r.options.reversed?-1:1,_=l.options.reversed;this._pointContainer.invert(a,t),this._arrows.forEach((e=>{const t=e.point;if(e.setVis(!t.isNull)){const s=r.getPos(h,t.xValue),d=u-l.getPos(o,t.yValue);let c=n+t.angleValue*p;_&&(c=180-c),t.xPos=a?u+l.getPos(o,t.yValue):s,t.yPos=a?h-r.getPos(h,t.xValue):d,e.trans(s,d),e.layout(i,c,g)}}))}_runShowEffect(e){e&&d.grow(this)}_doViewRateChanged(e){this._renderSeries(this.width,this.height)}getPointsAt(e,t){return[]}$_prepareArrows(e,t){this._arrows.prepare(t.length,((s,n)=>{const i=s.point=t[n];this._setPointStyle(s,e,i)}))}}function x(e){(function(e){return e.Series&&e.SeriesView})(e)&&(e.Series.register(V),e.SeriesView.register([V,y]))}export{V as VectorSeries,x as default};