-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy paththings-editor-chartjs-properties-pie.html
213 lines (182 loc) · 6.92 KB
/
things-editor-chartjs-properties-pie.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
<!DOCTYPE html>
<!--
@license
Copyright © HatioLab Inc. All rights reserved.
-->
<link rel="import" href="../../bower_components/polymer/polymer.html" />
<link rel="import" href="../../bower_components/paper-styles/paper-styles.html" />
<link rel="import" href="../../bower_components/iron-icons/editor-icons.html" />
<link rel="import" href="../../bower_components/iron-image/iron-image.html" />
<link rel="import" href="../../bower_components/things-designer-elements/things-editor-multiple-color.html" />
<link rel="import" href="../../bower_components/things-designer-elements/things-editor-number-input.html" />
<dom-module id="things-editor-chartjs-properties-pie">
<template>
<style>
:host {
@apply (--things-properties-panel);
}
label {
@apply (--things-label);
}
input {
@apply (--things-input);
}
fieldset {
@apply (--things-fieldset);
}
legend {
@apply (--things-fieldset-legend);
}
select {
@apply (--things-select);
background: url(/images/bg-input-select.png) 100% 50% no-repeat #fff;
}
things-editor-script {
width: 94%;
height: 300px;
margin: 0 0 7px 7px;
overflow: auto;
}
paper-tabs {
width: 229px;
height: 25px;
margin: -5px 0 0 7px;
border: 1px solid rgba(0, 0, 0, 0.2);
border-width: 1px 1px 0 1px;
}
paper-tabs::shadow #selectionBar.paper-tabs {
background-color: transparent;
}
paper-tab {
background-color: rgba(0, 0, 0, 0.2);
border: 1px solid rgba(0, 0, 0, 0.07);
border-width: 0 1px 0 0;
padding: 0 5px;
color: #fff;
font-size: 13px;
}
paper-tab[disabled] {
background-color: rgba(0, 0, 0, 0.1);
}
paper-tab:last-child {
border-width: 0;
}
paper-tab.iron-selected {
background-color: rgba(255, 255, 255, 0.5);
color: #585858;
}
.tab-content {
background-color: rgba(255, 255, 255, 0.5);
border: 1px solid rgba(0, 0, 0, 0.2);
border-width: 0 1px 1px 1px;
margin: 0 7px 10px 7px;
padding: 7px 5px 0 5px;
}
.tab-content label {
width: 40%;
}
.tab-content input {
width: 52%;
}
.same-width input[type='checkbox'] {
width: 15px;
}
.same-width label {
top: 0;
}
</style>
<form class="content" method="post">
<fieldset class="same-width">
<legend><things-i18n-msg msgid="label.chart" auto>Chart</things-i18n-msg></legend>
<label> <things-i18n-msg msgid="label.theme" auto>theme</things-i18n-msg> </label>
<select class="select-content" value="{{values.options.theme::change}}">
<option value="dark">dark</option>
<option value="light">light</option>
</select>
<div class="merge-column">
<label> <things-i18n-msg msgid="label.legend" auto>Legend</things-i18n-msg> </label>
<input type="checkbox" checked="{{values.options.legend.display::change}}" required />
</div>
<template is="dom-if" if="[[values.options.legend.display]]">
<label> <things-i18n-msg msgid="label.position" auto>Position</things-i18n-msg> </label>
<select class="select-content" value="{{values.options.legend.position::change}}">
<option value="top">top</option>
<option value="right">right</option>
<option value="bottom">bottom</option>
<option value="left">left</option>
</select>
</template>
<legend><things-i18n-msg msgid="label.value" auto>Value</things-i18n-msg></legend>
</fieldset>
<fieldset>
<legend><things-i18n-msg msgid="label.series" auto>Series</things-i18n-msg></legend>
<label> <things-i18n-msg msgid="label.data-key" auto>Data Key</things-i18n-msg> </label>
<input type="text" value="{{series.dataKey::change}}" />
<label> <things-i18n-msg msgid="label.color" auto>color</things-i18n-msg> </label>
<things-editor-multiple-color values="{{ series.color }}"></things-editor-multiple-color>
<label> <things-i18n-msg msgid="label.value-prefix" auto>Value Prefix</things-i18n-msg> </label>
<input type="text" value="{{series.valuePrefix::change}}" />
<label> <things-i18n-msg msgid="label.value-suffix" auto>Value suffix</things-i18n-msg> </label>
<input type="text" value="{{series.valueSuffix::change}}" />
<div>
<label> <things-i18n-msg msgid="label.value-display" auto>Value Display</things-i18n-msg> </label>
<input type="checkbox" checked="{{series.displayValue::change}}" required />
</div>
<template is="dom-if" if="[[series.displayValue]]">
<div>
<label> <things-i18n-msg msgid="label.font-color" auto>Font Color</things-i18n-msg> </label>
<things-editor-color value="{{series.defaultFontColor::change}}"></things-editor-color>
</div>
<div>
<label> <things-i18n-msg msgid="label.font-size" auto>Font Size</things-i18n-msg> </label>
<input is="things-editor-number-input" number="{{series.defaultFontSize::change}}" />
</div>
</template>
</fieldset>
<fieldset class="same-width">
<legend><things-i18n-msg msgid="label.axes" auto>Axes</things-i18n-msg></legend>
<label> <things-i18n-msg msgid="label.data-key" auto>Data Key</things-i18n-msg> </label>
<input type="text" value="{{values.data.labelDataKey::change}}" />
</fieldset>
</form>
</template>
<script>
;(function() {
'use strict'
Polymer({
is: 'things-editor-chartjs-properties-pie',
properties: {
values: {
type: Object,
notify: true
},
series: {
type: Object,
value: {}
}
},
observers: ['onValuesChanged(values.*)'],
onValuesChanged: function(values) {
// if(this._valueChanging)
// return
// this._valueChanging = true
if (values.path == 'values') {
// values가 바뀌었으므로 path를 다시 link한다.
this.unlinkPaths('series')
if (!this.get('values.data.datasets')) return
var series = this.values.data.datasets[0]
var oldVersionColor = series.backgroundColor
series.color = series.color || oldVersionColor
this.set('series', series)
this.linkPaths('series', 'values.data.datasets.0')
this._valueChanging = false
return
}
// values 하위의 무언가가 변경되면 values를 deep clone하여 다시 set.
this.set('values', Object.assign({}, values.base))
// this._valueChanging = false
}
})
})()
</script>
</dom-module>