@plotdb/chart 0.0.3 → 1.0.1
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 +11 -1
- package/build +11 -5
- package/dist/index.css +8 -0
- package/dist/index.js +607 -0
- package/dist/index.min.css +1 -0
- package/dist/index.min.js +1 -0
- package/package.json +12 -9
- package/src/{chart.ls → index.ls} +0 -0
- package/src/{chart.styl → index.styl} +0 -0
- package/web/src/pug/base.pug +1 -0
- package/web/src/pug/block/axis/0.0.1/index.ls +1 -7
- package/web/src/pug/block/axis-bubble/0.0.1/index.ls +1 -5
- package/web/src/pug/block/bar/0.0.1/index.ls +1 -5
- package/web/src/pug/block/bar-list/0.0.1/index.ls +1 -5
- package/web/src/pug/block/bar-race/0.0.1/index.ls +1 -5
- package/web/src/pug/block/base/0.0.1/index.ls +63 -64
- package/web/src/pug/block/blank/0.0.1/index.ls +1 -5
- package/web/src/pug/block/bubble/0.0.1/index.ls +4 -6
- package/web/src/pug/block/bubble/0.0.1/index.pug +14 -0
- package/web/src/pug/block/curve-bar/0.0.1/index.ls +1 -5
- package/web/src/pug/block/dumbbell/0.0.1/index.ls +1 -5
- package/web/src/pug/block/empty/0.0.1/index.ls +25 -24
- package/web/src/pug/block/gauge/0.0.1/index.ls +1 -5
- package/web/src/pug/block/line/0.0.1/index.ls +1 -6
- package/web/src/pug/block/number/0.0.1/index.ls +1 -5
- package/web/src/pug/block/percent-list/0.0.1/index.ls +1 -7
- package/web/src/pug/block/pie/0.0.1/index.ls +1 -5
- package/web/src/pug/block/pie-bubble/0.0.1/index.ls +1 -5
- package/web/src/pug/block/radar/0.0.1/index.ls +1 -5
- package/web/src/pug/block/scatter/0.0.1/index.ls +1 -5
- package/web/src/pug/block/sheet/0.0.1/index.ls +1 -5
- package/web/src/pug/block/table/0.0.1/index.ls +1 -5
- package/web/src/pug/block/taiwancounty/0.0.1/index.ls +1 -5
- package/web/src/pug/block/taiwantown/0.0.1/index.ls +1 -5
- package/web/src/pug/block/taiwanvillage/0.0.1/index.ls +1 -5
- package/web/src/pug/block/treemap/0.0.1/index.ls +1 -5
- package/web/src/pug/block/voronoi-treemap/0.0.1/index.ls +1 -5
- package/web/src/pug/block/wordcloud/0.0.1/index.ls +1 -5
- package/web/src/pug/block/worldmap/0.0.1/index.ls +1 -5
- package/web/src/styl/index.styl +6 -0
- package/web/static/block/axis/0.0.1/index.html +68 -73
- package/web/static/block/axis-bubble/0.0.1/index.html +205 -210
- package/web/static/block/bar/0.0.1/index.html +484 -489
- package/web/static/block/bar-list/0.0.1/index.html +188 -193
- package/web/static/block/bar-race/0.0.1/index.html +155 -160
- package/web/static/block/base/0.0.1/index.html +2 -2
- package/web/static/block/blank/0.0.1/index.html +35 -40
- package/web/static/block/bubble/0.0.1/index.html +377 -357
- package/web/static/block/curve-bar/0.0.1/index.html +126 -131
- package/web/static/block/dumbbell/0.0.1/index.html +160 -165
- package/web/static/block/empty/0.0.1/index.html +2 -2
- package/web/static/block/gauge/0.0.1/index.html +116 -121
- package/web/static/block/line/0.0.1/index.html +502 -507
- package/web/static/block/number/0.0.1/index.html +123 -128
- package/web/static/block/percent-list/0.0.1/index.html +263 -268
- package/web/static/block/pie/0.0.1/index.html +241 -246
- package/web/static/block/pie-bubble/0.0.1/index.html +295 -300
- package/web/static/block/radar/0.0.1/index.html +137 -142
- package/web/static/block/scatter/0.0.1/index.html +207 -212
- package/web/static/block/sheet/0.0.1/index.html +93 -98
- package/web/static/block/table/0.0.1/index.html +64 -70
- package/web/static/block/taiwancounty/0.0.1/index.html +180 -185
- package/web/static/block/taiwantown/0.0.1/index.html +104 -109
- package/web/static/block/taiwanvillage/0.0.1/index.html +114 -119
- package/web/static/block/treemap/0.0.1/index.html +296 -301
- package/web/static/block/voronoi-treemap/0.0.1/index.html +311 -316
- package/web/static/block/wordcloud/0.0.1/index.html +82 -87
- package/web/static/block/worldmap/0.0.1/index.html +186 -191
- package/web/static/css/index.css +6 -0
- package/web/static/css/index.min.css +1 -0
- package/web/static/index.html +1 -1
|
@@ -10,270 +10,265 @@
|
|
|
10
10
|
.pdl-layout > div[data-type=layout] > [data-name=legend] {
|
|
11
11
|
min-width: 6em;
|
|
12
12
|
}
|
|
13
|
-
</style><script type="@plotdb/block">
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
name:
|
|
20
|
-
version:
|
|
21
|
-
extend: {
|
|
22
|
-
name: "base",
|
|
23
|
-
version: "0.0.1"
|
|
24
|
-
},
|
|
25
|
-
dependencies: [],
|
|
26
|
-
i18n: {
|
|
27
|
-
"zh-TW": {
|
|
28
|
-
value: "數值",
|
|
29
|
-
name: "名稱",
|
|
30
|
-
other: "其它"
|
|
31
|
-
}
|
|
32
|
-
}
|
|
13
|
+
</style><script type="@plotdb/block">var mod;
|
|
14
|
+
module.exports = {
|
|
15
|
+
pkg: {
|
|
16
|
+
name: 'pie',
|
|
17
|
+
version: '0.0.1',
|
|
18
|
+
extend: {
|
|
19
|
+
name: "base",
|
|
20
|
+
version: "0.0.1"
|
|
33
21
|
},
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
})
|
|
42
|
-
});
|
|
22
|
+
dependencies: [],
|
|
23
|
+
i18n: {
|
|
24
|
+
"zh-TW": {
|
|
25
|
+
value: "數值",
|
|
26
|
+
name: "名稱",
|
|
27
|
+
other: "其它"
|
|
28
|
+
}
|
|
43
29
|
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
var
|
|
47
|
-
context = arg$.context, t = arg$.t;
|
|
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
|
-
name: "value",
|
|
73
|
-
priority: 20
|
|
74
|
-
},
|
|
75
|
-
name: {
|
|
76
|
-
type: 'NO',
|
|
77
|
-
name: "name",
|
|
78
|
-
priority: 10
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
init: function(){
|
|
82
|
-
var tint, this$ = this;
|
|
83
|
-
this.g = Object.fromEntries(['view', 'legend'].map(function(it){
|
|
84
|
-
return [it, d3.select(this$.layout.getGroup(it)).append('g')];
|
|
85
|
-
}));
|
|
86
|
-
this.tint = tint = new chart.utils.tint();
|
|
87
|
-
this.tip = new chart.utils.tip({
|
|
88
|
-
root: this.root,
|
|
89
|
-
accessor: function(arg$){
|
|
90
|
-
var evt, data, v;
|
|
91
|
-
evt = arg$.evt;
|
|
92
|
-
if (!(evt.target && (data = d3.select(evt.target).datum()))) {
|
|
93
|
-
return null;
|
|
94
|
-
}
|
|
95
|
-
v = isNaN(data.value)
|
|
96
|
-
? '-'
|
|
97
|
-
: data.value.toFixed(2) + "" + (this$.binding.value.unit || '');
|
|
98
|
-
return {
|
|
99
|
-
name: data.name,
|
|
100
|
-
value: v
|
|
101
|
-
};
|
|
102
|
-
},
|
|
103
|
-
range: function(){
|
|
104
|
-
return this$.layout.getNode('view').getBoundingClientRect();
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
this.legend = new chart.utils.legend({
|
|
108
|
-
layout: this.layout,
|
|
109
|
-
name: 'legend',
|
|
110
|
-
root: this.root,
|
|
111
|
-
shape: function(d){
|
|
112
|
-
return d3.select(this).attr('fill', tint.get(d.text));
|
|
30
|
+
},
|
|
31
|
+
init: function(arg$){
|
|
32
|
+
var root, context, pubsub, t;
|
|
33
|
+
root = arg$.root, context = arg$.context, pubsub = arg$.pubsub, t = arg$.t;
|
|
34
|
+
return pubsub.fire('init', {
|
|
35
|
+
mod: mod({
|
|
36
|
+
context: context,
|
|
37
|
+
t: t
|
|
38
|
+
})
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
mod = function(arg$){
|
|
43
|
+
var context, t, chart, d3;
|
|
44
|
+
context = arg$.context, t = arg$.t;
|
|
45
|
+
chart = context.chart, d3 = context.d3;
|
|
46
|
+
return {
|
|
47
|
+
sample: function(){
|
|
48
|
+
return {
|
|
49
|
+
raw: [1, 2, 3, 4, 5].map(function(val){
|
|
50
|
+
return {
|
|
51
|
+
val: (10 * Math.random()).toFixed(2),
|
|
52
|
+
name: val
|
|
53
|
+
};
|
|
54
|
+
}),
|
|
55
|
+
binding: {
|
|
56
|
+
name: {
|
|
57
|
+
key: 'name'
|
|
113
58
|
},
|
|
114
|
-
|
|
115
|
-
|
|
59
|
+
value: {
|
|
60
|
+
key: 'val'
|
|
116
61
|
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
destroy: function(){
|
|
127
|
-
return this.tip.destroy();
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
},
|
|
65
|
+
config: {},
|
|
66
|
+
dimension: {
|
|
67
|
+
value: {
|
|
68
|
+
type: 'R',
|
|
69
|
+
name: "value",
|
|
70
|
+
priority: 20
|
|
128
71
|
},
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
name: t("other"),
|
|
149
|
-
value: other.reduce(function(a, b){
|
|
150
|
-
return a + b.value;
|
|
151
|
-
}, 0)
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
} else {
|
|
155
|
-
ref$ = [
|
|
156
|
-
this.parsed.reduce(function(a, b){
|
|
157
|
-
return a + b.value;
|
|
158
|
-
}, 0), 0
|
|
159
|
-
], total = ref$[0], sum = ref$[1];
|
|
160
|
-
for (i$ = 0, to$ = this.parsed.length; i$ < to$; ++i$) {
|
|
161
|
-
idx = i$;
|
|
162
|
-
sum += this.parsed[idx].value;
|
|
163
|
-
if (sum / total > (this.cfg.collapse.threshold || 0.75)) {
|
|
164
|
-
break;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
other = this.parsed.splice(idx + 1);
|
|
168
|
-
if (other.length) {
|
|
169
|
-
this.parsed.push({
|
|
170
|
-
name: t("other"),
|
|
171
|
-
value: other.reduce(function(a, b){
|
|
172
|
-
return a + b.value;
|
|
173
|
-
}, 0)
|
|
174
|
-
});
|
|
175
|
-
}
|
|
72
|
+
name: {
|
|
73
|
+
type: 'NO',
|
|
74
|
+
name: "name",
|
|
75
|
+
priority: 10
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
init: function(){
|
|
79
|
+
var tint, this$ = this;
|
|
80
|
+
this.g = Object.fromEntries(['view', 'legend'].map(function(it){
|
|
81
|
+
return [it, d3.select(this$.layout.getGroup(it)).append('g')];
|
|
82
|
+
}));
|
|
83
|
+
this.tint = tint = new chart.utils.tint();
|
|
84
|
+
this.tip = new chart.utils.tip({
|
|
85
|
+
root: this.root,
|
|
86
|
+
accessor: function(arg$){
|
|
87
|
+
var evt, data, v;
|
|
88
|
+
evt = arg$.evt;
|
|
89
|
+
if (!(evt.target && (data = d3.select(evt.target).datum()))) {
|
|
90
|
+
return null;
|
|
176
91
|
}
|
|
177
|
-
|
|
178
|
-
|
|
92
|
+
v = isNaN(data.value)
|
|
93
|
+
? '-'
|
|
94
|
+
: data.value.toFixed(2) + "" + (this$.binding.value.unit || '');
|
|
179
95
|
return {
|
|
180
|
-
|
|
181
|
-
|
|
96
|
+
name: data.name,
|
|
97
|
+
value: v
|
|
182
98
|
};
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
var offset, i$, to$, i, obj, that, this$ = this, results$ = [];
|
|
187
|
-
this.parsed.map(function(it){
|
|
188
|
-
return it.picked = this$.legend.isSelected(it.name);
|
|
189
|
-
});
|
|
190
|
-
this.total.old = this.total.cur;
|
|
191
|
-
this.total.cur = this.parsed.reduce(function(a, b){
|
|
192
|
-
return a + (b.picked ? b.value : 0);
|
|
193
|
-
}, 0) || 1;
|
|
194
|
-
if (!this.total.old) {
|
|
195
|
-
this.total.old = this.total.cur;
|
|
99
|
+
},
|
|
100
|
+
range: function(){
|
|
101
|
+
return this$.layout.getNode('view').getBoundingClientRect();
|
|
196
102
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
103
|
+
});
|
|
104
|
+
this.legend = new chart.utils.legend({
|
|
105
|
+
layout: this.layout,
|
|
106
|
+
name: 'legend',
|
|
107
|
+
root: this.root,
|
|
108
|
+
shape: function(d){
|
|
109
|
+
return d3.select(this).attr('fill', tint.get(d.text));
|
|
110
|
+
},
|
|
111
|
+
cfg: {
|
|
112
|
+
selectable: true
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
this.legend.on('select', function(){
|
|
116
|
+
this$.bind();
|
|
117
|
+
this$.resize();
|
|
118
|
+
return this$.render();
|
|
119
|
+
});
|
|
120
|
+
this.arc = d3.arc().innerRadius(0).outerRadius(100).startAngle(0).endAngle(Math.PI / 2);
|
|
121
|
+
return this.total = {};
|
|
122
|
+
},
|
|
123
|
+
destroy: function(){
|
|
124
|
+
return this.tip.destroy();
|
|
125
|
+
},
|
|
126
|
+
parse: function(){
|
|
127
|
+
var other, ref$, total, sum, i$, to$, idx;
|
|
128
|
+
this.tint.reset();
|
|
129
|
+
this.parsed = this.data.map(function(it){
|
|
130
|
+
var ret;
|
|
131
|
+
ret = import$({}, it);
|
|
132
|
+
if (isNaN(ret.value)) {
|
|
133
|
+
ret.value = 0;
|
|
134
|
+
}
|
|
135
|
+
return ret;
|
|
136
|
+
});
|
|
137
|
+
this.parsed.sort(function(a, b){
|
|
138
|
+
return b.value - a.value;
|
|
139
|
+
});
|
|
140
|
+
if (this.cfg.collapse != null && this.cfg.collapse.enabled) {
|
|
141
|
+
if (this.cfg.collapse.method === 'count') {
|
|
142
|
+
other = this.parsed.splice(this.cfg.collapse.threshold || 7);
|
|
143
|
+
if (other.length) {
|
|
144
|
+
this.parsed.push({
|
|
145
|
+
name: t("other"),
|
|
146
|
+
value: other.reduce(function(a, b){
|
|
147
|
+
return a + b.value;
|
|
148
|
+
}, 0)
|
|
149
|
+
});
|
|
209
150
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
e: 2 * Math.PI * obj.cur.e / this.total.cur
|
|
151
|
+
} else {
|
|
152
|
+
ref$ = [
|
|
153
|
+
this.parsed.reduce(function(a, b){
|
|
154
|
+
return a + b.value;
|
|
155
|
+
}, 0), 0
|
|
156
|
+
], total = ref$[0], sum = ref$[1];
|
|
157
|
+
for (i$ = 0, to$ = this.parsed.length; i$ < to$; ++i$) {
|
|
158
|
+
idx = i$;
|
|
159
|
+
sum += this.parsed[idx].value;
|
|
160
|
+
if (sum / total > (this.cfg.collapse.threshold || 0.75)) {
|
|
161
|
+
break;
|
|
222
162
|
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
|
|
163
|
+
}
|
|
164
|
+
other = this.parsed.splice(idx + 1);
|
|
165
|
+
if (other.length) {
|
|
166
|
+
this.parsed.push({
|
|
167
|
+
name: t("other"),
|
|
168
|
+
value: other.reduce(function(a, b){
|
|
169
|
+
return a + b.value;
|
|
170
|
+
}, 0)
|
|
171
|
+
});
|
|
226
172
|
}
|
|
227
173
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
return
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
174
|
+
}
|
|
175
|
+
return this.legend.data(this.parsed.map(function(it){
|
|
176
|
+
return {
|
|
177
|
+
text: it.name,
|
|
178
|
+
key: it.name
|
|
179
|
+
};
|
|
180
|
+
}));
|
|
181
|
+
},
|
|
182
|
+
bind: function(){
|
|
183
|
+
var offset, i$, to$, i, obj, that, this$ = this, results$ = [];
|
|
184
|
+
this.parsed.map(function(it){
|
|
185
|
+
return it.picked = this$.legend.isSelected(it.name);
|
|
186
|
+
});
|
|
187
|
+
this.total.old = this.total.cur;
|
|
188
|
+
this.total.cur = this.parsed.reduce(function(a, b){
|
|
189
|
+
return a + (b.picked ? b.value : 0);
|
|
190
|
+
}, 0) || 1;
|
|
191
|
+
if (!this.total.old) {
|
|
192
|
+
this.total.old = this.total.cur;
|
|
193
|
+
}
|
|
194
|
+
offset = 0;
|
|
195
|
+
for (i$ = 0, to$ = this.parsed.length; i$ < to$; ++i$) {
|
|
196
|
+
i = i$;
|
|
197
|
+
obj = this.parsed[i];
|
|
198
|
+
if (!obj.old) {
|
|
199
|
+
obj.old = {
|
|
200
|
+
s: (that = this.parsed[i - 1]) ? that.old.e : 0,
|
|
201
|
+
e: 0
|
|
252
202
|
};
|
|
203
|
+
}
|
|
204
|
+
if (obj.cur) {
|
|
205
|
+
obj.old = obj.cur;
|
|
206
|
+
}
|
|
207
|
+
obj.cur = {
|
|
208
|
+
s: offset,
|
|
209
|
+
e: offset + (obj.picked ? obj.value : 0)
|
|
210
|
+
};
|
|
211
|
+
obj.angle = {
|
|
212
|
+
old: {
|
|
213
|
+
s: 2 * Math.PI * obj.old.s / this.total.old,
|
|
214
|
+
e: 2 * Math.PI * obj.old.e / this.total.old
|
|
215
|
+
},
|
|
216
|
+
cur: {
|
|
217
|
+
s: 2 * Math.PI * obj.cur.s / this.total.cur,
|
|
218
|
+
e: 2 * Math.PI * obj.cur.e / this.total.cur
|
|
219
|
+
}
|
|
253
220
|
};
|
|
254
|
-
if (
|
|
255
|
-
|
|
256
|
-
return it.value || it;
|
|
257
|
-
}));
|
|
221
|
+
if (obj.picked) {
|
|
222
|
+
results$.push(offset += obj.value);
|
|
258
223
|
}
|
|
259
|
-
box = this.layout.getBox('view');
|
|
260
|
-
this.g.view.attr('transform', "translate(" + box.width / 2 + "," + box.height / 2 + ")");
|
|
261
|
-
x$ = this.g.view.selectAll('path.data').data(this.parsed, function(it){
|
|
262
|
-
return it.name || it._idx;
|
|
263
|
-
});
|
|
264
|
-
x$.exit().remove();
|
|
265
|
-
x$.enter().append('path').attr('class', 'data');
|
|
266
|
-
this.g.view.selectAll('path.data').attr('fill', function(d, i){
|
|
267
|
-
return this$.tint.get(d.name || d._idx);
|
|
268
|
-
}).transition().duration(350).attrTween('d', function(d, i){
|
|
269
|
-
return interpolateArc(d.angle.old, d.angle.cur);
|
|
270
|
-
});
|
|
271
|
-
return this.legend.render();
|
|
272
224
|
}
|
|
273
|
-
|
|
225
|
+
return results$;
|
|
226
|
+
},
|
|
227
|
+
resize: function(){
|
|
228
|
+
var box, ref$, w, h, size;
|
|
229
|
+
this.layout.update(false);
|
|
230
|
+
box = this.layout.getBox('view');
|
|
231
|
+
this.layout.getNode('view').style.width = box.height + "px";
|
|
232
|
+
this.layout.update(false);
|
|
233
|
+
box = this.layout.getBox('view');
|
|
234
|
+
ref$ = [box.width, box.height], w = ref$[0], h = ref$[1];
|
|
235
|
+
size = Math.min(w, h);
|
|
236
|
+
return this.arc.innerRadius((this.cfg.donutPercent || 0.7) * size / 2).outerRadius(size / 2);
|
|
237
|
+
},
|
|
238
|
+
render: function(){
|
|
239
|
+
var tint, interpolateArc, box, x$, this$ = this;
|
|
240
|
+
tint = this.tint;
|
|
241
|
+
interpolateArc = function(a1, a2){
|
|
242
|
+
return function(t){
|
|
243
|
+
var ref$, s, e;
|
|
244
|
+
ref$ = ['s', 'e'].map(function(i){
|
|
245
|
+
return (a2[i] - a1[i]) * t + a1[i];
|
|
246
|
+
}), s = ref$[0], e = ref$[1];
|
|
247
|
+
this$.arc.startAngle(s).endAngle(e);
|
|
248
|
+
return this$.arc();
|
|
249
|
+
};
|
|
250
|
+
};
|
|
251
|
+
if (this.cfg != null && this.cfg.palette) {
|
|
252
|
+
this.tint.set(this.cfg.palette.colors.map(function(it){
|
|
253
|
+
return it.value || it;
|
|
254
|
+
}));
|
|
255
|
+
}
|
|
256
|
+
box = this.layout.getBox('view');
|
|
257
|
+
this.g.view.attr('transform', "translate(" + box.width / 2 + "," + box.height / 2 + ")");
|
|
258
|
+
x$ = this.g.view.selectAll('path.data').data(this.parsed, function(it){
|
|
259
|
+
return it.name || it._idx;
|
|
260
|
+
});
|
|
261
|
+
x$.exit().remove();
|
|
262
|
+
x$.enter().append('path').attr('class', 'data');
|
|
263
|
+
this.g.view.selectAll('path.data').attr('fill', function(d, i){
|
|
264
|
+
return this$.tint.get(d.name || d._idx);
|
|
265
|
+
}).transition().duration(350).attrTween('d', function(d, i){
|
|
266
|
+
return interpolateArc(d.angle.old, d.angle.cur);
|
|
267
|
+
});
|
|
268
|
+
return this.legend.render();
|
|
269
|
+
}
|
|
274
270
|
};
|
|
275
|
-
|
|
276
|
-
});
|
|
271
|
+
};
|
|
277
272
|
function import$(obj, src){
|
|
278
273
|
var own = {}.hasOwnProperty;
|
|
279
274
|
for (var key in src) if (own.call(src, key)) obj[key] = src[key];
|