@operato/scene-scichart 7.0.7 → 7.1.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +19 -0
- package/cache/translations/system/en.json +1 -1
- package/cache/translations/system/ko.json +1 -1
- package/db.sqlite +0 -0
- package/dist/charts/axis-synchronizer.d.ts +10 -0
- package/dist/charts/axis-synchronizer.js +32 -0
- package/dist/charts/axis-synchronizer.js.map +1 -0
- package/dist/charts/ox-scichart-multiple.d.ts +43 -0
- package/dist/charts/ox-scichart-multiple.js +298 -0
- package/dist/charts/ox-scichart-multiple.js.map +1 -0
- package/dist/charts/ox-scichart.d.ts +4 -1
- package/dist/charts/ox-scichart.js +1 -0
- package/dist/charts/ox-scichart.js.map +1 -1
- package/dist/charts/scichart-builder.d.ts +10 -1
- package/dist/charts/scichart-builder.js +98 -15
- package/dist/charts/scichart-builder.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/scichart-multiple-timeseries.d.ts +14 -0
- package/dist/scichart-multiple-timeseries.js +60 -0
- package/dist/scichart-multiple-timeseries.js.map +1 -0
- package/dist/scichart-timeseries.d.ts +2 -11
- package/dist/scichart-timeseries.js +2 -42
- package/dist/scichart-timeseries.js.map +1 -1
- package/dist/templates/index.js +2 -1
- package/dist/templates/index.js.map +1 -1
- package/dist/templates/scichart-multiple-timeseries.d.ts +53 -0
- package/dist/templates/scichart-multiple-timeseries.js +81 -0
- package/dist/templates/scichart-multiple-timeseries.js.map +1 -0
- package/helps/scene/component/scichart-multiple-timeseries.md +23 -0
- package/helps/scene/component/scichart-timeseries.md +18 -0
- package/icons/scichart-multiple-timeseries.png +0 -0
- package/logs/.08636eb59927f12972f6774f5947c8507b3564c2-audit.json +26 -6
- package/logs/.5e5d741d8b7784a2fbad65eedc0fd46946aaf6f2-audit.json +31 -21
- package/logs/{application-2024-07-13-21.log → application-2024-07-28-03.log} +8 -8
- package/logs/{application-2024-07-13-20.log → application-2024-07-28-17.log} +32 -36
- package/logs/application-2024-07-28-18.log +210 -0
- package/logs/application-2024-07-29-01.log +105 -0
- package/logs/application-2024-07-29-14.log +105 -0
- package/logs/application-2024-07-29-16.log +105 -0
- package/logs/connections-2024-07-23-14.log +50 -0
- package/logs/connections-2024-07-25-23.log +50 -0
- package/logs/connections-2024-07-26-18.log +50 -0
- package/logs/connections-2024-07-28-03.log +50 -0
- package/logs/connections-2024-07-28-17.log +200 -0
- package/logs/connections-2024-07-28-18.log +100 -0
- package/logs/connections-2024-07-29-01.log +50 -0
- package/logs/connections-2024-07-29-14.log +50 -0
- package/logs/connections-2024-07-29-16.log +50 -0
- package/package.json +2 -2
- package/schema.graphql +112 -0
- package/src/charts/axis-synchronizer.ts +37 -0
- package/src/charts/ox-scichart-multiple.ts +362 -0
- package/src/charts/ox-scichart.ts +3 -1
- package/src/charts/scichart-builder.ts +136 -24
- package/src/index.ts +1 -0
- package/src/scichart-multiple-timeseries.ts +74 -0
- package/src/scichart-timeseries.ts +3 -54
- package/src/templates/index.ts +2 -1
- package/src/templates/scichart-multiple-timeseries.ts +87 -0
- package/things-scene.config.js +0 -2
- package/translations/en.json +3 -1
- package/translations/ja.json +3 -1
- package/translations/ko.json +3 -1
- package/translations/ms.json +3 -1
- package/translations/zh.json +3 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/logs/connections-2024-07-08-22.log +0 -50
- package/logs/connections-2024-07-08-23.log +0 -100
- package/logs/connections-2024-07-09-15.log +0 -100
- package/logs/connections-2024-07-10-00.log +0 -50
- package/logs/connections-2024-07-10-10.log +0 -50
- package/logs/connections-2024-07-13-20.log +0 -200
- package/logs/connections-2024-07-13-21.log +0 -50
@@ -0,0 +1,298 @@
|
|
1
|
+
var OxSciChartMultiple_1;
|
2
|
+
import { __decorate } from "tslib";
|
3
|
+
import { LitElement, html, css } from 'lit';
|
4
|
+
import { property, query, customElement } from 'lit/decorators.js';
|
5
|
+
import { keyed } from 'lit/directives/keyed.js';
|
6
|
+
import { buildSciChart, buildSciChartOverview } from './scichart-builder';
|
7
|
+
import { AxisSynchroniser } from './axis-synchronizer';
|
8
|
+
import { NumberRange, SciChartVerticalGroup } from 'scichart';
|
9
|
+
import { ScrollbarStyles } from '@operato/styles';
|
10
|
+
let OxSciChartMultiple = OxSciChartMultiple_1 = class OxSciChartMultiple extends LitElement {
|
11
|
+
constructor() {
|
12
|
+
super(...arguments);
|
13
|
+
this.config = null;
|
14
|
+
this.data = [];
|
15
|
+
this.visibleSeries = [];
|
16
|
+
this.showOverview = true;
|
17
|
+
this.synchronizer = new AxisSynchroniser(new NumberRange(200, 500));
|
18
|
+
this.verticalGroup = new SciChartVerticalGroup();
|
19
|
+
this.isInitializing = false;
|
20
|
+
this.overviewChart = null;
|
21
|
+
this.overviewDataSeries = [];
|
22
|
+
this.groupCharts = [];
|
23
|
+
/*
|
24
|
+
[주의]
|
25
|
+
ox-scichart container의 id를 글로벌 유니크하게 해야한다.
|
26
|
+
SciChart가 특별히 container의 id를 기반으로 하위 컴포넌트를 구성하고 있기 때문이다.
|
27
|
+
shadowDom 안에 있는 container 이더라도, 글로벌 유니크한 id를 제공해야 한다.
|
28
|
+
그렇지 않으면, 단 하나의 차트만 제대로 렌더링된다.
|
29
|
+
*/
|
30
|
+
this.containerId = 'ox-scichart-multiple' + ++OxSciChartMultiple_1.idx;
|
31
|
+
}
|
32
|
+
async initializeSciChart() {
|
33
|
+
this.cleanup();
|
34
|
+
const { chart, dataSeries } = (await buildSciChartOverview(this.config, this.overviewContainer, {}, this.synchronizer)) || {};
|
35
|
+
this.verticalGroup.addSurfaceToGroup(chart.sciChartSurface);
|
36
|
+
this.overviewChart = chart;
|
37
|
+
this.overviewDataSeries = dataSeries;
|
38
|
+
}
|
39
|
+
async updated(changedProperties) {
|
40
|
+
var needDataUpdate = false;
|
41
|
+
if (changedProperties.has('config') && this.config) {
|
42
|
+
this.isInitializing = true;
|
43
|
+
await this.initializeSciChart();
|
44
|
+
this.isInitializing = false;
|
45
|
+
needDataUpdate = true;
|
46
|
+
}
|
47
|
+
if (changedProperties.has('visibleSeries')) {
|
48
|
+
if (this.isInitializing) {
|
49
|
+
await this.ensureInitialization();
|
50
|
+
}
|
51
|
+
await this.updateSeries(this.visibleSeries, changedProperties.get('visibleSeries'));
|
52
|
+
needDataUpdate = true;
|
53
|
+
}
|
54
|
+
if (changedProperties.has('data')) {
|
55
|
+
needDataUpdate = true;
|
56
|
+
}
|
57
|
+
if (needDataUpdate) {
|
58
|
+
await this.updateDataSeries();
|
59
|
+
}
|
60
|
+
}
|
61
|
+
async ensureInitialization() {
|
62
|
+
while (this.isInitializing) {
|
63
|
+
await new Promise(resolve => setTimeout(resolve, 100)); // Check every 100ms
|
64
|
+
}
|
65
|
+
}
|
66
|
+
cleanup() {
|
67
|
+
var _a;
|
68
|
+
this.cleanupGroup();
|
69
|
+
if (this.overviewChart) {
|
70
|
+
(_a = this.overviewChart.sciChartSurface) === null || _a === void 0 ? void 0 : _a.delete();
|
71
|
+
this.overviewChart = null;
|
72
|
+
}
|
73
|
+
}
|
74
|
+
cleanupGroup() {
|
75
|
+
this.groupCharts.forEach(chart => {
|
76
|
+
if (chart.sciChartSurface) {
|
77
|
+
this.synchronizer.removeAxis(chart.sciChartSurface.xAxes.get(0));
|
78
|
+
this.verticalGroup.removeSurface(chart.sciChartSurface);
|
79
|
+
chart.sciChartSurface.delete();
|
80
|
+
}
|
81
|
+
});
|
82
|
+
this.groupCharts.length = 0;
|
83
|
+
}
|
84
|
+
async updateDataSeries() {
|
85
|
+
var _a, _b;
|
86
|
+
const { config, data } = this;
|
87
|
+
const { datasets = [], labelDataKey: attrX } = (config === null || config === void 0 ? void 0 : config.data) || {};
|
88
|
+
if (!(data instanceof Array) || !attrX) {
|
89
|
+
return [];
|
90
|
+
}
|
91
|
+
const newData = this.dataSet;
|
92
|
+
(this.groupCharts || []).forEach(({ dataKey, sciChartSurface, dataSeries }) => {
|
93
|
+
try {
|
94
|
+
dataSeries.forEach(ds => ds.clear());
|
95
|
+
const dataSet = newData.filter((data, index) => dataKey == datasets[index].dataKey);
|
96
|
+
dataSet.forEach((data, index) => {
|
97
|
+
dataSeries[index].appendRange(data.map(d => d.xValue), data.map(d => d.yValue));
|
98
|
+
});
|
99
|
+
}
|
100
|
+
catch (error) {
|
101
|
+
console.log(error);
|
102
|
+
}
|
103
|
+
sciChartSurface.zoomExtents();
|
104
|
+
sciChartSurface.invalidateElement();
|
105
|
+
});
|
106
|
+
try {
|
107
|
+
this.overviewDataSeries.forEach(ds => ds.clear());
|
108
|
+
newData.forEach((data, index) => {
|
109
|
+
if (this.visibleSeries.includes(datasets[index].dataKey)) {
|
110
|
+
this.overviewDataSeries[index].appendRange(data.map(d => d.xValue), data.map(d => d.yValue));
|
111
|
+
}
|
112
|
+
});
|
113
|
+
(_a = this.overviewChart) === null || _a === void 0 ? void 0 : _a.sciChartSurface.zoomExtents();
|
114
|
+
(_b = this.overviewChart) === null || _b === void 0 ? void 0 : _b.sciChartSurface.invalidateElement();
|
115
|
+
}
|
116
|
+
catch (error) {
|
117
|
+
console.log(error);
|
118
|
+
}
|
119
|
+
}
|
120
|
+
get dataSet() {
|
121
|
+
const { config, data } = this;
|
122
|
+
const { datasets = [], labelDataKey: attrX } = (config === null || config === void 0 ? void 0 : config.data) || {};
|
123
|
+
if (!(data instanceof Array) || !attrX) {
|
124
|
+
return [];
|
125
|
+
}
|
126
|
+
return datasets.map(dataset => {
|
127
|
+
return data
|
128
|
+
.map(item => {
|
129
|
+
if (!item || typeof item !== 'object') {
|
130
|
+
return;
|
131
|
+
}
|
132
|
+
const xValue = new Date(item[attrX]);
|
133
|
+
if (isNaN(xValue.getTime())) {
|
134
|
+
console.error('Invalid date:', item[attrX]);
|
135
|
+
return;
|
136
|
+
}
|
137
|
+
return {
|
138
|
+
xValue: xValue.getTime() / 1000,
|
139
|
+
yValue: item[dataset.dataKey]
|
140
|
+
};
|
141
|
+
})
|
142
|
+
.filter(Boolean);
|
143
|
+
});
|
144
|
+
}
|
145
|
+
render() {
|
146
|
+
var _a;
|
147
|
+
const { datasets = [] } = ((_a = this.config) === null || _a === void 0 ? void 0 : _a.data) || {};
|
148
|
+
return html `
|
149
|
+
<div id=${this.containerId + '-overview'} class="overview" ?hidden=${!this.showOverview}></div>
|
150
|
+
<div id="chart-group">
|
151
|
+
${datasets.map(({ dataKey }) => keyed(dataKey, html `
|
152
|
+
<div
|
153
|
+
id=${this.containerId + '-' + dataKey}
|
154
|
+
class="grouped-chart"
|
155
|
+
?hidden=${!this.visibleSeries.includes(dataKey)}
|
156
|
+
></div>
|
157
|
+
`))}
|
158
|
+
</div>
|
159
|
+
`;
|
160
|
+
}
|
161
|
+
async buildChartGroup() {
|
162
|
+
this.cleanupGroup();
|
163
|
+
const { config } = this;
|
164
|
+
const { datasets = [] } = (config === null || config === void 0 ? void 0 : config.data) || {};
|
165
|
+
await Promise.all(datasets
|
166
|
+
.filter(dataset => this.visibleSeries.includes(dataset.dataKey))
|
167
|
+
.map(async (dataset) => {
|
168
|
+
await this.addChart(dataset.dataKey);
|
169
|
+
}));
|
170
|
+
}
|
171
|
+
async updateSeries(after, before) {
|
172
|
+
/* 기존 시리즈와 새로운 시리즈의 차이를 비교해서, before에는 있는데, after에는 없으면 await removeChart(string)를 호출하고, after에는 있는데, before에는 없으면, addChart(string) 한다. */
|
173
|
+
// before에는 있는데 after에는 없는 시리즈를 제거합니다.
|
174
|
+
for (const series of before || []) {
|
175
|
+
if (!after.includes(series)) {
|
176
|
+
await this.removeChart(series);
|
177
|
+
}
|
178
|
+
}
|
179
|
+
// after에는 있는데 before에는 없는 시리즈를 추가합니다.
|
180
|
+
for (const series of after || []) {
|
181
|
+
if (!before || !before.includes(series)) {
|
182
|
+
await this.addChart(series);
|
183
|
+
}
|
184
|
+
}
|
185
|
+
}
|
186
|
+
async addChart(dataKey) {
|
187
|
+
const groupedChart = {
|
188
|
+
dataKey: '',
|
189
|
+
sciChartSurface: undefined,
|
190
|
+
dataSeries: []
|
191
|
+
};
|
192
|
+
const { data = {}, options = {} } = this.config || {};
|
193
|
+
const { datasets = [] } = data;
|
194
|
+
const dataset = datasets.find(dataset => dataset.dataKey == dataKey);
|
195
|
+
if (!dataset) {
|
196
|
+
return;
|
197
|
+
}
|
198
|
+
const { scales } = options;
|
199
|
+
const { yAxes = [] } = scales || {};
|
200
|
+
const yAxis = {
|
201
|
+
...yAxes[0],
|
202
|
+
axisTitle: dataset === null || dataset === void 0 ? void 0 : dataset.label
|
203
|
+
};
|
204
|
+
const config = {
|
205
|
+
...this.config,
|
206
|
+
data: {
|
207
|
+
datasets: [dataset]
|
208
|
+
},
|
209
|
+
options: {
|
210
|
+
...options,
|
211
|
+
scales: {
|
212
|
+
...scales,
|
213
|
+
yAxes: [yAxis]
|
214
|
+
}
|
215
|
+
}
|
216
|
+
};
|
217
|
+
const container = this.renderRoot.querySelector(`#${this.containerId + '-' + dataKey}`);
|
218
|
+
var { chart, dataSeries } = (await buildSciChart(config, container, { fontSize: 14, fontFamily: 'Roboto', fontColor: undefined }, this.containerId));
|
219
|
+
this.verticalGroup.addSurfaceToGroup(chart.sciChartSurface);
|
220
|
+
this.synchronizer.addAxis(chart.sciChartSurface.xAxes.get(0));
|
221
|
+
groupedChart.dataKey = config.data.datasets[0].dataKey;
|
222
|
+
groupedChart.sciChartSurface = chart.sciChartSurface;
|
223
|
+
groupedChart.dataSeries = dataSeries;
|
224
|
+
this.groupCharts = this.groupSorter([...this.groupCharts, groupedChart]);
|
225
|
+
}
|
226
|
+
removeChart(dataKey) {
|
227
|
+
const index = this.groupCharts.findIndex((chart) => chart.dataKey == dataKey);
|
228
|
+
const [groupedChart] = this.groupCharts.splice(index, 1);
|
229
|
+
if (!groupedChart) {
|
230
|
+
return;
|
231
|
+
}
|
232
|
+
this.verticalGroup.removeSurface(groupedChart.sciChartSurface);
|
233
|
+
this.synchronizer.removeAxis(groupedChart.sciChartSurface.xAxes.get(0));
|
234
|
+
groupedChart.sciChartSurface.delete();
|
235
|
+
groupedChart.sciChartSurface = undefined;
|
236
|
+
this.groupCharts = this.groupSorter(this.groupCharts);
|
237
|
+
}
|
238
|
+
groupSorter(group) {
|
239
|
+
return group.sort((a, b) => this.visibleSeries.findIndex((s) => s.dataKey == a.dataKey) -
|
240
|
+
this.visibleSeries.findIndex((s) => s.dataKey == b.dataKey));
|
241
|
+
}
|
242
|
+
async appendData(appendum) { }
|
243
|
+
};
|
244
|
+
OxSciChartMultiple.idx = 0;
|
245
|
+
OxSciChartMultiple.styles = [
|
246
|
+
ScrollbarStyles,
|
247
|
+
css `
|
248
|
+
:host {
|
249
|
+
display: flex;
|
250
|
+
flex-direction: column;
|
251
|
+
|
252
|
+
width: 100%;
|
253
|
+
height: 100%;
|
254
|
+
}
|
255
|
+
|
256
|
+
.overview {
|
257
|
+
height: 80px;
|
258
|
+
}
|
259
|
+
|
260
|
+
#chart-group {
|
261
|
+
flex: 1;
|
262
|
+
|
263
|
+
display: flex;
|
264
|
+
flex-direction: column;
|
265
|
+
overflow-y: auto;
|
266
|
+
}
|
267
|
+
|
268
|
+
.grouped-chart {
|
269
|
+
flex: 1;
|
270
|
+
|
271
|
+
min-height: 25%;
|
272
|
+
}
|
273
|
+
|
274
|
+
[hidden] {
|
275
|
+
display: none;
|
276
|
+
}
|
277
|
+
`
|
278
|
+
];
|
279
|
+
__decorate([
|
280
|
+
property({ type: Object })
|
281
|
+
], OxSciChartMultiple.prototype, "config", void 0);
|
282
|
+
__decorate([
|
283
|
+
property({ type: Array })
|
284
|
+
], OxSciChartMultiple.prototype, "data", void 0);
|
285
|
+
__decorate([
|
286
|
+
property({ type: Array })
|
287
|
+
], OxSciChartMultiple.prototype, "visibleSeries", void 0);
|
288
|
+
__decorate([
|
289
|
+
property({ type: Boolean, attribute: 'show-overview' })
|
290
|
+
], OxSciChartMultiple.prototype, "showOverview", void 0);
|
291
|
+
__decorate([
|
292
|
+
query('.overview')
|
293
|
+
], OxSciChartMultiple.prototype, "overviewContainer", void 0);
|
294
|
+
OxSciChartMultiple = OxSciChartMultiple_1 = __decorate([
|
295
|
+
customElement('ox-scichart-multiple')
|
296
|
+
], OxSciChartMultiple);
|
297
|
+
export { OxSciChartMultiple };
|
298
|
+
//# sourceMappingURL=ox-scichart-multiple.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ox-scichart-multiple.js","sourceRoot":"","sources":["../../src/charts/ox-scichart-multiple.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;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAE/C,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,EAAE,WAAW,EAAa,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAExE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAG1C,IAAM,kBAAkB,0BAAxB,MAAM,kBAAmB,SAAQ,UAAU;IAA3C;;QACuB,WAAM,GAAoC,IAAI,CAAA;QAC/C,SAAI,GAA8B,EAAE,CAAA;QACpC,kBAAa,GAAa,EAAE,CAAA;QACE,iBAAY,GAAY,IAAI,CAAA;QAE7E,iBAAY,GAAqB,IAAI,gBAAgB,CAAC,IAAI,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAA;QAChF,kBAAa,GAA0B,IAAI,qBAAqB,EAAE,CAAA;QAElE,mBAAc,GAAY,KAAK,CAAA;QAC/B,kBAAa,GAAQ,IAAI,CAAA;QACzB,uBAAkB,GAAU,EAAE,CAAA;QAC9B,gBAAW,GAIb,EAAE,CAAA;QAER;;;;;;WAMG;QACK,gBAAW,GAAW,sBAAsB,GAAG,EAAE,oBAAkB,CAAC,GAAG,CAAA;IA+TjF,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;IACf,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA8BF;CACF,AAjCY,CAiCZ;AA/D2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDAA+C;AAC/C;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;gDAAqC;AACpC;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;yDAA6B;AACE;IAAxD,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;wDAA6B;AAuBjE;IAAnB,KAAK,CAAC,WAAW,CAAC;6DAAmC;AA3B3C,kBAAkB;IAD9B,aAAa,CAAC,sBAAsB,CAAC;GACzB,kBAAkB,CAwV9B","sourcesContent":["import { LitElement, html, css } from 'lit'\nimport { property, query, customElement } from 'lit/decorators.js'\nimport { keyed } from 'lit/directives/keyed.js'\n\nimport { buildSciChart, buildSciChartOverview } from './scichart-builder'\nimport { AxisSynchroniser } from './axis-synchronizer'\nimport { NumberRange, scaleAxes, SciChartVerticalGroup } from 'scichart'\n\nimport { ScrollbarStyles } from '@operato/styles'\n\n@customElement('ox-scichart-multiple')\nexport class OxSciChartMultiple extends LitElement {\n @property({ type: Object }) config: OperatoChart.ChartConfig | null = null\n @property({ type: Array }) data: { [attr: string]: any }[] = []\n @property({ type: Array }) visibleSeries: string[] = []\n @property({ type: Boolean, attribute: 'show-overview' }) showOverview: boolean = true\n\n private synchronizer: AxisSynchroniser = new AxisSynchroniser(new NumberRange(200, 500))\n private verticalGroup: SciChartVerticalGroup = new SciChartVerticalGroup()\n\n private isInitializing: boolean = false\n private overviewChart: any = null\n private overviewDataSeries: any[] = []\n private groupCharts: {\n dataKey: string\n sciChartSurface: any\n dataSeries: any[]\n }[] = []\n\n /*\n [주의]\n ox-scichart container의 id를 글로벌 유니크하게 해야한다. \n SciChart가 특별히 container의 id를 기반으로 하위 컴포넌트를 구성하고 있기 때문이다.\n shadowDom 안에 있는 container 이더라도, 글로벌 유니크한 id를 제공해야 한다.\n 그렇지 않으면, 단 하나의 차트만 제대로 렌더링된다.\n */\n private containerId: string = 'ox-scichart-multiple' + ++OxSciChartMultiple.idx\n\n @query('.overview') overviewContainer!: HTMLDivElement\n\n static idx: number = 0\n\n static styles = [\n ScrollbarStyles,\n css`\n :host {\n display: flex;\n flex-direction: column;\n\n width: 100%;\n height: 100%;\n }\n\n .overview {\n height: 80px;\n }\n\n #chart-group {\n flex: 1;\n\n display: flex;\n flex-direction: column;\n overflow-y: auto;\n }\n\n .grouped-chart {\n flex: 1;\n\n min-height: 25%;\n }\n\n [hidden] {\n display: none;\n }\n `\n ]\n\n async initializeSciChart() {\n this.cleanup()\n\n const { chart, dataSeries } =\n (await buildSciChartOverview(this.config, this.overviewContainer, {}, this.synchronizer)) || {}\n\n this.verticalGroup.addSurfaceToGroup(chart.sciChartSurface)\n\n this.overviewChart = chart\n this.overviewDataSeries = dataSeries!\n }\n\n async updated(changedProperties: Map<string | number | symbol, unknown>) {\n var needDataUpdate = false\n\n if (changedProperties.has('config') && this.config) {\n this.isInitializing = true\n await this.initializeSciChart()\n this.isInitializing = false\n needDataUpdate = true\n }\n\n if (changedProperties.has('visibleSeries')) {\n if (this.isInitializing) {\n await this.ensureInitialization()\n }\n await this.updateSeries(this.visibleSeries, changedProperties.get('visibleSeries') as string[])\n needDataUpdate = true\n }\n\n if (changedProperties.has('data')) {\n needDataUpdate = true\n }\n\n if (needDataUpdate) {\n await this.updateDataSeries()\n }\n }\n\n private async ensureInitialization() {\n while (this.isInitializing) {\n await new Promise(resolve => setTimeout(resolve, 100)) // Check every 100ms\n }\n }\n\n cleanup() {\n this.cleanupGroup()\n\n if (this.overviewChart) {\n this.overviewChart.sciChartSurface?.delete()\n this.overviewChart = null\n }\n }\n\n cleanupGroup() {\n this.groupCharts.forEach(chart => {\n if (chart.sciChartSurface) {\n this.synchronizer.removeAxis(chart.sciChartSurface.xAxes.get(0))\n this.verticalGroup.removeSurface(chart.sciChartSurface)\n chart.sciChartSurface.delete()\n }\n })\n\n this.groupCharts.length = 0\n }\n\n async updateDataSeries() {\n const { config, data } = this\n const { datasets = [], labelDataKey: attrX } = config?.data || {}\n\n if (!(data instanceof Array) || !attrX) {\n return []\n }\n\n const newData = this.dataSet\n\n ;(this.groupCharts || []).forEach(({ dataKey, sciChartSurface, dataSeries }) => {\n try {\n dataSeries.forEach(ds => ds.clear())\n const dataSet = newData.filter((data, index) => dataKey == datasets[index].dataKey!)\n\n dataSet.forEach((data, index) => {\n dataSeries[index].appendRange(\n data.map(d => d.xValue),\n data.map(d => d.yValue)\n )\n })\n } catch (error) {\n console.log(error)\n }\n\n sciChartSurface.zoomExtents()\n sciChartSurface.invalidateElement()\n })\n\n try {\n this.overviewDataSeries.forEach(ds => ds.clear())\n\n newData.forEach((data, index) => {\n if (this.visibleSeries.includes(datasets[index].dataKey!)) {\n this.overviewDataSeries[index].appendRange(\n data.map(d => d.xValue),\n data.map(d => d.yValue)\n )\n }\n })\n\n this.overviewChart?.sciChartSurface.zoomExtents()\n this.overviewChart?.sciChartSurface.invalidateElement()\n } catch (error) {\n console.log(error)\n }\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 render() {\n const { datasets = [] } = this.config?.data || {}\n\n return html`\n <div id=${this.containerId + '-overview'} class=\"overview\" ?hidden=${!this.showOverview}></div>\n <div id=\"chart-group\">\n ${datasets.map(({ dataKey }) =>\n keyed(\n dataKey,\n html`\n <div\n id=${this.containerId + '-' + dataKey}\n class=\"grouped-chart\"\n ?hidden=${!this.visibleSeries.includes(dataKey!)}\n ></div>\n `\n )\n )}\n </div>\n `\n }\n\n async buildChartGroup() {\n this.cleanupGroup()\n\n const { config } = this\n const { datasets = [] } = config?.data || {}\n\n await Promise.all(\n datasets\n .filter(dataset => this.visibleSeries.includes(dataset.dataKey!))\n .map(async dataset => {\n await this.addChart(dataset.dataKey!)\n })\n )\n }\n\n async updateSeries(after: string[], before: string[]) {\n /* 기존 시리즈와 새로운 시리즈의 차이를 비교해서, before에는 있는데, after에는 없으면 await removeChart(string)를 호출하고, after에는 있는데, before에는 없으면, addChart(string) 한다. */\n // before에는 있는데 after에는 없는 시리즈를 제거합니다.\n for (const series of before || []) {\n if (!after.includes(series)) {\n await this.removeChart(series)\n }\n }\n\n // after에는 있는데 before에는 없는 시리즈를 추가합니다.\n for (const series of after || []) {\n if (!before || !before.includes(series)) {\n await this.addChart(series)\n }\n }\n }\n\n async addChart(dataKey: string) {\n const groupedChart = {\n dataKey: '',\n sciChartSurface: undefined,\n dataSeries: [] as any[]\n }\n\n const { data = {}, options = {} } = this.config || {}\n const { datasets = [] } = data as OperatoChart.ChartData\n const dataset = datasets.find(dataset => dataset.dataKey == dataKey)\n\n if (!dataset) {\n return\n }\n\n const { scales } = options\n const { yAxes = [] } = scales || {}\n const yAxis = {\n ...yAxes[0],\n axisTitle: dataset?.label\n }\n\n const config = {\n ...this.config,\n data: {\n datasets: [dataset]\n },\n options: {\n ...options,\n scales: {\n ...scales,\n yAxes: [yAxis]\n }\n }\n }\n\n const container = this.renderRoot.querySelector(`#${this.containerId + '-' + dataKey}`)\n var { chart, dataSeries } = (await buildSciChart(\n config,\n container,\n { fontSize: 14, fontFamily: 'Roboto', fontColor: undefined },\n this.containerId\n ))!\n\n this.verticalGroup.addSurfaceToGroup(chart.sciChartSurface)\n this.synchronizer.addAxis(chart.sciChartSurface.xAxes.get(0))\n\n groupedChart.dataKey = config.data.datasets[0]!.dataKey!\n groupedChart.sciChartSurface = chart.sciChartSurface\n groupedChart.dataSeries = dataSeries\n\n this.groupCharts = this.groupSorter([...this.groupCharts, groupedChart])\n }\n\n removeChart(dataKey: string) {\n const index = this.groupCharts.findIndex((chart: any) => chart.dataKey == dataKey)\n const [groupedChart] = this.groupCharts.splice(index, 1)\n\n if (!groupedChart) {\n return\n }\n\n this.verticalGroup.removeSurface(groupedChart.sciChartSurface)\n this.synchronizer.removeAxis(groupedChart.sciChartSurface.xAxes.get(0))\n\n groupedChart.sciChartSurface.delete()\n groupedChart.sciChartSurface = undefined\n\n this.groupCharts = this.groupSorter(this.groupCharts)\n }\n\n groupSorter(group: any[]) {\n return group.sort(\n (a, b) =>\n this.visibleSeries.findIndex((s: any) => s.dataKey == a.dataKey) -\n this.visibleSeries.findIndex((s: any) => s.dataKey == b.dataKey)\n )\n }\n\n async appendData(appendum: { [attr: string]: any }[]) {}\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ox-scichart-multiple': OxSciChartMultiple\n }\n}\n"]}
|
@@ -4,7 +4,7 @@ export declare class OxSciChart extends LitElement {
|
|
4
4
|
data: {
|
5
5
|
[attr: string]: any;
|
6
6
|
}[];
|
7
|
-
|
7
|
+
chart: any;
|
8
8
|
private dataSeries;
|
9
9
|
private containerId;
|
10
10
|
container: HTMLDivElement;
|
@@ -17,6 +17,9 @@ export declare class OxSciChart extends LitElement {
|
|
17
17
|
xValue: number;
|
18
18
|
yValue: number;
|
19
19
|
}[][];
|
20
|
+
appendData(appendum: {
|
21
|
+
[attr: string]: any;
|
22
|
+
}[]): Promise<void>;
|
20
23
|
render(): import("lit-html").TemplateResult<1>;
|
21
24
|
}
|
22
25
|
declare global {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ox-scichart.js","sourceRoot":"","sources":["../../src/charts/ox-scichart.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,UAAU,EAAE,I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;;;;;;;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;AAf1C,UAAU;IADtB,aAAa,CAAC,aAAa,CAAC;GAChB,UAAU,CAuHtB","sourcesContent":["import { LitElement, html, css } from 'lit'\nimport { property, query, customElement } from 'lit/decorators.js'\nimport { buildSciChart } from './scichart-builder'\n\n@customElement('ox-scichart')\nexport class OxSciChart extends LitElement {\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 this.chart = chart\n this.dataSeries = dataSeries!\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 }\n\n updateDataSeries() {\n if (!this.dataSeries?.length) return\n\n this.dataSeries.forEach(ds => ds.clear())\n const newData = this.dataSet\n\n newData.forEach((data, index) => {\n this.dataSeries[index].appendRange(\n data.map(d => d.xValue),\n data.map(d => d.yValue)\n )\n })\n\n this.chart?.sciChartSurface.zoomExtents()\n this.chart?.sciChartSurface.invalidateElement()\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\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,8 +1,17 @@
|
|
1
|
+
import { AxisSynchroniser } from './axis-synchronizer';
|
1
2
|
export declare function buildSciChart(config: OperatoChart.ChartConfig | undefined | null, container: any, { fontSize, fontFamily, fontColor }: {
|
2
3
|
fontSize?: number;
|
3
4
|
fontFamily?: string;
|
4
5
|
fontColor?: string;
|
5
|
-
}): Promise<{
|
6
|
+
}, grouped?: string): Promise<{
|
7
|
+
chart: any;
|
8
|
+
dataSeries: any[];
|
9
|
+
} | undefined>;
|
10
|
+
export declare function buildSciChartOverview(config: OperatoChart.ChartConfig | undefined | null, container: any, { fontSize, fontFamily, fontColor }: {
|
11
|
+
fontSize?: number;
|
12
|
+
fontFamily?: string;
|
13
|
+
fontColor?: string;
|
14
|
+
}, axisSynchroniser: AxisSynchroniser): Promise<{
|
6
15
|
chart: any;
|
7
16
|
dataSeries: any[];
|
8
17
|
} | undefined>;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { TinyColor } from '@ctrl/tinycolor';
|
2
|
-
import { SciChartSurface, SciChartJSLightTheme, SciChartJSDarkv2Theme, XyDataSeries, FastLineRenderableSeries, SplineLineRenderableSeries, FastColumnRenderableSeries, StackedColumnRenderableSeries, StackedMountainRenderableSeries, StackedColumnCollection, StackedMountainCollection, NumericAxis, DateTimeNumericAxis, EAutoRange, EAxisAlignment, ECoordinateMode, EHorizontalAnchorPoint, EVerticalAnchorPoint, NumberRange, MouseWheelZoomModifier, ZoomPanModifier, ZoomExtentsModifier, RolloverModifier, SmartDateLabelProvider, EllipsePointMarker, SquarePointMarker, TrianglePointMarker, CrossPointMarker, XPointMarker, WaveAnimation, LegendModifier, ELegendPlacement, EXyDirection, XAxisDragModifier, YAxisDragModifier, TextAnnotation, LineAnnotation, BoxAnnotation, HorizontalLineAnnotation, VerticalLineAnnotation } from 'scichart';
|
2
|
+
import { SciChartSurface, SciChartJSLightTheme, SciChartJSDarkv2Theme, XyDataSeries, FastLineRenderableSeries, SplineLineRenderableSeries, FastColumnRenderableSeries, StackedColumnRenderableSeries, StackedMountainRenderableSeries, StackedColumnCollection, StackedMountainCollection, NumericAxis, DateTimeNumericAxis, EAutoRange, EAxisAlignment, EExecuteOn, ECoordinateMode, EHorizontalAnchorPoint, EVerticalAnchorPoint, NumberRange, MouseWheelZoomModifier, RubberBandXyZoomModifier, ZoomPanModifier, ZoomExtentsModifier, RolloverModifier, SmartDateLabelProvider, EllipsePointMarker, SquarePointMarker, TrianglePointMarker, CrossPointMarker, XPointMarker, WaveAnimation, LegendModifier, ELegendPlacement, EXyDirection, XAxisDragModifier, YAxisDragModifier, TextAnnotation, LineAnnotation, BoxAnnotation, HorizontalLineAnnotation, VerticalLineAnnotation, OverviewRangeSelectionModifier, ENumericFormat } from 'scichart';
|
3
3
|
SciChartSurface.UseCommunityLicense();
|
4
4
|
SciChartSurface.configure({
|
5
5
|
dataUrl: `/node_modules/scichart/_wasm/scichart2d.data`,
|
@@ -10,6 +10,10 @@ const DEFAULT_STROKE = '#000000';
|
|
10
10
|
const POINT_MARKER_SIZE = 10;
|
11
11
|
const STROKE_THICKNESS = 2;
|
12
12
|
const ANIMATION_DURATION = 1000;
|
13
|
+
function getLocalTimeOffset() {
|
14
|
+
const now = new Date();
|
15
|
+
return now.getTimezoneOffset() * -60;
|
16
|
+
}
|
13
17
|
function getBaseColorFromTheme(theme) {
|
14
18
|
return new TinyColor(theme == 'dark' ? '#fff' : '#000');
|
15
19
|
}
|
@@ -45,7 +49,7 @@ function createPointMarker(wasmContext, dataset, color = DEFAULT_COLOR) {
|
|
45
49
|
return new EllipsePointMarker(wasmContext, pointMarkerOptions);
|
46
50
|
}
|
47
51
|
}
|
48
|
-
function createAxis(wasmContext, axis, index, isXAxis, fontColor, fontFamily, fontSize) {
|
52
|
+
function createAxis(wasmContext, axis, index, isXAxis, fontColor, fontFamily, fontSize, options) {
|
49
53
|
const { axisTitle, ticks } = axis;
|
50
54
|
const { autoMax, autoMin, min, max, stepSize, beginAtZero, color = fontColor, textStrokeColor = fontColor } = ticks || {};
|
51
55
|
const axisOptions = {
|
@@ -64,10 +68,21 @@ function createAxis(wasmContext, axis, index, isXAxis, fontColor, fontFamily, fo
|
|
64
68
|
fontFamily,
|
65
69
|
fontSize,
|
66
70
|
color: textStrokeColor
|
67
|
-
}
|
71
|
+
},
|
72
|
+
...options
|
68
73
|
};
|
74
|
+
const labelProvider = new SmartDateLabelProvider({
|
75
|
+
labelFormat: ENumericFormat.Date_HHMMSS,
|
76
|
+
showWiderDateOnFirstLabel: true,
|
77
|
+
showYearOnWiderDate: true,
|
78
|
+
dateOffset: getLocalTimeOffset()
|
79
|
+
});
|
80
|
+
labelProvider.cursorNumericFormat = ENumericFormat.Date_DDMMHHMM;
|
69
81
|
return isXAxis
|
70
|
-
? new DateTimeNumericAxis(wasmContext, {
|
82
|
+
? new DateTimeNumericAxis(wasmContext, {
|
83
|
+
...axisOptions,
|
84
|
+
labelProvider
|
85
|
+
})
|
71
86
|
: new NumericAxis(wasmContext, { ...axisOptions, id: index !== 0 ? `yAxis${index}` : undefined });
|
72
87
|
}
|
73
88
|
function createSeries(wasmContext, dataset, index, stacked, animation, yAxisId) {
|
@@ -125,12 +140,15 @@ function createSeries(wasmContext, dataset, index, stacked, animation, yAxisId)
|
|
125
140
|
}
|
126
141
|
return { series, dataSeries };
|
127
142
|
}
|
128
|
-
export async function buildSciChart(config, container, { fontSize, fontFamily, fontColor }) {
|
143
|
+
export async function buildSciChart(config, container, { fontSize = 14, fontFamily = 'Roboto', fontColor }, grouped) {
|
129
144
|
if (!config)
|
130
145
|
return;
|
131
146
|
const { type: chartType, options, data: fromData } = config;
|
132
147
|
const { datasets = [] } = fromData || {};
|
133
|
-
var { theme, tooltip
|
148
|
+
var { theme, tooltip = true, animation = true, legend = {
|
149
|
+
display: true,
|
150
|
+
position: 'top'
|
151
|
+
}, scales: fromScales, xGridLine = true, yGridLine = true, y2ndGridLine = false, stacked = false, multiAxis = false, annotations = [] } = options || {};
|
134
152
|
var baseColor = getBaseColorFromTheme(theme);
|
135
153
|
if (theme === 'auto') {
|
136
154
|
theme = getThemeFromBrowser();
|
@@ -158,7 +176,8 @@ export async function buildSciChart(config, container, { fontSize, fontFamily, f
|
|
158
176
|
if (tooltip) {
|
159
177
|
const rolloverModifier = new RolloverModifier({
|
160
178
|
showTooltip: true,
|
161
|
-
showAxisLabel: true
|
179
|
+
showAxisLabel: true,
|
180
|
+
modifierGroup: grouped
|
162
181
|
});
|
163
182
|
sciChartSurface.chartModifiers.add(rolloverModifier);
|
164
183
|
}
|
@@ -206,7 +225,9 @@ export async function buildSciChart(config, container, { fontSize, fontFamily, f
|
|
206
225
|
verticalAnchorPoint,
|
207
226
|
fontSize: annotation.fontSize,
|
208
227
|
fontFamily: annotation.fontFamily,
|
209
|
-
textColor: convertColor(annotation.stroke, fontColor)
|
228
|
+
textColor: convertColor(annotation.stroke, fontColor),
|
229
|
+
xCoordinateMode: (annotation.xCoordinateMode || ECoordinateMode.DataValue),
|
230
|
+
yCoordinateMode: (annotation.yCoordinateMode || ECoordinateMode.DataValue)
|
210
231
|
});
|
211
232
|
break;
|
212
233
|
case 'line':
|
@@ -217,8 +238,8 @@ export async function buildSciChart(config, container, { fontSize, fontFamily, f
|
|
217
238
|
y2: annotation.y2,
|
218
239
|
stroke: convertColor(annotation.stroke, '#FF0000'),
|
219
240
|
strokeThickness: annotation.strokeThickness,
|
220
|
-
xCoordinateMode: ECoordinateMode.
|
221
|
-
yCoordinateMode: ECoordinateMode.DataValue
|
241
|
+
xCoordinateMode: (annotation.xCoordinateMode || ECoordinateMode.DataValue),
|
242
|
+
yCoordinateMode: (annotation.yCoordinateMode || ECoordinateMode.DataValue)
|
222
243
|
});
|
223
244
|
break;
|
224
245
|
case 'box':
|
@@ -229,21 +250,27 @@ export async function buildSciChart(config, container, { fontSize, fontFamily, f
|
|
229
250
|
y2: annotation.y2,
|
230
251
|
fill: convertColor(annotation.fill, '#FF0000'),
|
231
252
|
stroke: convertColor(annotation.stroke, '#FF0000'),
|
232
|
-
strokeThickness: annotation.strokeThickness
|
253
|
+
strokeThickness: annotation.strokeThickness,
|
254
|
+
xCoordinateMode: (annotation.xCoordinateMode || ECoordinateMode.DataValue),
|
255
|
+
yCoordinateMode: (annotation.yCoordinateMode || ECoordinateMode.DataValue)
|
233
256
|
});
|
234
257
|
break;
|
235
258
|
case 'horizontalLine':
|
236
259
|
sciAnnotation = new HorizontalLineAnnotation({
|
237
260
|
y1: annotation.y1,
|
238
261
|
stroke: convertColor(annotation.stroke, '#FF0000'),
|
239
|
-
strokeThickness: annotation.strokeThickness
|
262
|
+
strokeThickness: annotation.strokeThickness,
|
263
|
+
xCoordinateMode: (annotation.xCoordinateMode || ECoordinateMode.DataValue),
|
264
|
+
yCoordinateMode: (annotation.yCoordinateMode || ECoordinateMode.DataValue)
|
240
265
|
});
|
241
266
|
break;
|
242
267
|
case 'verticalLine':
|
243
268
|
sciAnnotation = new VerticalLineAnnotation({
|
244
269
|
x1: annotation.x1,
|
245
270
|
stroke: convertColor(annotation.stroke, '#FF0000'),
|
246
|
-
strokeThickness: annotation.strokeThickness
|
271
|
+
strokeThickness: annotation.strokeThickness,
|
272
|
+
xCoordinateMode: (annotation.xCoordinateMode || ECoordinateMode.DataValue),
|
273
|
+
yCoordinateMode: (annotation.yCoordinateMode || ECoordinateMode.DataValue)
|
247
274
|
});
|
248
275
|
break;
|
249
276
|
default:
|
@@ -255,8 +282,7 @@ export async function buildSciChart(config, container, { fontSize, fontFamily, f
|
|
255
282
|
});
|
256
283
|
}
|
257
284
|
// 줌인/줌아웃 모디파이어 추가
|
258
|
-
sciChartSurface.chartModifiers.add(
|
259
|
-
// new RubberBandXyZoomModifier(),
|
285
|
+
sciChartSurface.chartModifiers.add(new RubberBandXyZoomModifier({ executeOn: EExecuteOn.MouseRightButton, modifierGroup: grouped }),
|
260
286
|
// new ZoomPanModifier({ xyDirection: EXyDirection.XDirection }),
|
261
287
|
new ZoomPanModifier(), new MouseWheelZoomModifier({ xyDirection: EXyDirection.XDirection }), new ZoomExtentsModifier(), new XAxisDragModifier(), new YAxisDragModifier());
|
262
288
|
if (legend === null || legend === void 0 ? void 0 : legend.display) {
|
@@ -276,4 +302,61 @@ export async function buildSciChart(config, container, { fontSize, fontFamily, f
|
|
276
302
|
}
|
277
303
|
return { chart, dataSeries: dataSeriesArray };
|
278
304
|
}
|
305
|
+
export async function buildSciChartOverview(config, container, { fontSize = 14, fontFamily = 'Roboto', fontColor }, axisSynchroniser) {
|
306
|
+
if (!config)
|
307
|
+
return;
|
308
|
+
const { type: chartType, options, data: fromData } = config;
|
309
|
+
const { datasets = [] } = fromData || {};
|
310
|
+
var { theme, animation, scales: fromScales, stacked, multiAxis } = options || {};
|
311
|
+
var baseColor = getBaseColorFromTheme(theme);
|
312
|
+
if (theme === 'auto') {
|
313
|
+
theme = getThemeFromBrowser();
|
314
|
+
}
|
315
|
+
fontColor = fontColor || baseColor.clone().toString();
|
316
|
+
const { xAxes = [], yAxes = [] } = fromScales || {};
|
317
|
+
// Instead we create a normal chart and then manually add the OverviewRangeSelectionModifier and bind it to the axisSynchroniser
|
318
|
+
const chart = await SciChartSurface.create(container, {
|
319
|
+
theme: theme == 'dark' ? new SciChartJSDarkv2Theme() : new SciChartJSLightTheme()
|
320
|
+
});
|
321
|
+
const { sciChartSurface, wasmContext } = chart;
|
322
|
+
// X 축 설정
|
323
|
+
xAxes.forEach((axis, index) => {
|
324
|
+
const xAxis = createAxis(wasmContext, axis, index, true, fontColor, fontFamily, fontSize);
|
325
|
+
sciChartSurface.xAxes.add(xAxis);
|
326
|
+
});
|
327
|
+
(multiAxis ? yAxes : [yAxes[0]]).forEach((axis, index) => {
|
328
|
+
const yAxis = createAxis(wasmContext, axis, index, false, fontColor, fontFamily, fontSize, {
|
329
|
+
drawLabels: false,
|
330
|
+
drawMajorTicks: false,
|
331
|
+
drawMinorTicks: false,
|
332
|
+
drawMajorGridLines: false,
|
333
|
+
drawMinorGridLines: false
|
334
|
+
});
|
335
|
+
sciChartSurface.yAxes.add(yAxis);
|
336
|
+
});
|
337
|
+
const rangeSelectionModifier = new OverviewRangeSelectionModifier();
|
338
|
+
// When the range selection is moved, updated the linked charts
|
339
|
+
rangeSelectionModifier.onSelectedAreaChanged = (selectedRange) => {
|
340
|
+
if (!selectedRange.equals(axisSynchroniser.visibleRange)) {
|
341
|
+
axisSynchroniser.publishChange({ visibleRange: selectedRange });
|
342
|
+
}
|
343
|
+
};
|
344
|
+
rangeSelectionModifier.selectedArea = axisSynchroniser.visibleRange;
|
345
|
+
sciChartSurface.chartModifiers.add(rangeSelectionModifier);
|
346
|
+
// When charts are moved, update the range selection
|
347
|
+
axisSynchroniser.visibleRangeChanged.subscribe(({ visibleRange }) => {
|
348
|
+
const updatedSelectedRange = visibleRange.clip(sciChartSurface.xAxes.get(0).visibleRange);
|
349
|
+
const shouldUpdateSelectedRange = !updatedSelectedRange.equals(rangeSelectionModifier.selectedArea);
|
350
|
+
if (shouldUpdateSelectedRange) {
|
351
|
+
rangeSelectionModifier.selectedArea = updatedSelectedRange;
|
352
|
+
}
|
353
|
+
});
|
354
|
+
const dataSeriesArray = datasets.map((dataset, index) => {
|
355
|
+
const yAxisId = dataset.yAxisID == 'right' && multiAxis ? 'yAxis1' : undefined;
|
356
|
+
const { series, dataSeries } = createSeries(wasmContext, dataset, index, !!stacked, !!animation, yAxisId);
|
357
|
+
sciChartSurface.renderableSeries.add(series);
|
358
|
+
return dataSeries;
|
359
|
+
});
|
360
|
+
return { chart, dataSeries: dataSeriesArray };
|
361
|
+
}
|
279
362
|
//# sourceMappingURL=scichart-builder.js.map
|