@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.
Files changed (71) hide show
  1. package/CHANGELOG.md +11 -1
  2. package/build +11 -5
  3. package/dist/index.css +8 -0
  4. package/dist/index.js +607 -0
  5. package/dist/index.min.css +1 -0
  6. package/dist/index.min.js +1 -0
  7. package/package.json +12 -9
  8. package/src/{chart.ls → index.ls} +0 -0
  9. package/src/{chart.styl → index.styl} +0 -0
  10. package/web/src/pug/base.pug +1 -0
  11. package/web/src/pug/block/axis/0.0.1/index.ls +1 -7
  12. package/web/src/pug/block/axis-bubble/0.0.1/index.ls +1 -5
  13. package/web/src/pug/block/bar/0.0.1/index.ls +1 -5
  14. package/web/src/pug/block/bar-list/0.0.1/index.ls +1 -5
  15. package/web/src/pug/block/bar-race/0.0.1/index.ls +1 -5
  16. package/web/src/pug/block/base/0.0.1/index.ls +63 -64
  17. package/web/src/pug/block/blank/0.0.1/index.ls +1 -5
  18. package/web/src/pug/block/bubble/0.0.1/index.ls +4 -6
  19. package/web/src/pug/block/bubble/0.0.1/index.pug +14 -0
  20. package/web/src/pug/block/curve-bar/0.0.1/index.ls +1 -5
  21. package/web/src/pug/block/dumbbell/0.0.1/index.ls +1 -5
  22. package/web/src/pug/block/empty/0.0.1/index.ls +25 -24
  23. package/web/src/pug/block/gauge/0.0.1/index.ls +1 -5
  24. package/web/src/pug/block/line/0.0.1/index.ls +1 -6
  25. package/web/src/pug/block/number/0.0.1/index.ls +1 -5
  26. package/web/src/pug/block/percent-list/0.0.1/index.ls +1 -7
  27. package/web/src/pug/block/pie/0.0.1/index.ls +1 -5
  28. package/web/src/pug/block/pie-bubble/0.0.1/index.ls +1 -5
  29. package/web/src/pug/block/radar/0.0.1/index.ls +1 -5
  30. package/web/src/pug/block/scatter/0.0.1/index.ls +1 -5
  31. package/web/src/pug/block/sheet/0.0.1/index.ls +1 -5
  32. package/web/src/pug/block/table/0.0.1/index.ls +1 -5
  33. package/web/src/pug/block/taiwancounty/0.0.1/index.ls +1 -5
  34. package/web/src/pug/block/taiwantown/0.0.1/index.ls +1 -5
  35. package/web/src/pug/block/taiwanvillage/0.0.1/index.ls +1 -5
  36. package/web/src/pug/block/treemap/0.0.1/index.ls +1 -5
  37. package/web/src/pug/block/voronoi-treemap/0.0.1/index.ls +1 -5
  38. package/web/src/pug/block/wordcloud/0.0.1/index.ls +1 -5
  39. package/web/src/pug/block/worldmap/0.0.1/index.ls +1 -5
  40. package/web/src/styl/index.styl +6 -0
  41. package/web/static/block/axis/0.0.1/index.html +68 -73
  42. package/web/static/block/axis-bubble/0.0.1/index.html +205 -210
  43. package/web/static/block/bar/0.0.1/index.html +484 -489
  44. package/web/static/block/bar-list/0.0.1/index.html +188 -193
  45. package/web/static/block/bar-race/0.0.1/index.html +155 -160
  46. package/web/static/block/base/0.0.1/index.html +2 -2
  47. package/web/static/block/blank/0.0.1/index.html +35 -40
  48. package/web/static/block/bubble/0.0.1/index.html +377 -357
  49. package/web/static/block/curve-bar/0.0.1/index.html +126 -131
  50. package/web/static/block/dumbbell/0.0.1/index.html +160 -165
  51. package/web/static/block/empty/0.0.1/index.html +2 -2
  52. package/web/static/block/gauge/0.0.1/index.html +116 -121
  53. package/web/static/block/line/0.0.1/index.html +502 -507
  54. package/web/static/block/number/0.0.1/index.html +123 -128
  55. package/web/static/block/percent-list/0.0.1/index.html +263 -268
  56. package/web/static/block/pie/0.0.1/index.html +241 -246
  57. package/web/static/block/pie-bubble/0.0.1/index.html +295 -300
  58. package/web/static/block/radar/0.0.1/index.html +137 -142
  59. package/web/static/block/scatter/0.0.1/index.html +207 -212
  60. package/web/static/block/sheet/0.0.1/index.html +93 -98
  61. package/web/static/block/table/0.0.1/index.html +64 -70
  62. package/web/static/block/taiwancounty/0.0.1/index.html +180 -185
  63. package/web/static/block/taiwantown/0.0.1/index.html +104 -109
  64. package/web/static/block/taiwanvillage/0.0.1/index.html +114 -119
  65. package/web/static/block/treemap/0.0.1/index.html +296 -301
  66. package/web/static/block/voronoi-treemap/0.0.1/index.html +311 -316
  67. package/web/static/block/wordcloud/0.0.1/index.html +82 -87
  68. package/web/static/block/worldmap/0.0.1/index.html +186 -191
  69. package/web/static/css/index.css +6 -0
  70. package/web/static/css/index.min.css +1 -0
  71. package/web/static/index.html +1 -1
