@operato/scene-scichart 9.1.1 → 10.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/charts/axis-synchronizer.js +3 -2
- package/dist/charts/axis-synchronizer.js.map +1 -1
- package/dist/charts/ox-scichart-multiple.d.ts +2 -1
- package/dist/charts/ox-scichart-multiple.js +70 -74
- package/dist/charts/ox-scichart-multiple.js.map +1 -1
- package/dist/charts/ox-scichart.d.ts +2 -1
- package/dist/charts/ox-scichart.js +46 -51
- package/dist/charts/ox-scichart.js.map +1 -1
- package/dist/charts/scichart-builder.js +13 -14
- package/dist/charts/scichart-builder.js.map +1 -1
- package/dist/scichart-multiple-timeseries.js +1 -2
- package/dist/scichart-multiple-timeseries.js.map +1 -1
- package/dist/scichart-timeseries.js +1 -2
- package/dist/scichart-timeseries.js.map +1 -1
- package/package.json +14 -14
|
@@ -4,26 +4,46 @@ import { LitElement, html, css } from 'lit';
|
|
|
4
4
|
import { property, query, customElement } from 'lit/decorators.js';
|
|
5
5
|
import { buildSciChart, updateAnnotations, addAnnotationsOnDataChange, removeAnnotationsByData } from './scichart-builder.js';
|
|
6
6
|
import { NumberRange } from 'scichart';
|
|
7
|
-
let OxSciChart =
|
|
7
|
+
let OxSciChart = class OxSciChart extends LitElement {
|
|
8
|
+
static { OxSciChart_1 = this; }
|
|
9
|
+
static MAX_DATA_SIZE = 2000;
|
|
8
10
|
constructor() {
|
|
9
|
-
super(
|
|
11
|
+
super();
|
|
10
12
|
this.config = null;
|
|
11
13
|
this.data = [];
|
|
12
|
-
this.chart = null;
|
|
13
|
-
this.dataSeries = [];
|
|
14
|
-
/*
|
|
15
|
-
[주의]
|
|
16
|
-
ox-scichart container의 id를 글로벌 유니크하게 해야한다.
|
|
17
|
-
SciChart가 특별히 container의 id를 기반으로 하위 컴포넌트를 구성하고 있기 때문이다.
|
|
18
|
-
shadowDom 안에 있는 container 이더라도, 글로벌 유니크한 id를 제공해야 한다.
|
|
19
|
-
그렇지 않으면, 단 하나의 차트만 제대로 렌더링된다.
|
|
20
|
-
*/
|
|
21
|
-
this.containerId = 'ox-sci-chart' + ++OxSciChart_1.idx;
|
|
22
14
|
}
|
|
15
|
+
chart = null;
|
|
16
|
+
dataSeries = [];
|
|
17
|
+
/*
|
|
18
|
+
[주의]
|
|
19
|
+
ox-scichart container의 id를 글로벌 유니크하게 해야한다.
|
|
20
|
+
SciChart가 특별히 container의 id를 기반으로 하위 컴포넌트를 구성하고 있기 때문이다.
|
|
21
|
+
shadowDom 안에 있는 container 이더라도, 글로벌 유니크한 id를 제공해야 한다.
|
|
22
|
+
그렇지 않으면, 단 하나의 차트만 제대로 렌더링된다.
|
|
23
|
+
*/
|
|
24
|
+
static idx = 0;
|
|
25
|
+
containerId = 'ox-sci-chart' + ++OxSciChart_1.idx;
|
|
26
|
+
static styles = css `
|
|
27
|
+
:host {
|
|
28
|
+
display: block;
|
|
29
|
+
width: 100%;
|
|
30
|
+
height: 100%;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.chart-container {
|
|
34
|
+
display: flex;
|
|
35
|
+
width: 100%;
|
|
36
|
+
height: 100%;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.chart-content {
|
|
40
|
+
flex: 1;
|
|
41
|
+
position: relative;
|
|
42
|
+
}
|
|
43
|
+
`;
|
|
23
44
|
async initializeSciChart() {
|
|
24
|
-
var _a;
|
|
25
45
|
if (this.chart) {
|
|
26
|
-
|
|
46
|
+
this.chart.sciChartSurface?.delete();
|
|
27
47
|
this.chart = null;
|
|
28
48
|
}
|
|
29
49
|
const { chart, dataSeries } = (await buildSciChart(this.config, this.container, {}, {})) || {};
|
|
@@ -33,12 +53,11 @@ let OxSciChart = OxSciChart_1 = class OxSciChart extends LitElement {
|
|
|
33
53
|
this.dataSeries = dataSeries;
|
|
34
54
|
}
|
|
35
55
|
dispose() {
|
|
36
|
-
var _a;
|
|
37
56
|
// 데이터 시리즈 해제
|
|
38
57
|
this.dataSeries.forEach(ds => ds.delete());
|
|
39
58
|
this.dataSeries = [];
|
|
40
59
|
// SciChartSurface 해제
|
|
41
|
-
if (
|
|
60
|
+
if (this.chart?.sciChartSurface) {
|
|
42
61
|
this.chart.sciChartSurface.renderableSeries.clear(); // 렌더러 시리즈 제거
|
|
43
62
|
this.chart.sciChartSurface.xAxes.clear(); // X축 제거
|
|
44
63
|
this.chart.sciChartSurface.yAxes.clear(); // Y축 제거
|
|
@@ -62,8 +81,7 @@ let OxSciChart = OxSciChart_1 = class OxSciChart extends LitElement {
|
|
|
62
81
|
}
|
|
63
82
|
}
|
|
64
83
|
updateDataSeries() {
|
|
65
|
-
|
|
66
|
-
if (!((_a = this.dataSeries) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
84
|
+
if (!this.dataSeries?.length) {
|
|
67
85
|
return;
|
|
68
86
|
}
|
|
69
87
|
this.dataSeries.forEach(ds => ds.clear());
|
|
@@ -75,14 +93,13 @@ let OxSciChart = OxSciChart_1 = class OxSciChart extends LitElement {
|
|
|
75
93
|
}
|
|
76
94
|
});
|
|
77
95
|
setTimeout(() => {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
(_b = this.chart) === null || _b === void 0 ? void 0 : _b.sciChartSurface.invalidateElement();
|
|
96
|
+
this.chart?.sciChartSurface.zoomExtents();
|
|
97
|
+
this.chart?.sciChartSurface.invalidateElement();
|
|
81
98
|
}, 200);
|
|
82
99
|
}
|
|
83
100
|
get dataSet() {
|
|
84
101
|
const { config, data } = this;
|
|
85
|
-
const { datasets = [], labelDataKey: attrX } =
|
|
102
|
+
const { datasets = [], labelDataKey: attrX } = config?.data || {};
|
|
86
103
|
if (!(data instanceof Array) || !attrX) {
|
|
87
104
|
return [];
|
|
88
105
|
}
|
|
@@ -106,15 +123,14 @@ let OxSciChart = OxSciChart_1 = class OxSciChart extends LitElement {
|
|
|
106
123
|
});
|
|
107
124
|
}
|
|
108
125
|
async appendData(appendum) {
|
|
109
|
-
|
|
110
|
-
if (!appendum || !appendum.length || !((_a = this.dataSeries) === null || _a === void 0 ? void 0 : _a.length))
|
|
126
|
+
if (!appendum || !appendum.length || !this.dataSeries?.length)
|
|
111
127
|
return;
|
|
112
128
|
const { config } = this;
|
|
113
|
-
const { datasets = [], labelDataKey: attrX } =
|
|
129
|
+
const { datasets = [], labelDataKey: attrX } = config?.data || {};
|
|
114
130
|
const { options: { annotations = [] } = {}, data: chartData } = config || {};
|
|
115
131
|
if (!attrX)
|
|
116
132
|
return;
|
|
117
|
-
|
|
133
|
+
this.data ??= [];
|
|
118
134
|
const prevDataLength = this.data.length;
|
|
119
135
|
const prevData = this.data.slice(); // 기존 데이터 복사
|
|
120
136
|
// 데이터 추가
|
|
@@ -125,7 +141,7 @@ let OxSciChart = OxSciChart_1 = class OxSciChart extends LitElement {
|
|
|
125
141
|
removed = this.data.splice(0, appendum.length);
|
|
126
142
|
this.dataSeries.forEach(ds => ds.removeRange(0, appendum.length));
|
|
127
143
|
// 삭제된 데이터와 연관된 annotation 제거
|
|
128
|
-
if (
|
|
144
|
+
if (this.chart?.sciChartSurface) {
|
|
129
145
|
removeAnnotationsByData(this.chart.sciChartSurface, removed, chartData, annotations);
|
|
130
146
|
}
|
|
131
147
|
}
|
|
@@ -151,7 +167,7 @@ let OxSciChart = OxSciChart_1 = class OxSciChart extends LitElement {
|
|
|
151
167
|
}
|
|
152
168
|
});
|
|
153
169
|
// === annotation 추가: 값이 변경된 경우에만 ===
|
|
154
|
-
if (
|
|
170
|
+
if (this.chart?.sciChartSurface) {
|
|
155
171
|
addAnnotationsOnDataChange(this.chart.sciChartSurface, annotations, chartData, prevData, appendum
|
|
156
172
|
// config?.options?.fontFamily,
|
|
157
173
|
// config?.options?.fontColor
|
|
@@ -159,9 +175,8 @@ let OxSciChart = OxSciChart_1 = class OxSciChart extends LitElement {
|
|
|
159
175
|
}
|
|
160
176
|
// 차트 갱신 및 X축 시프트
|
|
161
177
|
setTimeout(() => {
|
|
162
|
-
|
|
163
|
-
(
|
|
164
|
-
if ((_b = this.chart) === null || _b === void 0 ? void 0 : _b.sciChartSurface) {
|
|
178
|
+
this.chart?.sciChartSurface.invalidateElement();
|
|
179
|
+
if (this.chart?.sciChartSurface) {
|
|
165
180
|
const xAxis = this.chart.sciChartSurface.xAxes.get(0);
|
|
166
181
|
if (xAxis) {
|
|
167
182
|
const visibleRange = xAxis.visibleRange;
|
|
@@ -180,26 +195,6 @@ let OxSciChart = OxSciChart_1 = class OxSciChart extends LitElement {
|
|
|
180
195
|
return html ` <div id=${this.containerId} class="chart-container"></div> `;
|
|
181
196
|
}
|
|
182
197
|
};
|
|
183
|
-
OxSciChart.MAX_DATA_SIZE = 2000;
|
|
184
|
-
OxSciChart.idx = 0;
|
|
185
|
-
OxSciChart.styles = css `
|
|
186
|
-
:host {
|
|
187
|
-
display: block;
|
|
188
|
-
width: 100%;
|
|
189
|
-
height: 100%;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
.chart-container {
|
|
193
|
-
display: flex;
|
|
194
|
-
width: 100%;
|
|
195
|
-
height: 100%;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
.chart-content {
|
|
199
|
-
flex: 1;
|
|
200
|
-
position: relative;
|
|
201
|
-
}
|
|
202
|
-
`;
|
|
203
198
|
__decorate([
|
|
204
199
|
property({ type: Object })
|
|
205
200
|
], OxSciChart.prototype, "config", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ox-scichart.js","sourceRoot":"","sources":["../../src/charts/ox-scichart.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAElE,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,0BAA0B,EAC1B,uBAAuB,EACxB,MAAM,uBAAuB,CAAA;AAC9B,OAAO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C,CAAC,CAAC,SAAS,EAAiB,CAAA;oBAE/D,IAAI,SAAS,CAAC,GAAG,GAAG,YAAY,CAAC,GAAG,EAAE,CAAC;wBACrC,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,GAAG,YAAY,CAAC,GAAG,CAAA;wBAC9C,MAAM,QAAQ,GAAG,IAAI,WAAW,CAAC,YAAY,CAAC,GAAG,GAAG,KAAK,EAAE,YAAY,CAAC,GAAG,GAAG,KAAK,CAAC,CAAA;wBACpF,KAAK,CAAC,YAAY,GAAG,QAAQ,CAAA;oBAC/B,CAAC;gBACH,CAAC;gBACD,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,iBAAiB,EAAE,CAAA;YAChD,CAAC;QACH,CAAC,EAAE,GAAG,CAAC,CAAA;IACT,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAA,YAAY,IAAI,CAAC,WAAW,kCAAkC,CAAA;IAC3E,CAAC;;AAvOuB,wBAAa,GAAG,IAAI,AAAP,CAAO;AAkBrC,cAAG,GAAW,CAAC,AAAZ,CAAY;AAEf,iBAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;GAiBlB,AAjBY,CAiBZ;AAnC2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0CAA+C;AAC/C;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;wCAAqC;AAapC;IAA1B,KAAK,CAAC,kBAAkB,CAAC;6CAA2B;AAjB1C,UAAU;IADtB,aAAa,CAAC,aAAa,CAAC;GAChB,UAAU,CAyOtB","sourcesContent":["import { LitElement, html, css } from 'lit'\nimport { property, query, customElement } from 'lit/decorators.js'\nimport type { OperatoChart } from '@operato/chart'\nimport {\n buildSciChart,\n updateAnnotations,\n addAnnotationsOnDataChange,\n removeAnnotationsByData\n} from './scichart-builder.js'\nimport { NumberRange } from 'scichart'\n\n@customElement('ox-scichart')\nexport class OxSciChart extends LitElement {\n private static readonly MAX_DATA_SIZE = 2000\n\n @property({ type: Object }) config: OperatoChart.ChartConfig | null = null\n @property({ type: Array }) data: { [attr: string]: any }[] = []\n\n public chart: any = null\n private dataSeries: any[] = []\n /*\n [주의]\n ox-scichart container의 id를 글로벌 유니크하게 해야한다. \n SciChart가 특별히 container의 id를 기반으로 하위 컴포넌트를 구성하고 있기 때문이다.\n shadowDom 안에 있는 container 이더라도, 글로벌 유니크한 id를 제공해야 한다.\n 그렇지 않으면, 단 하나의 차트만 제대로 렌더링된다.\n */\n private containerId: string = 'ox-sci-chart' + ++OxSciChart.idx\n\n @query('.chart-container') container!: HTMLDivElement\n\n static idx: number = 0\n\n static styles = css`\n :host {\n display: block;\n width: 100%;\n height: 100%;\n }\n\n .chart-container {\n display: flex;\n width: 100%;\n height: 100%;\n }\n\n .chart-content {\n flex: 1;\n position: relative;\n }\n `\n\n async initializeSciChart() {\n if (this.chart) {\n this.chart.sciChartSurface?.delete()\n this.chart = null\n }\n\n const { chart, dataSeries } = (await buildSciChart(this.config, this.container, {}, {})) || {}\n\n const { data: chartData, options: { annotations } = {} } = this.config || {}\n updateAnnotations(chart.sciChartSurface, annotations, chartData, this.data)\n\n this.chart = chart\n this.dataSeries = dataSeries!\n }\n\n dispose() {\n // 데이터 시리즈 해제\n this.dataSeries.forEach(ds => ds.delete())\n this.dataSeries = []\n\n // SciChartSurface 해제\n if (this.chart?.sciChartSurface) {\n this.chart.sciChartSurface.renderableSeries.clear() // 렌더러 시리즈 제거\n this.chart.sciChartSurface.xAxes.clear() // X축 제거\n this.chart.sciChartSurface.yAxes.clear() // Y축 제거\n this.chart.sciChartSurface.delete() // SciChartSurface 삭제\n }\n\n this.chart = null // chart 객체 초기화\n }\n\n async updated(changedProperties: Map<string | number | symbol, unknown>) {\n var needDataUpdate = false\n\n if (changedProperties.has('config') && this.config) {\n await this.initializeSciChart()\n needDataUpdate = true\n }\n\n if (changedProperties.has('data')) {\n needDataUpdate = true\n }\n\n if (needDataUpdate) {\n await this.updateDataSeries()\n\n const { data: chartData, options: { annotations } = {} } = this.config || {}\n updateAnnotations(this.chart.sciChartSurface, annotations, chartData, this.data)\n }\n }\n\n updateDataSeries() {\n if (!this.dataSeries?.length) {\n return\n }\n\n this.dataSeries.forEach(ds => ds.clear())\n const newData = this.dataSet\n\n newData.forEach((data, index) => {\n const filteredData = data.filter(d => typeof d.yValue === 'number')\n\n if (filteredData.length > 0) {\n this.dataSeries[index].appendRange(\n filteredData.map(d => d.xValue),\n filteredData.map(d => d.yValue)\n )\n }\n })\n\n setTimeout(() => {\n this.chart?.sciChartSurface.zoomExtents()\n this.chart?.sciChartSurface.invalidateElement()\n }, 200)\n }\n\n get dataSet(): { xValue: number; yValue: number }[][] {\n const { config, data } = this\n const { datasets = [], labelDataKey: attrX } = config?.data || {}\n\n if (!(data instanceof Array) || !attrX) {\n return []\n }\n\n return datasets.map(dataset => {\n return data\n .map(item => {\n if (!item || typeof item !== 'object') {\n return\n }\n\n const xValue = new Date(item[attrX])\n if (isNaN(xValue.getTime())) {\n console.error('Invalid date:', item[attrX])\n return\n }\n\n return {\n xValue: xValue.getTime() / 1000,\n yValue: item[dataset.dataKey!]\n }\n })\n .filter(Boolean) as { xValue: number; yValue: number }[]\n })\n }\n\n async appendData(appendum: { [attr: string]: any }[]) {\n if (!appendum || !appendum.length || !this.dataSeries?.length) return\n const { config } = this\n const { datasets = [], labelDataKey: attrX } = config?.data || {}\n const { options: { annotations = [] } = {}, data: chartData } = config || {}\n if (!attrX) return\n\n this.data ??= []\n const prevDataLength = this.data.length\n const prevData = this.data.slice() // 기존 데이터 복사\n\n // 데이터 추가\n this.data.push(...appendum)\n\n // 데이터 초과 시 삭제 처리 및 관련 annotation 제거\n let removed: any[] = []\n if (this.data.length > OxSciChart.MAX_DATA_SIZE) {\n removed = this.data.splice(0, appendum.length)\n this.dataSeries.forEach(ds => ds.removeRange(0, appendum.length))\n // 삭제된 데이터와 연관된 annotation 제거\n if (this.chart?.sciChartSurface) {\n removeAnnotationsByData(this.chart.sciChartSurface, removed, chartData, annotations)\n }\n }\n\n // 새로운 데이터만 dataSeries에 추가\n datasets.forEach((dataset, index) => {\n const newData = appendum\n .map(item => {\n if (!item || typeof item !== 'object') return null\n const xValue = new Date(item[attrX])\n if (isNaN(xValue.getTime())) {\n console.error('Invalid date:', item[attrX])\n return null\n }\n return {\n xValue: xValue.getTime() / 1000,\n yValue: item[dataset.dataKey!]\n }\n })\n .filter(Boolean) as { xValue: number; yValue: number }[]\n\n if (newData.length > 0) {\n this.dataSeries[index].appendRange(\n newData.map(d => d.xValue),\n newData.map(d => d.yValue)\n )\n }\n })\n\n // === annotation 추가: 값이 변경된 경우에만 ===\n if (this.chart?.sciChartSurface) {\n addAnnotationsOnDataChange(\n this.chart.sciChartSurface,\n annotations,\n chartData,\n prevData,\n appendum\n // config?.options?.fontFamily,\n // config?.options?.fontColor\n )\n }\n\n // 차트 갱신 및 X축 시프트\n setTimeout(() => {\n this.chart?.sciChartSurface.invalidateElement()\n\n if (this.chart?.sciChartSurface) {\n const xAxis = this.chart.sciChartSurface.xAxes.get(0)\n if (xAxis) {\n const visibleRange = xAxis.visibleRange as NumberRange\n const dataRange = this.dataSeries[0].getXRange() as NumberRange\n\n if (dataRange.max > visibleRange.max) {\n const shift = dataRange.max - visibleRange.max\n const newRange = new NumberRange(visibleRange.min + shift, visibleRange.max + shift)\n xAxis.visibleRange = newRange\n }\n }\n this.chart.sciChartSurface.invalidateElement()\n }\n }, 200)\n }\n\n render() {\n return html` <div id=${this.containerId} class=\"chart-container\"></div> `\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ox-scichart': OxSciChart\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ox-scichart.js","sourceRoot":"","sources":["../../src/charts/ox-scichart.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,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;gBACrD,IAAI,KAAK,EAAE,CAAC;oBACV,MAAM,YAAY,GAAG,KAAK,CAAC,YAA2B,CAAA;oBACtD,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,EAAiB,CAAA;oBAE/D,IAAI,SAAS,CAAC,GAAG,GAAG,YAAY,CAAC,GAAG,EAAE,CAAC;wBACrC,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,GAAG,YAAY,CAAC,GAAG,CAAA;wBAC9C,MAAM,QAAQ,GAAG,IAAI,WAAW,CAAC,YAAY,CAAC,GAAG,GAAG,KAAK,EAAE,YAAY,CAAC,GAAG,GAAG,KAAK,CAAC,CAAA;wBACpF,KAAK,CAAC,YAAY,GAAG,QAAQ,CAAA;oBAC/B,CAAC;gBACH,CAAC;gBACD,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,iBAAiB,EAAE,CAAA;YAChD,CAAC;QACH,CAAC,EAAE,GAAG,CAAC,CAAA;IACT,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAA,YAAY,IAAI,CAAC,WAAW,kCAAkC,CAAA;IAC3E,CAAC;;AA3OmC;IAAnC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0CAAgD;AACxC;IAAlC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;wCAAwC;AAqB/B;IAAlC,KAAK,CAAC,kBAAkB,CAAC;6CAAkC;AAzBjD,UAAU;IADtB,aAAa,CAAC,aAAa,CAAC;GAChB,UAAU,CA+OtB","sourcesContent":["import { LitElement, html, css } from 'lit'\nimport { property, query, customElement } from 'lit/decorators.js'\nimport type { OperatoChart } from '@operato/chart'\nimport {\n buildSciChart,\n updateAnnotations,\n addAnnotationsOnDataChange,\n removeAnnotationsByData\n} from './scichart-builder.js'\nimport { NumberRange } from 'scichart'\n\n@customElement('ox-scichart')\nexport class OxSciChart extends LitElement {\n private static readonly MAX_DATA_SIZE = 2000\n\n @property({ type: Object }) declare config: OperatoChart.ChartConfig | null\n @property({ type: Array }) declare data: { [attr: string]: any }[]\n\n constructor() {\n super()\n this.config = null\n this.data = []\n }\n\n public chart: any = null\n private dataSeries: any[] = []\n /*\n [주의]\n ox-scichart container의 id를 글로벌 유니크하게 해야한다. \n SciChart가 특별히 container의 id를 기반으로 하위 컴포넌트를 구성하고 있기 때문이다.\n shadowDom 안에 있는 container 이더라도, 글로벌 유니크한 id를 제공해야 한다.\n 그렇지 않으면, 단 하나의 차트만 제대로 렌더링된다.\n */\n static idx: number = 0\n\n private containerId: string = 'ox-sci-chart' + ++OxSciChart.idx\n\n @query('.chart-container') declare container: HTMLDivElement\n\n static styles = css`\n :host {\n display: block;\n width: 100%;\n height: 100%;\n }\n\n .chart-container {\n display: flex;\n width: 100%;\n height: 100%;\n }\n\n .chart-content {\n flex: 1;\n position: relative;\n }\n `\n\n async initializeSciChart() {\n if (this.chart) {\n this.chart.sciChartSurface?.delete()\n this.chart = null\n }\n\n const { chart, dataSeries } = (await buildSciChart(this.config, this.container, {}, {})) || {}\n\n const { data: chartData, options: { annotations } = {} } = this.config || {}\n updateAnnotations(chart.sciChartSurface, annotations, chartData, this.data)\n\n this.chart = chart\n this.dataSeries = dataSeries!\n }\n\n dispose() {\n // 데이터 시리즈 해제\n this.dataSeries.forEach(ds => ds.delete())\n this.dataSeries = []\n\n // SciChartSurface 해제\n if (this.chart?.sciChartSurface) {\n this.chart.sciChartSurface.renderableSeries.clear() // 렌더러 시리즈 제거\n this.chart.sciChartSurface.xAxes.clear() // X축 제거\n this.chart.sciChartSurface.yAxes.clear() // Y축 제거\n this.chart.sciChartSurface.delete() // SciChartSurface 삭제\n }\n\n this.chart = null // chart 객체 초기화\n }\n\n async updated(changedProperties: Map<string | number | symbol, unknown>) {\n var needDataUpdate = false\n\n if (changedProperties.has('config') && this.config) {\n await this.initializeSciChart()\n needDataUpdate = true\n }\n\n if (changedProperties.has('data')) {\n needDataUpdate = true\n }\n\n if (needDataUpdate) {\n await this.updateDataSeries()\n\n const { data: chartData, options: { annotations } = {} } = this.config || {}\n updateAnnotations(this.chart.sciChartSurface, annotations, chartData, this.data)\n }\n }\n\n updateDataSeries() {\n if (!this.dataSeries?.length) {\n return\n }\n\n this.dataSeries.forEach(ds => ds.clear())\n const newData = this.dataSet\n\n newData.forEach((data, index) => {\n const filteredData = data.filter(d => typeof d.yValue === 'number')\n\n if (filteredData.length > 0) {\n this.dataSeries[index].appendRange(\n filteredData.map(d => d.xValue),\n filteredData.map(d => d.yValue)\n )\n }\n })\n\n setTimeout(() => {\n this.chart?.sciChartSurface.zoomExtents()\n this.chart?.sciChartSurface.invalidateElement()\n }, 200)\n }\n\n get dataSet(): { xValue: number; yValue: number }[][] {\n const { config, data } = this\n const { datasets = [], labelDataKey: attrX } = config?.data || {}\n\n if (!(data instanceof Array) || !attrX) {\n return []\n }\n\n return datasets.map(dataset => {\n return data\n .map(item => {\n if (!item || typeof item !== 'object') {\n return\n }\n\n const xValue = new Date(item[attrX])\n if (isNaN(xValue.getTime())) {\n console.error('Invalid date:', item[attrX])\n return\n }\n\n return {\n xValue: xValue.getTime() / 1000,\n yValue: item[dataset.dataKey!]\n }\n })\n .filter(Boolean) as { xValue: number; yValue: number }[]\n })\n }\n\n async appendData(appendum: { [attr: string]: any }[]) {\n if (!appendum || !appendum.length || !this.dataSeries?.length) return\n const { config } = this\n const { datasets = [], labelDataKey: attrX } = config?.data || {}\n const { options: { annotations = [] } = {}, data: chartData } = config || {}\n if (!attrX) return\n\n this.data ??= []\n const prevDataLength = this.data.length\n const prevData = this.data.slice() // 기존 데이터 복사\n\n // 데이터 추가\n this.data.push(...appendum)\n\n // 데이터 초과 시 삭제 처리 및 관련 annotation 제거\n let removed: any[] = []\n if (this.data.length > OxSciChart.MAX_DATA_SIZE) {\n removed = this.data.splice(0, appendum.length)\n this.dataSeries.forEach(ds => ds.removeRange(0, appendum.length))\n // 삭제된 데이터와 연관된 annotation 제거\n if (this.chart?.sciChartSurface) {\n removeAnnotationsByData(this.chart.sciChartSurface, removed, chartData, annotations)\n }\n }\n\n // 새로운 데이터만 dataSeries에 추가\n datasets.forEach((dataset, index) => {\n const newData = appendum\n .map(item => {\n if (!item || typeof item !== 'object') return null\n const xValue = new Date(item[attrX])\n if (isNaN(xValue.getTime())) {\n console.error('Invalid date:', item[attrX])\n return null\n }\n return {\n xValue: xValue.getTime() / 1000,\n yValue: item[dataset.dataKey!]\n }\n })\n .filter(Boolean) as { xValue: number; yValue: number }[]\n\n if (newData.length > 0) {\n this.dataSeries[index].appendRange(\n newData.map(d => d.xValue),\n newData.map(d => d.yValue)\n )\n }\n })\n\n // === annotation 추가: 값이 변경된 경우에만 ===\n if (this.chart?.sciChartSurface) {\n addAnnotationsOnDataChange(\n this.chart.sciChartSurface,\n annotations,\n chartData,\n prevData,\n appendum\n // config?.options?.fontFamily,\n // config?.options?.fontColor\n )\n }\n\n // 차트 갱신 및 X축 시프트\n setTimeout(() => {\n this.chart?.sciChartSurface.invalidateElement()\n\n if (this.chart?.sciChartSurface) {\n const xAxis = this.chart.sciChartSurface.xAxes.get(0)\n if (xAxis) {\n const visibleRange = xAxis.visibleRange as NumberRange\n const dataRange = this.dataSeries[0].getXRange() as NumberRange\n\n if (dataRange.max > visibleRange.max) {\n const shift = dataRange.max - visibleRange.max\n const newRange = new NumberRange(visibleRange.min + shift, visibleRange.max + shift)\n xAxis.visibleRange = newRange\n }\n }\n this.chart.sciChartSurface.invalidateElement()\n }\n }, 200)\n }\n\n render() {\n return html` <div id=${this.containerId} class=\"chart-container\"></div> `\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ox-scichart': OxSciChart\n }\n}\n"]}
|
|
@@ -253,23 +253,22 @@ export async function buildSciChart(config, container, { fontSize = 13, fontFami
|
|
|
253
253
|
showAxisLabel: true /* show x-axis label for cursor */,
|
|
254
254
|
modifierGroup: grouped,
|
|
255
255
|
tooltipDataTemplate: (seriesInfo) => {
|
|
256
|
-
var _a, _b;
|
|
257
256
|
const valuesWithLabels = [];
|
|
258
257
|
const xySeriesInfo = seriesInfo;
|
|
259
258
|
let formattedValue = xySeriesInfo.yValue;
|
|
260
259
|
// 시리즈 이름으로 인덱스 찾기
|
|
261
260
|
const datasetIdx = datasets.findIndex(ds => ds.label === xySeriesInfo.seriesName);
|
|
262
261
|
const thisDataset = datasets[datasetIdx >= 0 ? datasetIdx : index];
|
|
263
|
-
const valueFormat =
|
|
262
|
+
const valueFormat = thisDataset?.valueFormat || '0.##';
|
|
264
263
|
if (typeof formattedValue === 'number') {
|
|
265
264
|
// prefix, numberFormat, suffix 분리
|
|
266
265
|
const match = valueFormat.match(/^(.*?)([#,0.]+)(.*?)$/);
|
|
267
266
|
const prefix = match ? match[1] : '';
|
|
268
267
|
const numberFormat = match ? match[2] : valueFormat;
|
|
269
268
|
const suffix = match ? match[3] : '';
|
|
270
|
-
const decimalPart =
|
|
269
|
+
const decimalPart = numberFormat.split('.')[1]?.replace(/[^#0]/g, '');
|
|
271
270
|
let minFrac = decimalPart ? decimalPart.length : 0;
|
|
272
|
-
let maxFrac =
|
|
271
|
+
let maxFrac = numberFormat.split('.')[1]?.length || 2;
|
|
273
272
|
const formattedNumber = new Intl.NumberFormat(undefined, {
|
|
274
273
|
minimumFractionDigits: minFrac,
|
|
275
274
|
maximumFractionDigits: maxFrac,
|
|
@@ -306,7 +305,7 @@ export async function buildSciChart(config, container, { fontSize = 13, fontFami
|
|
|
306
305
|
sciChartSurface.chartModifiers.add(new RubberBandXyZoomModifier({ executeOn: EExecuteOn.MouseRightButton, modifierGroup: grouped }),
|
|
307
306
|
// new ZoomPanModifier({ xyDirection: EXyDirection.XDirection }),
|
|
308
307
|
new ZoomPanModifier({ xyDirection: EXyDirection.XDirection }), new MouseWheelZoomModifier({ xyDirection: EXyDirection.XDirection }), new ZoomExtentsModifier(), new XAxisDragModifier(), new YAxisDragModifier());
|
|
309
|
-
if (legend
|
|
308
|
+
if (legend?.display) {
|
|
310
309
|
const legendModifier = new LegendModifier({
|
|
311
310
|
showCheckboxes: true,
|
|
312
311
|
showSeriesMarkers: true,
|
|
@@ -424,9 +423,9 @@ function getYCoordModeByAnchor(anchor) {
|
|
|
424
423
|
return ECoordinateMode.Relative;
|
|
425
424
|
}
|
|
426
425
|
export function updateAnnotations(sciChartSurface, annotations = [], fromData, rawData = [], fontSize, fontFamily, fontColor) {
|
|
427
|
-
fontSize
|
|
428
|
-
fontFamily
|
|
429
|
-
fontColor
|
|
426
|
+
fontSize ||= 13;
|
|
427
|
+
fontFamily ||= 'Roboto';
|
|
428
|
+
fontColor ||= '#FFFFFF';
|
|
430
429
|
sciChartSurface.annotations.clear();
|
|
431
430
|
if (annotations) {
|
|
432
431
|
annotations.forEach(annotation => {
|
|
@@ -443,7 +442,7 @@ export function updateAnnotations(sciChartSurface, annotations = [], fromData, r
|
|
|
443
442
|
: EVerticalAnchorPoint.Center;
|
|
444
443
|
// dataKey가 있는 경우 데이터와 연동
|
|
445
444
|
if (annotation.dataKey && rawData && rawData.length > 0) {
|
|
446
|
-
const attrX =
|
|
445
|
+
const attrX = fromData?.labelDataKey || ''; // X축 데이터 키 가져오기
|
|
447
446
|
if (annotation.type === 'verticalLine') {
|
|
448
447
|
// 수직 라인: falsy => truthy 변화 지점에만 표시
|
|
449
448
|
let prevValue = undefined;
|
|
@@ -722,10 +721,10 @@ export function updateAnnotations(sciChartSurface, annotations = [], fromData, r
|
|
|
722
721
|
export function addAnnotationsOnDataChange(sciChartSurface, annotations = [], fromData, prevData = [], appendum = [], fontSize, fontFamily, fontColor) {
|
|
723
722
|
if (!annotations || !appendum || !appendum.length)
|
|
724
723
|
return;
|
|
725
|
-
fontSize
|
|
726
|
-
fontFamily
|
|
727
|
-
fontColor
|
|
728
|
-
const attrX =
|
|
724
|
+
fontSize ||= 13;
|
|
725
|
+
fontFamily ||= 'Roboto';
|
|
726
|
+
fontColor ||= '#FFFFFF';
|
|
727
|
+
const attrX = fromData?.labelDataKey || '';
|
|
729
728
|
annotations
|
|
730
729
|
.filter(annotation => annotation.dataKey && (annotation.type == 'text' || annotation.type == 'verticalLine'))
|
|
731
730
|
.forEach(annotation => {
|
|
@@ -794,7 +793,7 @@ export function addAnnotationsOnDataChange(sciChartSurface, annotations = [], fr
|
|
|
794
793
|
export function removeAnnotationsByData(sciChartSurface, removedData = [], fromData, annotations = []) {
|
|
795
794
|
if (!removedData || !removedData.length || !annotations.length)
|
|
796
795
|
return;
|
|
797
|
-
const attrX =
|
|
796
|
+
const attrX = fromData?.labelDataKey || '';
|
|
798
797
|
const removedXValues = removedData
|
|
799
798
|
.map(item => {
|
|
800
799
|
const xValue = attrX ? new Date(item[attrX]).getTime() / 1000 : undefined;
|