@operato/scene-chartjs 0.0.5
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/CHANGELOG.md +17 -0
- package/LICENSE +21 -0
- package/README.md +21 -0
- package/assets/bar-chart.png +0 -0
- package/assets/doughnut-chart.png +0 -0
- package/assets/horizontal-bar-chart.png +0 -0
- package/assets/line-chart.png +0 -0
- package/assets/mixed-chart.png +0 -0
- package/assets/pie-chart.png +0 -0
- package/assets/polar-area-chart.png +0 -0
- package/assets/radar-chart.png +0 -0
- package/demo/bar.html +266 -0
- package/demo/chartjs.html +73 -0
- package/demo/index.html +547 -0
- package/demo/legend.html +267 -0
- package/demo/things-scene-chartjs.html +7 -0
- package/dist/chartjs.d.ts +27 -0
- package/dist/chartjs.js +109 -0
- package/dist/chartjs.js.map +1 -0
- package/dist/config-converter.d.ts +1 -0
- package/dist/config-converter.js +343 -0
- package/dist/config-converter.js.map +1 -0
- package/dist/editors/index.d.ts +5 -0
- package/dist/editors/index.js +11 -0
- package/dist/editors/index.js.map +1 -0
- package/dist/editors/property-editor-chartjs-abstract.d.ts +44 -0
- package/dist/editors/property-editor-chartjs-abstract.js +250 -0
- package/dist/editors/property-editor-chartjs-abstract.js.map +1 -0
- package/dist/editors/property-editor-chartjs-hbar.d.ts +9 -0
- package/dist/editors/property-editor-chartjs-hbar.js +160 -0
- package/dist/editors/property-editor-chartjs-hbar.js.map +1 -0
- package/dist/editors/property-editor-chartjs-mixed.d.ts +20 -0
- package/dist/editors/property-editor-chartjs-mixed.js +193 -0
- package/dist/editors/property-editor-chartjs-mixed.js.map +1 -0
- package/dist/editors/property-editor-chartjs-multi-series-abstract.d.ts +31 -0
- package/dist/editors/property-editor-chartjs-multi-series-abstract.js +373 -0
- package/dist/editors/property-editor-chartjs-multi-series-abstract.js.map +1 -0
- package/dist/editors/property-editor-chartjs-pie.d.ts +14 -0
- package/dist/editors/property-editor-chartjs-pie.js +70 -0
- package/dist/editors/property-editor-chartjs-pie.js.map +1 -0
- package/dist/editors/property-editor-chartjs-radar.d.ts +10 -0
- package/dist/editors/property-editor-chartjs-radar.js +42 -0
- package/dist/editors/property-editor-chartjs-radar.js.map +1 -0
- package/dist/editors/property-editor-chartjs-styles.d.ts +1 -0
- package/dist/editors/property-editor-chartjs-styles.js +165 -0
- package/dist/editors/property-editor-chartjs-styles.js.map +1 -0
- package/dist/editors/property-editor-chartjs.d.ts +14 -0
- package/dist/editors/property-editor-chartjs.js +83 -0
- package/dist/editors/property-editor-chartjs.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/ox-chart.d.ts +20 -0
- package/dist/ox-chart.js +137 -0
- package/dist/ox-chart.js.map +1 -0
- package/dist/plugins/chart-series-highlight.d.ts +5 -0
- package/dist/plugins/chart-series-highlight.js +37 -0
- package/dist/plugins/chart-series-highlight.js.map +1 -0
- package/dist/plugins/chartjs-plugin-data-binder.d.ts +5 -0
- package/dist/plugins/chartjs-plugin-data-binder.js +111 -0
- package/dist/plugins/chartjs-plugin-data-binder.js.map +1 -0
- package/helps/scene/component/chartjs.ko.md +332 -0
- package/helps/scene/component/chartjs.md +333 -0
- package/helps/scene/component/chartjs.zh.md +331 -0
- package/helps/scene/images/chart-bar-01.png +0 -0
- package/helps/scene/images/chart-bar-02.png +0 -0
- package/helps/scene/images/chart-bar-03.png +0 -0
- package/helps/scene/images/chart-bar-08.png +0 -0
- package/helps/scene/images/chart-bar-12.png +0 -0
- package/helps/scene/images/chart-data-01.png +0 -0
- package/helps/scene/images/chart-data-04.png +0 -0
- package/helps/scene/images/chart-doughnut-01.png +0 -0
- package/helps/scene/images/chart-horizontal-bar-01.png +0 -0
- package/helps/scene/images/chart-line-01.png +0 -0
- package/helps/scene/images/chart-mix-01.png +0 -0
- package/helps/scene/images/chart-mix-02.png +0 -0
- package/helps/scene/images/chart-pie-01.png +0 -0
- package/helps/scene/images/chart-polar-01.png +0 -0
- package/helps/scene/images/chart-radar-01.png +0 -0
- package/package.json +78 -0
- package/src/chartjs.ts +134 -0
- package/src/config-converter.ts +401 -0
- package/src/editors/index.ts +11 -0
- package/src/editors/property-editor-chartjs-abstract.ts +301 -0
- package/src/editors/property-editor-chartjs-hbar.ts +163 -0
- package/src/editors/property-editor-chartjs-mixed.ts +204 -0
- package/src/editors/property-editor-chartjs-multi-series-abstract.ts +393 -0
- package/src/editors/property-editor-chartjs-pie.ts +79 -0
- package/src/editors/property-editor-chartjs-radar.ts +43 -0
- package/src/editors/property-editor-chartjs-styles.ts +165 -0
- package/src/editors/property-editor-chartjs.ts +88 -0
- package/src/index.ts +7 -0
- package/src/ox-chart.ts +150 -0
- package/src/plugins/chart-series-highlight.ts +43 -0
- package/src/plugins/chartjs-plugin-data-binder.ts +138 -0
- package/src/scene-chart.d.ts +152 -0
- package/templates/bar-chart.js +124 -0
- package/templates/doughnut-chart.js +58 -0
- package/templates/horizontal-bar-chart.js +121 -0
- package/templates/index.js +22 -0
- package/templates/line-chart.js +155 -0
- package/templates/mixed-chart.js +152 -0
- package/templates/pie-chart.js +58 -0
- package/templates/polar-area-chart.js +92 -0
- package/templates/radar-chart.js +98 -0
- package/test/basic-test.html +61 -0
- package/test/index.html +20 -0
- package/things-scene.config.js +7 -0
- package/translations/en.json +5 -0
- package/translations/ko.json +5 -0
- package/translations/ms.json +5 -0
- package/translations/zh.json +5 -0
- package/tsconfig.json +22 -0
- package/tsconfig.tsbuildinfo +1 -0
package/demo/legend.html
ADDED
@@ -0,0 +1,267 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<!--
|
3
|
+
@license
|
4
|
+
Copyright © HatioLab Inc. All rights reserved.
|
5
|
+
-->
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<meta charset="utf-8">
|
9
|
+
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
|
10
|
+
<title>things-scene-chartjs Demo</title>
|
11
|
+
<script src="../bower_components/webcomponentsjs/webcomponents-lite.min.js"></script>
|
12
|
+
|
13
|
+
<link rel="import" href="../bower_components/things-scene-viewer/things-scene-viewer.html">
|
14
|
+
<link rel="import" href="../bower_components/things-scene-viewer/things-scene-layer.html">
|
15
|
+
<link rel="import" href="../bower_components/things-scene-viewer/things-scene-handler.html">
|
16
|
+
<link rel="import" href="../bower_components/things-designer-elements/elements.html">
|
17
|
+
<link rel="import" href="../bower_components/things-scene-modeler/things-scene-properties.html">
|
18
|
+
|
19
|
+
<link rel="import" href="./things-scene-chartjs.html">
|
20
|
+
|
21
|
+
<style is="custom-style">
|
22
|
+
|
23
|
+
@font-face {
|
24
|
+
font-family: "Bitstream Vera Serif Bold";
|
25
|
+
src: url("fonts/VeraSeBd.ttf");
|
26
|
+
}
|
27
|
+
|
28
|
+
things-scene-viewer {
|
29
|
+
display: block;
|
30
|
+
width: 640px;
|
31
|
+
height: 480px;
|
32
|
+
}
|
33
|
+
</style>
|
34
|
+
</head>
|
35
|
+
<body unresolved>
|
36
|
+
|
37
|
+
<template is="dom-bind" id="app">
|
38
|
+
<p>An example of <code><things-scene-chartjs></code>:</p>
|
39
|
+
|
40
|
+
<things-scene-viewer id='scene' scene='{{scene}}' model='[[model]]' selected='{{selected}}'>
|
41
|
+
<things-scene-layer type="selection-layer"></things-scene-layer>
|
42
|
+
<things-scene-layer type="modeling-layer"></things-scene-layer>
|
43
|
+
<things-scene-handler type="text-editor"></things-scene-handler>
|
44
|
+
<things-scene-handler type="move-handler"></things-scene-handler>
|
45
|
+
</things-scene-viewer>
|
46
|
+
|
47
|
+
<button id="change">Change Value</button>
|
48
|
+
<button id="change-model">Change Model</button>
|
49
|
+
<fieldset>
|
50
|
+
<legend>Chart.js properties</legend>
|
51
|
+
<things-scene-properties id="properties"
|
52
|
+
scene="[[scene]]"
|
53
|
+
selected="[[selected]]"
|
54
|
+
model="{{target}}"
|
55
|
+
bounds="{{bounds}}"
|
56
|
+
props="{{props}}">
|
57
|
+
<things-editor-properties id="properties"
|
58
|
+
target="{{target}}"
|
59
|
+
props="{{props}}">
|
60
|
+
</things-editor-properties>
|
61
|
+
</things-scene-properties>
|
62
|
+
</fieldset>
|
63
|
+
|
64
|
+
</template>
|
65
|
+
<canvas id="chartCanvas" width="300" height="300">
|
66
|
+
</canvas>
|
67
|
+
<script>
|
68
|
+
window.addEventListener('WebComponentsReady', function(e) {
|
69
|
+
var app = document.querySelector('#app')
|
70
|
+
|
71
|
+
app.$.change.addEventListener('click', function() {
|
72
|
+
var viewer = app.$.scene
|
73
|
+
|
74
|
+
app.selected[0].set('data', [
|
75
|
+
{
|
76
|
+
"date": "2016-11-10",
|
77
|
+
"inQty": "712882",
|
78
|
+
"badQty": "0"
|
79
|
+
},
|
80
|
+
{
|
81
|
+
"date": "2016-11-11",
|
82
|
+
"inQty": "526234",
|
83
|
+
"badQty": "0"
|
84
|
+
},
|
85
|
+
{
|
86
|
+
"date": "2016-11-12",
|
87
|
+
"inQty": "701163",
|
88
|
+
"badQty": "8837"
|
89
|
+
}
|
90
|
+
])
|
91
|
+
})
|
92
|
+
app.$['change-model'].addEventListener('click', function() {
|
93
|
+
var viewer = app.$.scene
|
94
|
+
|
95
|
+
var selected = app.selected[0]
|
96
|
+
var chartModel = JSON.parse(JSON.stringify(selected.model.chart))
|
97
|
+
chartModel.data.datasets.push({
|
98
|
+
label:'add',
|
99
|
+
backgroundColor: 'red',
|
100
|
+
data: []
|
101
|
+
})
|
102
|
+
|
103
|
+
selected.set('chart', chartModel)
|
104
|
+
})
|
105
|
+
|
106
|
+
app.$.properties.addEventListener('change', function(e) {
|
107
|
+
console.log('change', e, app.$.properties.model)
|
108
|
+
})
|
109
|
+
|
110
|
+
Chart.defaults.global.tooltips.mode = 'label';
|
111
|
+
|
112
|
+
app.props = [{
|
113
|
+
type: 'number',
|
114
|
+
label: 'Font Size',
|
115
|
+
name: 'chart.options.fontSize',
|
116
|
+
property: 'number'
|
117
|
+
},{
|
118
|
+
type: 'number',
|
119
|
+
label: 'Width',
|
120
|
+
name: 'width',
|
121
|
+
property: 'number'
|
122
|
+
}, {
|
123
|
+
type: 'number',
|
124
|
+
label: 'Height',
|
125
|
+
name: 'height',
|
126
|
+
property: 'number'
|
127
|
+
}, {
|
128
|
+
type: 'number',
|
129
|
+
label: 'Tension',
|
130
|
+
name: 'chart.data.datasets.0.lineTension',
|
131
|
+
property: 'number'
|
132
|
+
}, {
|
133
|
+
type: 'color',
|
134
|
+
label: 'Border Color',
|
135
|
+
name: 'chart.data.datasets.0.borderColor',
|
136
|
+
property: 'color'
|
137
|
+
}, {
|
138
|
+
type: 'multiple-color',
|
139
|
+
label: 'Background Color',
|
140
|
+
name: 'chart.data.datasets.0.backgroundColor',
|
141
|
+
property: {
|
142
|
+
colorType: 'array'
|
143
|
+
}
|
144
|
+
}, {
|
145
|
+
type: 'number',
|
146
|
+
label: 'Border Width',
|
147
|
+
name: 'chart.data.datasets.0.borderWidth',
|
148
|
+
property: 'number'
|
149
|
+
}, {
|
150
|
+
type: 'color',
|
151
|
+
label: 'Point Border Color',
|
152
|
+
name: 'chart.data.datasets.0.pointBorderColor',
|
153
|
+
property: 'color'
|
154
|
+
}, {
|
155
|
+
type: 'color',
|
156
|
+
label: 'Point Background Color',
|
157
|
+
name: 'chart.data.datasets.0.pointBackgroundColor',
|
158
|
+
property: 'color'
|
159
|
+
}, {
|
160
|
+
type: 'number',
|
161
|
+
label: 'Point Border Width',
|
162
|
+
name: 'chart.data.datasets.0.pointBorderWidth',
|
163
|
+
property: 'number'
|
164
|
+
}, {
|
165
|
+
type: 'checkbox',
|
166
|
+
label: 'Fill',
|
167
|
+
name: 'chart.data.datasets.0.fill',
|
168
|
+
property: 'checkbox'
|
169
|
+
}, {
|
170
|
+
type: 'checkbox',
|
171
|
+
label: 'X Axis Grid Line',
|
172
|
+
name: 'chart.options.scales.xAxes.0.gridLines.display',
|
173
|
+
property: 'checkbox'
|
174
|
+
}, {
|
175
|
+
type: 'string',
|
176
|
+
label: 'Theme',
|
177
|
+
name: 'chart.options.theme',
|
178
|
+
property: 'string'
|
179
|
+
}, {
|
180
|
+
type: 'checkbox',
|
181
|
+
label: 'Show Legend',
|
182
|
+
name: 'chart.options.legend.display',
|
183
|
+
property: 'checkbox'
|
184
|
+
}, {
|
185
|
+
type: 'string',
|
186
|
+
label: 'Legend Position',
|
187
|
+
name: 'chart.options.legend.position',
|
188
|
+
property: 'string'
|
189
|
+
}, {
|
190
|
+
type: 'checkbox',
|
191
|
+
label: 'is Stacked',
|
192
|
+
name: 'chart.options.stacked',
|
193
|
+
property: 'checkbox'
|
194
|
+
}, {
|
195
|
+
type: 'checkbox',
|
196
|
+
label: 'Multi Axis',
|
197
|
+
name: 'chart.options.multiAxis',
|
198
|
+
property: 'checkbox'
|
199
|
+
}]
|
200
|
+
|
201
|
+
app.model = {
|
202
|
+
width: 500,
|
203
|
+
height: 500,
|
204
|
+
components: [{
|
205
|
+
type: 'chartjs',
|
206
|
+
top: 50,
|
207
|
+
left: 50,
|
208
|
+
width: 400,
|
209
|
+
height: 400,
|
210
|
+
fontColor: '#FF0000',
|
211
|
+
lineWidth: 5,
|
212
|
+
chart: {
|
213
|
+
type: 'bar',
|
214
|
+
data: {
|
215
|
+
labels: [],
|
216
|
+
datasets: [{
|
217
|
+
type: 'line',
|
218
|
+
label: 'Line Dataset',
|
219
|
+
yAxisID: 'left',
|
220
|
+
borderColor: 'red',
|
221
|
+
fill: false,
|
222
|
+
data: []
|
223
|
+
}, {
|
224
|
+
type: 'bar',
|
225
|
+
label: 'Bar Dataset',
|
226
|
+
yAxisID: 'right',
|
227
|
+
borderColor: 'blue',
|
228
|
+
backgroundColor: 'blue',
|
229
|
+
data: []
|
230
|
+
}]
|
231
|
+
},
|
232
|
+
options: {
|
233
|
+
multiAxis: true,
|
234
|
+
legend: {
|
235
|
+
display: true,
|
236
|
+
position: 'top'
|
237
|
+
},
|
238
|
+
scales: {
|
239
|
+
xAxes: [{
|
240
|
+
position: 'bottom',
|
241
|
+
gridLines: {
|
242
|
+
display: true
|
243
|
+
}
|
244
|
+
}],
|
245
|
+
yAxes: [{
|
246
|
+
position: 'left',
|
247
|
+
id: 'left'
|
248
|
+
}, {
|
249
|
+
position: 'right',
|
250
|
+
id: 'right'
|
251
|
+
}]
|
252
|
+
}
|
253
|
+
}
|
254
|
+
},
|
255
|
+
data : {
|
256
|
+
seriesData : [
|
257
|
+
[0, 10, 5, 3, 6],
|
258
|
+
[100, 10, 60, 30, 50]
|
259
|
+
],
|
260
|
+
labelData : ['a', 'b', 'c', 'd', 'e' ]
|
261
|
+
}
|
262
|
+
}]
|
263
|
+
}
|
264
|
+
});
|
265
|
+
</script>
|
266
|
+
</body>
|
267
|
+
</html>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<!--
|
2
|
+
@license
|
3
|
+
Copyright © HatioLab Inc. All rights reserved.
|
4
|
+
-->
|
5
|
+
<script src="../bower_components/Chart.JS/dist/Chart.js"></script>
|
6
|
+
<script src="../bower_components/TinyColor/dist/tinycolor-min.js"></script>
|
7
|
+
<script src="../things-scene-chartjs.js"></script>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import './ox-chart';
|
2
|
+
import { HTMLOverlayElement, Properties } from '@hatiolab/things-scene';
|
3
|
+
import { OxChart } from './ox-chart';
|
4
|
+
export default class ChartJS extends HTMLOverlayElement {
|
5
|
+
private _isChartChanged;
|
6
|
+
private _isDataChanged;
|
7
|
+
get nature(): {
|
8
|
+
mutable: boolean;
|
9
|
+
resizable: boolean;
|
10
|
+
rotatable: boolean;
|
11
|
+
properties: {
|
12
|
+
type: string;
|
13
|
+
label: string;
|
14
|
+
name: string;
|
15
|
+
}[];
|
16
|
+
'value-property': string;
|
17
|
+
help: string;
|
18
|
+
};
|
19
|
+
get hasTextProperty(): boolean;
|
20
|
+
get tagName(): string;
|
21
|
+
isShadowable(): boolean;
|
22
|
+
createElement(): void;
|
23
|
+
setElementProperties(element: OxChart): void;
|
24
|
+
_setChartConfig(element: OxChart): void;
|
25
|
+
onchange(after: Properties, before: Properties): void;
|
26
|
+
onchangeData(data: any): void;
|
27
|
+
}
|
package/dist/chartjs.js
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
import './ox-chart';
|
2
|
+
/*
|
3
|
+
* Copyright © HatioLab Inc. All rights reserved.
|
4
|
+
*/
|
5
|
+
import { Component, HTMLOverlayElement, error } from '@hatiolab/things-scene';
|
6
|
+
import cloneDeep from 'lodash/cloneDeep';
|
7
|
+
const NATURE = {
|
8
|
+
mutable: false,
|
9
|
+
resizable: true,
|
10
|
+
rotatable: true,
|
11
|
+
properties: [
|
12
|
+
{
|
13
|
+
type: 'chartjs',
|
14
|
+
label: '',
|
15
|
+
name: 'chart'
|
16
|
+
}
|
17
|
+
],
|
18
|
+
'value-property': 'data',
|
19
|
+
help: 'scene/component/chartjs'
|
20
|
+
};
|
21
|
+
export default class ChartJS extends HTMLOverlayElement {
|
22
|
+
constructor() {
|
23
|
+
super(...arguments);
|
24
|
+
this._isChartChanged = false;
|
25
|
+
this._isDataChanged = false;
|
26
|
+
}
|
27
|
+
get nature() {
|
28
|
+
return NATURE;
|
29
|
+
}
|
30
|
+
get hasTextProperty() {
|
31
|
+
return false;
|
32
|
+
}
|
33
|
+
get tagName() {
|
34
|
+
return 'ox-chart';
|
35
|
+
}
|
36
|
+
isShadowable() {
|
37
|
+
return false;
|
38
|
+
}
|
39
|
+
createElement() {
|
40
|
+
super.createElement();
|
41
|
+
var { width, height } = this.bounds;
|
42
|
+
var element = this.element;
|
43
|
+
var data = this.data;
|
44
|
+
element.width = width;
|
45
|
+
element.height = height;
|
46
|
+
this._setChartConfig(element);
|
47
|
+
element.data = data;
|
48
|
+
}
|
49
|
+
/* component.property => element.property */
|
50
|
+
setElementProperties(element) {
|
51
|
+
this.set('lineWidth', 0); // border 표현이 자연스럽게 바뀌면 지울것.
|
52
|
+
var { chart: chartConfig } = this.state;
|
53
|
+
var { width, height } = this.bounds;
|
54
|
+
var data = this.data;
|
55
|
+
try {
|
56
|
+
element.width = width;
|
57
|
+
element.height = height;
|
58
|
+
if (chartConfig && this._isChartChanged) {
|
59
|
+
this._setChartConfig(element);
|
60
|
+
this._isChartChanged = false;
|
61
|
+
}
|
62
|
+
if (this._isDataChanged) {
|
63
|
+
element.data = data;
|
64
|
+
this._isDataChanged = false;
|
65
|
+
}
|
66
|
+
}
|
67
|
+
catch (e) {
|
68
|
+
error(e);
|
69
|
+
}
|
70
|
+
}
|
71
|
+
_setChartConfig(element) {
|
72
|
+
var { chart: chartConfig, fontSize = 12, fontFamily, fontColor, shadow } = this.state;
|
73
|
+
var { left = 0, top = 0, blurSize = 0, color = 'transparent' } = shadow || {};
|
74
|
+
const fontOption = {
|
75
|
+
defaultFontSize: fontSize,
|
76
|
+
defaultFontFamily: fontFamily,
|
77
|
+
defaultFontColor: fontColor
|
78
|
+
};
|
79
|
+
const shadowOption = {
|
80
|
+
shadowOffsetX: left,
|
81
|
+
shadowOffsetY: top,
|
82
|
+
shadowBlur: blurSize,
|
83
|
+
shadowColor: color
|
84
|
+
};
|
85
|
+
var cloneChartConf = cloneDeep(chartConfig);
|
86
|
+
cloneChartConf.options = {
|
87
|
+
...cloneChartConf.options,
|
88
|
+
...fontOption
|
89
|
+
};
|
90
|
+
cloneChartConf.data.datasets = cloneChartConf.data.datasets.map((dataset) => {
|
91
|
+
return {
|
92
|
+
...dataset,
|
93
|
+
...shadowOption
|
94
|
+
};
|
95
|
+
});
|
96
|
+
element.options = cloneChartConf;
|
97
|
+
}
|
98
|
+
onchange(after, before) {
|
99
|
+
this._isChartChanged = false;
|
100
|
+
if ('chart' in after || 'fontSize' in after || 'fontFamily' in after || 'fontColor' in after || 'shadow' in after)
|
101
|
+
this._isChartChanged = true;
|
102
|
+
super.onchange(after, before);
|
103
|
+
}
|
104
|
+
onchangeData(data) {
|
105
|
+
this._isDataChanged = true;
|
106
|
+
}
|
107
|
+
}
|
108
|
+
Component.register('chartjs', ChartJS);
|
109
|
+
//# sourceMappingURL=chartjs.js.map
|
@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,EAAE,IAAI;YACnB,aAAa,EAAE,GAAG;YAClB,UAAU,EAAE,QAAQ;YACpB,WAAW,EAAE,KAAK;SACnB,CAAA;QAED,IAAI,cAAc,GAAG,SAAS,CAAC,WAAW,CAAC,CAAA;QAE3C,cAAc,CAAC,OAAO,GAAG;YACvB,GAAG,cAAc,CAAC,OAAO;YACzB,GAAG,UAAU;SACd,CAAA;QAED,cAAc,CAAC,IAAI,CAAC,QAAQ,GAAG,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAY,EAAE,EAAE;YAC/E,OAAO;gBACL,GAAG,OAAO;gBACV,GAAG,YAAY;aAChB,CAAA;QACH,CAAC,CAAC,CAAA;QAEF,OAAO,CAAC,OAAO,GAAG,cAAc,CAAA;IAClC,CAAC;IAED,QAAQ,CAAC,KAAiB,EAAE,MAAkB;QAC5C,IAAI,CAAC,eAAe,GAAG,KAAK,CAAA;QAE5B,IAAI,OAAO,IAAI,KAAK,IAAI,UAAU,IAAI,KAAK,IAAI,YAAY,IAAI,KAAK,IAAI,WAAW,IAAI,KAAK,IAAI,QAAQ,IAAI,KAAK;YAC/G,IAAI,CAAC,eAAe,GAAG,IAAI,CAAA;QAE7B,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;IAC/B,CAAC;IAED,YAAY,CAAC,IAAS;QACpB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAA;IAC5B,CAAC;CACF;AAED,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA","sourcesContent":["import './ox-chart'\n\n/*\n * Copyright © HatioLab Inc. All rights reserved.\n */\nimport { Component, HTMLOverlayElement, Properties, error } from '@hatiolab/things-scene'\n\nimport { OxChart } from './ox-chart'\nimport cloneDeep from 'lodash/cloneDeep'\n\nconst NATURE = {\n mutable: false,\n resizable: true,\n rotatable: true,\n properties: [\n {\n type: 'chartjs',\n label: '',\n name: 'chart'\n }\n ],\n 'value-property': 'data',\n help: 'scene/component/chartjs'\n}\n\nexport default class ChartJS extends HTMLOverlayElement {\n private _isChartChanged = false\n private _isDataChanged = false\n\n get nature() {\n return NATURE\n }\n\n get hasTextProperty() {\n return false\n }\n\n get tagName() {\n return 'ox-chart'\n }\n\n isShadowable() {\n return false\n }\n\n createElement() {\n super.createElement()\n\n var { width, height } = this.bounds\n var element = this.element as OxChart\n var data = this.data\n\n element.width = width\n element.height = height\n\n this._setChartConfig(element)\n element.data = data\n }\n\n /* component.property => element.property */\n setElementProperties(element: OxChart) {\n this.set('lineWidth', 0) // border 표현이 자연스럽게 바뀌면 지울것.\n\n var { chart: chartConfig } = this.state\n var { width, height } = this.bounds\n var data = this.data\n\n try {\n element.width = width\n element.height = height\n\n if (chartConfig && this._isChartChanged) {\n this._setChartConfig(element)\n this._isChartChanged = false\n }\n\n if (this._isDataChanged) {\n element.data = data\n this._isDataChanged = false\n }\n } catch (e) {\n error(e)\n }\n }\n\n _setChartConfig(element: OxChart) {\n var { chart: chartConfig, fontSize = 12, fontFamily, fontColor, shadow } = this.state\n var { left = 0, top = 0, blurSize = 0, color = 'transparent' } = shadow || {}\n\n const fontOption = {\n defaultFontSize: fontSize,\n defaultFontFamily: fontFamily,\n defaultFontColor: fontColor\n }\n\n const shadowOption = {\n shadowOffsetX: left,\n shadowOffsetY: top,\n shadowBlur: blurSize,\n shadowColor: color\n }\n\n var cloneChartConf = cloneDeep(chartConfig)\n\n cloneChartConf.options = {\n ...cloneChartConf.options,\n ...fontOption\n }\n\n cloneChartConf.data.datasets = cloneChartConf.data.datasets.map((dataset: any) => {\n return {\n ...dataset,\n ...shadowOption\n }\n })\n\n element.options = cloneChartConf\n }\n\n onchange(after: Properties, before: Properties) {\n this._isChartChanged = false\n\n if ('chart' in after || 'fontSize' in after || 'fontFamily' in after || 'fontColor' in after || 'shadow' in after)\n this._isChartChanged = true\n\n super.onchange(after, before)\n }\n\n onchangeData(data: any) {\n this._isDataChanged = true\n }\n}\n\nComponent.register('chartjs', ChartJS)\n"]}
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare function convertConfigure(chart: SceneChart.ChartConfig): void;
|