@@ -31,326 +31,321 @@
31
31
  font-size: 1.1em;
32
32
  line-height: 1.2em;
33
33
  }
34
- </style><script type="@plotdb/block">(function(it){
35
- return it();
36
- })(function(){
37
- var blockFactory, mod;
38
- blockFactory = {
39
- pkg: {
40
- name: 'pie-bubble',
41
- version: '0.0.1',
42
- extend: {
43
- name: "base",
44
- version: "0.0.1"
45
- },
46
- dependencies: []
34
+ </style><script type="@plotdb/block">var mod;
35
+ module.exports = {
36
+ pkg: {
37
+ name: 'pie-bubble',
38
+ version: '0.0.1',
39
+ extend: {
40
+ name: "base",
41
+ version: "0.0.1"
47
42
  },
48
- init: function(arg$){
49
- var root, context, pubsub;
50
- root = arg$.root, context = arg$.context, pubsub = arg$.pubsub;
51
- return pubsub.fire('init', {
52
- mod: mod({
53
- context: context
54
- })
55
- }).then(function(it){
56
- return it[0];
57
- });
58
- }
59
- };
60
- mod = function(arg$){
61
- var context, d3, forceBoundary, ldcolor, chart, ref$;
62
- context = arg$.context;
63
- d3 = context.d3, forceBoundary = context.forceBoundary, ldcolor = context.ldcolor, chart = context.chart;
64
- return {
65
- sample: function(){
66
- return {
67
- raw: [0, 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].map(function(val){
68
- return {
69
- name: "name" + val,
70
- val1: Math.random() * 100,
71
- val2: Math.random() * 100
72
- };
73
- }),
74
- binding: {
75
- name: {
76
- key: 'name'
77
- },
78
- left: {
79
- key: 'val1'
80
- },
81
- right: {
82
- key: 'val2'
83
- }
43
+ dependencies: []
44
+ },
45
+ init: function(arg$){
46
+ var root, context, pubsub;
47
+ root = arg$.root, context = arg$.context, pubsub = arg$.pubsub;
48
+ return pubsub.fire('init', {
49
+ mod: mod({
50
+ context: context
51
+ })
52
+ }).then(function(it){
53
+ return it[0];
54
+ });
55
+ }
56
+ };
57
+ mod = function(arg$){
58
+ var context, d3, forceBoundary, ldcolor, chart, ref$;
59
+ context = arg$.context;
60
+ d3 = context.d3, forceBoundary = context.forceBoundary, ldcolor = context.ldcolor, chart = context.chart;
61
+ return {
62
+ sample: function(){
63
+ return {
64
+ raw: [0, 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].map(function(val){
65
+ return {
66
+ name: "name" + val,
67
+ val1: Math.random() * 100,
68
+ val2: Math.random() * 100
69
+ };
70
+ }),
71
+ binding: {
72
+ name: {
73
+ key: 'name'
74
+ },
75
+ left: {
76
+ key: 'val1'
77
+ },
78
+ right: {
79
+ key: 'val2'
84
80
  }
85
- };
86
- },
87
- config: (ref$ = import$({}, chart.utils.config.preset['default']), ref$.color = {
88
- left: {
89
- type: 'color',
90
- 'default': '#f90'
91
- },
92
- right: {
93
- type: 'color',
94
- 'default': '#09f'
95
- }
96
- }, ref$),
97
- dimension: {
98
- name: {
99
- type: 'N',
100
- name: "name"
101
- },
102
- left: {
103
- type: 'R',
104
- name: "size in left"
105
- },
106
- right: {
107
- type: 'R',
108
- name: "size in right"
109
81
  }
82
+ };
83
+ },
84
+ config: (ref$ = import$({}, chart.utils.config.preset['default']), ref$.color = {
85
+ left: {
86
+ type: 'color',
87
+ 'default': '#f90'
88
+ },
89
+ right: {
90
+ type: 'color',
91
+ 'default': '#09f'
92
+ }
93
+ }, ref$),
94
+ dimension: {
95
+ name: {
96
+ type: 'N',
97
+ name: "name"
110
98
  },
111
- init: function(){
112
- var tint, this$ = this;
113
- this.tint = tint = new chart.utils.tint();
114
- this.valid = [];
115
- this.g = Object.fromEntries(['view', 'legend'].map(function(it){
116
- return [it, d3.select(this$.layout.getGroup(it))];
117
- }));
118
- this.tip = new chart.utils.tip({
119
- root: this.root,
120
- node: this.root.querySelector('[data-name=tip]'),
121
- view: {
122
- name: function(arg$){
123
- var ctx;
124
- ctx = arg$.ctx;
125
- if (ctx) {
126
- return ctx.name;
127
- } else {
128
- return '';
129
- }
130
- },
131
- value1: function(arg$){
132
- var ctx;
133
- ctx = arg$.ctx;
134
- if (ctx) {
135
- return ctx.value1;
136
- } else {
137
- return '';
138
- }
139
- },
140
- value2: function(arg$){
141
- var ctx;
142
- ctx = arg$.ctx;
143
- if (ctx) {
144
- return ctx.value2;
145
- } else {
146
- return '';
147
- }
99
+ left: {
100
+ type: 'R',
101
+ name: "size in left"
102
+ },
103
+ right: {
104
+ type: 'R',
105
+ name: "size in right"
106
+ }
107
+ },
108
+ init: function(){
109
+ var tint, this$ = this;
110
+ this.tint = tint = new chart.utils.tint();
111
+ this.valid = [];
112
+ this.g = Object.fromEntries(['view', 'legend'].map(function(it){
113
+ return [it, d3.select(this$.layout.getGroup(it))];
114
+ }));
115
+ this.tip = new chart.utils.tip({
116
+ root: this.root,
117
+ node: this.root.querySelector('[data-name=tip]'),
118
+ view: {
119
+ name: function(arg$){
120
+ var ctx;
121
+ ctx = arg$.ctx;
122
+ if (ctx) {
123
+ return ctx.name;
124
+ } else {
125
+ return '';
148
126
  }
149
127
  },
150
- accessor: function(arg$){
151
- var evt, data, unit, fmt;
152
- evt = arg$.evt;
153
- if (!(evt.target && (data = d3.select(evt.target).datum()))) {
154
- return null;
128
+ value1: function(arg$){
129
+ var ctx;
130
+ ctx = arg$.ctx;
131
+ if (ctx) {
132
+ return ctx.value1;
133
+ } else {
134
+ return '';
155
135
  }
156
- unit = this$.binding.left.unit || this$.binding.right.unit || '';
157
- fmt = d3.format('.3s');
158
- return {
159
- name: data.name || '',
160
- value1: this$.legendData[0].text + ": " + fmt(data.L) + unit,
161
- value2: this$.legendData[1].text + ": " + fmt(data.R) + unit
162
- };
163
136
  },
164
- range: function(){
165
- return this$.layout.getNode('view').getBoundingClientRect();
137
+ value2: function(arg$){
138
+ var ctx;
139
+ ctx = arg$.ctx;
140
+ if (ctx) {
141
+ return ctx.value2;
142
+ } else {
143
+ return '';
144
+ }
166
145
  }
167
- });
168
- this.legend = new chart.utils.legend({
169
- layout: this.layout,
170
- name: 'legend',
171
- root: this.root,
172
- shape: function(d){
173
- return d3.select(this).attr('fill', tint.get(d.key));
174
- },
175
- cfg: {
176
- selectable: true
146
+ },
147
+ accessor: function(arg$){
148
+ var evt, data, unit, fmt;
149
+ evt = arg$.evt;
150
+ if (!(evt.target && (data = d3.select(evt.target).datum()))) {
151
+ return null;
177
152
  }
178
- });
179
- return this.legend.on('select', function(){
180
- this$.bind();
181
- this$.resize();
182
- return this$.render();
183
- });
184
- },
185
- destroy: function(){
186
- return this.tip.destroy();
187
- },
188
- parse: function(){
189
- var this$ = this;
190
- this.valid = this.data.filter(function(it){
191
- return !isNaN(it.left + it.right);
192
- });
193
- this.legendData = ['left', 'right'].map(function(it){
194
- var v;
195
- v = this$.binding[it] ? this$.binding[it].name || this$.binding[it].key : it;
153
+ unit = this$.binding.left.unit || this$.binding.right.unit || '';
154
+ fmt = d3.format('.3s');
196
155
  return {
197
- key: v,
198
- text: v
156
+ name: data.name || '',
157
+ value1: this$.legendData[0].text + ": " + fmt(data.L) + unit,
158
+ value2: this$.legendData[1].text + ": " + fmt(data.R) + unit
199
159
  };
200
- });
201
- return this.legend.data(this.legendData);
202
- },
203
- resize: function(){
204
- var ref$, vbox, rng, this$ = this;
205
- this.sim = null;
206
- this.start();
207
- (ref$ = this.cfg).tip || (ref$.tip = {});
208
- (ref$ = this.cfg).color || (ref$.color = {});
209
- (ref$ = this.cfg).legend || (ref$.legend = {});
210
- this.tip.toggle(((ref$ = this.cfg).tip || (ref$.tip = {})).enabled != null ? this.cfg.tip.enabled : true);
211
- if (this.cfg.color.left === this.cfg.color.right) {
212
- this.cfg.colorRight = '#09f';
160
+ },
161
+ range: function(){
162
+ return this$.layout.getNode('view').getBoundingClientRect();
213
163
  }
214
- this.tint.set({
215
- colors: [this.cfg.color.left || this.cfg.palette.colors[0] || '#09f', this.cfg.color.right || this.cfg.palette.colors[1] || '#f90'],
216
- maps: this.legendData.map(function(it){
217
- return it.key;
218
- })
219
- }, true);
220
- this.legend.config((ref$ = this.cfg.legend, ref$.selectable = false, ref$));
221
- this.legend.update();
222
- this.layout.update(false);
223
- this.vbox = vbox = this.layout.getBox('view');
224
- rng = d3.randomUniform.source(d3.randomLcg(this.seed))(0, 1);
225
- this.valid.map(function(obj){
226
- var ref$, L, R, r, sum, rate, x, y;
227
- ref$ = [(ref$ = obj.left) > 0 ? ref$ : 0, (ref$ = obj.right) > 0 ? ref$ : 0], L = ref$[0], R = ref$[1];
228
- r = sum = L + R;
229
- rate = !sum
230
- ? 0.5
231
- : R / sum;
232
- ref$ = [rate * vbox.width, rng() * vbox.height], x = ref$[0], y = ref$[1];
233
- obj.r = r;
234
- obj.sum = sum;
235
- obj.rate = rate;
236
- obj.L = L;
237
- obj.R = R;
238
- obj.cx = x;
239
- if (!(obj.x != null)) {
240
- obj.x = x;
241
- obj.y = y;
242
- }
243
- if (!(obj._x != null)) {
244
- obj._x = x;
245
- obj._y = y;
246
- }
247
- return obj;
248
- });
249
- this.rate = 0.9 * Math.PI / (2 * Math.sqrt(3)) * Math.sqrt(vbox.width * vbox.height / this.valid.map(function(it){
250
- return Math.PI * Math.pow(it.r, 2);
251
- }).reduce(function(a, b){
252
- return a + b;
253
- }, 0));
254
- return this.valid.map(function(d, i){
255
- var ref$;
256
- return d.rr = (ref$ = d.r * this$.rate) > 2 ? ref$ : 2;
257
- });
258
- },
259
- render: function(){
260
- var binding, tint, rate, legendData, x$, y$;
261
- binding = this.binding, tint = this.tint, rate = this.rate, legendData = this.legendData;
262
- x$ = this.g.view.selectAll('g.pie').data(this.valid);
263
- x$.exit().remove();
264
- x$.enter().append('g').attr('class', "pie data").each(function(){
265
- d3.select(this).append('path');
266
- return d3.select(this).append('path');
267
- });
268
- this.g.view.selectAll('g.pie').each(function(d, i){
269
- d3.select(this).attr('transform', "translate(" + d.x + " " + d.y + ")");
270
- return d3.select(this).selectAll('path').attr('fill', function(e, j){
271
- return tint.get(legendData[j].key);
272
- }).attr('d', function(e, j){
273
- var r, rx, ry1, ry2, f;
274
- r = d.rr;
275
- rx = r * Math.cos(d.rate * Math.PI);
276
- ry1 = -r * Math.sin(d.rate * Math.PI);
277
- ry2 = r * Math.sin(d.rate * Math.PI);
278
- f = d.rate > 0.5
279
- ? j
280
- : 1 - j;
281
- return ["M", rx, ry1, "A", r, r, 0, f, j, rx, ry2, "L", 0, 0, "Z"].join(" ");
282
- });
283
- });
284
- y$ = this.g.view.selectAll('g.label').data(this.valid);
285
- y$.exit().remove();
286
- y$.enter().append('g').attr('class', 'label').each(function(d, i){
287
- var this$ = this;
288
- return [0].map(function(){
289
- return d3.select(this$).append('text');
290
- }).map(function(it){
291
- return it.attr('text-anchor', 'middle').attr('dominant-baseline', 'middle').attr('font-size', '.7em').style('pointer-event', 'none');
292
- });
293
- });
294
- this.g.view.selectAll('g.label').attr('transform', function(d, i){
295
- return "translate(" + d.x + "," + d.y + ")";
296
- }).each(function(d, i){
297
- return d3.select(this).selectAll('text').attr('opacity', d.rr * 2 < (d.sum.toFixed(2) + "").length * 7 ? 0 : 1).text(function(e, i){
298
- var ret;
299
- ret = d3.format('.3s')(d.sum);
300
- if (ret) {
301
- ret = ret + "" + (binding.left.unit || binding.right.unir || '');
302
- }
303
- return ret;
304
- });
305
- });
306
- return this.legend.render();
307
- },
308
- tick: function(){
309
- var pad, kickoff, fc, this$ = this;
310
- pad = this.cfg.pad || 5;
311
- if (!this.sim) {
312
- kickoff = true;
313
- this.fc = fc = d3.forceCollide().strength(0.6).iterations(20).radius(function(it){
314
- return it.rr;
315
- });
316
- this.fb = forceBoundary(function(it){
317
- return it.rr + pad;
318
- }, function(it){
319
- return it.rr + pad;
320
- }, function(it){
321
- return this$.vbox.width - it.rr - pad;
322
- }, function(it){
323
- return this$.vbox.height - it.rr - pad;
324
- }).strength(0.8);
325
- this.fy = d3.forceY().strength(0.2);
326
- this.fx = d3.forceX().strength(0.2).x(function(it){
327
- return it.cx;
328
- });
329
- this.sim = d3.forceSimulation().force('b', this.fb).force('collide', fc).force('fx', this.fx).force('fy', this.fy);
330
- this.sim.stop();
331
- this.sim.alpha(0.9);
164
+ });
165
+ this.legend = new chart.utils.legend({
166
+ layout: this.layout,
167
+ name: 'legend',
168
+ root: this.root,
169
+ shape: function(d){
170
+ return d3.select(this).attr('fill', tint.get(d.key));
171
+ },
172
+ cfg: {
173
+ selectable: true
332
174
  }
333
- this.fy.y(this.vbox.height / 2);
334
- this.sim.nodes(this.valid);
335
- this.sim.tick(kickoff ? 10 : 1);
336
- if (this.sim.alpha() < 0.01) {
337
- this.stop();
175
+ });
176
+ return this.legend.on('select', function(){
177
+ this$.bind();
178
+ this$.resize();
179
+ return this$.render();
180
+ });
181
+ },
182
+ destroy: function(){
183
+ return this.tip.destroy();
184
+ },
185
+ parse: function(){
186
+ var this$ = this;
187
+ this.valid = this.data.filter(function(it){
188
+ return !isNaN(it.left + it.right);
189
+ });
190
+ this.legendData = ['left', 'right'].map(function(it){
191
+ var v;
192
+ v = this$.binding[it] ? this$.binding[it].name || this$.binding[it].key : it;
193
+ return {
194
+ key: v,
195
+ text: v
196
+ };
197
+ });
198
+ return this.legend.data(this.legendData);
199
+ },
200
+ resize: function(){
201
+ var ref$, vbox, rng, this$ = this;
202
+ this.sim = null;
203
+ this.start();
204
+ (ref$ = this.cfg).tip || (ref$.tip = {});
205
+ (ref$ = this.cfg).color || (ref$.color = {});
206
+ (ref$ = this.cfg).legend || (ref$.legend = {});
207
+ this.tip.toggle(((ref$ = this.cfg).tip || (ref$.tip = {})).enabled != null ? this.cfg.tip.enabled : true);
208
+ if (this.cfg.color.left === this.cfg.color.right) {
209
+ this.cfg.colorRight = '#09f';
210
+ }
211
+ this.tint.set({
212
+ colors: [this.cfg.color.left || this.cfg.palette.colors[0] || '#09f', this.cfg.color.right || this.cfg.palette.colors[1] || '#f90'],
213
+ maps: this.legendData.map(function(it){
214
+ return it.key;
215
+ })
216
+ }, true);
217
+ this.legend.config((ref$ = this.cfg.legend, ref$.selectable = false, ref$));
218
+ this.legend.update();
219
+ this.layout.update(false);
220
+ this.vbox = vbox = this.layout.getBox('view');
221
+ rng = d3.randomUniform.source(d3.randomLcg(this.seed))(0, 1);
222
+ this.valid.map(function(obj){
223
+ var ref$, L, R, r, sum, rate, x, y;
224
+ ref$ = [(ref$ = obj.left) > 0 ? ref$ : 0, (ref$ = obj.right) > 0 ? ref$ : 0], L = ref$[0], R = ref$[1];
225
+ r = sum = L + R;
226
+ rate = !sum
227
+ ? 0.5
228
+ : R / sum;
229
+ ref$ = [rate * vbox.width, rng() * vbox.height], x = ref$[0], y = ref$[1];
230
+ obj.r = r;
231
+ obj.sum = sum;
232
+ obj.rate = rate;
233
+ obj.L = L;
234
+ obj.R = R;
235
+ obj.cx = x;
236
+ if (!(obj.x != null)) {
237
+ obj.x = x;
238
+ obj.y = y;
239
+ }
240
+ if (!(obj._x != null)) {
241
+ obj._x = x;
242
+ obj._y = y;
338
243
  }
339
- this.valid.map(function(it){
340
- it._x = it._x + (it.x - it._x) * 0.1;
341
- return it._y = it._y + (it.y - it._y) * 0.1;
244
+ return obj;
245
+ });
246
+ this.rate = 0.9 * Math.PI / (2 * Math.sqrt(3)) * Math.sqrt(vbox.width * vbox.height / this.valid.map(function(it){
247
+ return Math.PI * Math.pow(it.r, 2);
248
+ }).reduce(function(a, b){
249
+ return a + b;
250
+ }, 0));
251
+ return this.valid.map(function(d, i){
252
+ var ref$;
253
+ return d.rr = (ref$ = d.r * this$.rate) > 2 ? ref$ : 2;
254
+ });
255
+ },
256
+ render: function(){
257
+ var binding, tint, rate, legendData, x$, y$;
258
+ binding = this.binding, tint = this.tint, rate = this.rate, legendData = this.legendData;
259
+ x$ = this.g.view.selectAll('g.pie').data(this.valid);
260
+ x$.exit().remove();
261
+ x$.enter().append('g').attr('class', "pie data").each(function(){
262
+ d3.select(this).append('path');
263
+ return d3.select(this).append('path');
264
+ });
265
+ this.g.view.selectAll('g.pie').each(function(d, i){
266
+ d3.select(this).attr('transform', "translate(" + d.x + " " + d.y + ")");
267
+ return d3.select(this).selectAll('path').attr('fill', function(e, j){
268
+ return tint.get(legendData[j].key);
269
+ }).attr('d', function(e, j){
270
+ var r, rx, ry1, ry2, f;
271
+ r = d.rr;
272
+ rx = r * Math.cos(d.rate * Math.PI);
273
+ ry1 = -r * Math.sin(d.rate * Math.PI);
274
+ ry2 = r * Math.sin(d.rate * Math.PI);
275
+ f = d.rate > 0.5
276
+ ? j
277
+ : 1 - j;
278
+ return ["M", rx, ry1, "A", r, r, 0, f, j, rx, ry2, "L", 0, 0, "Z"].join(" ");
342
279
  });
343
- this.g.view.selectAll('g.label').attr('transform', function(d, i){
344
- return "translate(" + d._x + "," + d._y + ")";
280
+ });
281
+ y$ = this.g.view.selectAll('g.label').data(this.valid);
282
+ y$.exit().remove();
283
+ y$.enter().append('g').attr('class', 'label').each(function(d, i){
284
+ var this$ = this;
285
+ return [0].map(function(){
286
+ return d3.select(this$).append('text');
287
+ }).map(function(it){
288
+ return it.attr('text-anchor', 'middle').attr('dominant-baseline', 'middle').attr('font-size', '.7em').style('pointer-event', 'none');
345
289
  });
346
- return this.g.view.selectAll('g.pie').attr('transform', function(d, i){
347
- return "translate(" + d._x + "," + d._y + ")";
290
+ });
291
+ this.g.view.selectAll('g.label').attr('transform', function(d, i){
292
+ return "translate(" + d.x + "," + d.y + ")";
293
+ }).each(function(d, i){
294
+ return d3.select(this).selectAll('text').attr('opacity', d.rr * 2 < (d.sum.toFixed(2) + "").length * 7 ? 0 : 1).text(function(e, i){
295
+ var ret;
296
+ ret = d3.format('.3s')(d.sum);
297
+ if (ret) {
298
+ ret = ret + "" + (binding.left.unit || binding.right.unir || '');
299
+ }
300
+ return ret;
348
301
  });
302
+ });
303
+ return this.legend.render();
304
+ },
305
+ tick: function(){
306
+ var pad, kickoff, fc, this$ = this;
307
+ pad = this.cfg.pad || 5;
308
+ if (!this.sim) {
309
+ kickoff = true;
310
+ this.fc = fc = d3.forceCollide().strength(0.6).iterations(20).radius(function(it){
311
+ return it.rr;
312
+ });
313
+ this.fb = forceBoundary(function(it){
314
+ return it.rr + pad;
315
+ }, function(it){
316
+ return it.rr + pad;
317
+ }, function(it){
318
+ return this$.vbox.width - it.rr - pad;
319
+ }, function(it){
320
+ return this$.vbox.height - it.rr - pad;
321
+ }).strength(0.8);
322
+ this.fy = d3.forceY().strength(0.2);
323
+ this.fx = d3.forceX().strength(0.2).x(function(it){
324
+ return it.cx;
325
+ });
326
+ this.sim = d3.forceSimulation().force('b', this.fb).force('collide', fc).force('fx', this.fx).force('fy', this.fy);
327
+ this.sim.stop();
328
+ this.sim.alpha(0.9);
329
+ }
330
+ this.fy.y(this.vbox.height / 2);
331
+ this.sim.nodes(this.valid);
332
+ this.sim.tick(kickoff ? 10 : 1);
333
+ if (this.sim.alpha() < 0.01) {
334
+ this.stop();
349
335
  }
350
- };
336
+ this.valid.map(function(it){
337
+ it._x = it._x + (it.x - it._x) * 0.1;
338
+ return it._y = it._y + (it.y - it._y) * 0.1;
339
+ });
340
+ this.g.view.selectAll('g.label').attr('transform', function(d, i){
341
+ return "translate(" + d._x + "," + d._y + ")";
342
+ });
343
+ return this.g.view.selectAll('g.pie').attr('transform', function(d, i){
344
+ return "translate(" + d._x + "," + d._y + ")";
345
+ });
346
+ }
351
347
  };
352
- return blockFactory;
353
- });
348
+ };
354
349
  function import$(obj, src){
355
350
  var own = {}.hasOwnProperty;
356
351
  for (var key in src) if (own.call(src, key)) obj[key] = src[key];