@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
@@ -36,323 +36,318 @@
36
36
  grid-column: 2;
37
37
  grid-row: 2;
38
38
  }
39
- </style><script type="@plotdb/block">(function(it){
40
- return it();
41
- })(function(){
42
- var blockFactory, mod;
43
- blockFactory = {
44
- pkg: {
45
- name: 'treemap',
46
- version: '0.0.1',
47
- extend: {
48
- name: "base",
49
- version: "0.0.1"
50
- },
51
- dependencies: [],
52
- i18n: {
53
- "zh-TW": {
54
- "other": "其它",
55
- "unit": "單位"
56
- }
57
- }
39
+ </style><script type="@plotdb/block">var mod;
40
+ module.exports = {
41
+ pkg: {
42
+ name: 'treemap',
43
+ version: '0.0.1',
44
+ extend: {
45
+ name: "base",
46
+ version: "0.0.1"
58
47
  },
59
- init: function(arg$){
60
- var root, context, pubsub, t;
61
- root = arg$.root, context = arg$.context, pubsub = arg$.pubsub, t = arg$.t;
62
- return pubsub.fire('init', {
63
- mod: mod({
64
- root: root,
65
- context: context,
66
- t: t
67
- })
68
- });
48
+ dependencies: [],
49
+ i18n: {
50
+ "zh-TW": {
51
+ "other": "其它",
52
+ "unit": "單位"
53
+ }
69
54
  }
70
- };
71
- mod = function(arg$){
72
- var root, context, t, chart, d3, ldcolor, wrapSvgText;
73
- root = arg$.root, context = arg$.context, t = arg$.t;
74
- chart = context.chart, d3 = context.d3, ldcolor = context.ldcolor, wrapSvgText = context.wrapSvgText;
75
- return {
76
- sample: function(){
77
- return {
78
- 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){
79
- return {
80
- val: Math.random().toFixed(2),
81
- cat: Math.floor(1 + 6 * Math.random())
82
- };
83
- }),
84
- binding: {
85
- color: {
86
- key: 'cat'
87
- },
88
- area: {
89
- key: 'val',
90
- unit: 'MB'
91
- },
92
- name: {
93
- key: 'cat'
94
- },
95
- category: {
96
- key: 'cat'
97
- }
98
- }
99
- };
100
- },
101
- config: {
102
- unitPosition: {
103
- type: 'choice',
104
- values: ['inner', 'outside', 'none']
105
- }
106
- },
107
- dimension: {
108
- color: {
109
- type: 'RC',
110
- name: "顏色",
111
- priority: 4
112
- },
113
- area: {
114
- type: 'R',
115
- name: "面積",
116
- priority: 1
117
- },
118
- name: {
119
- type: 'NC',
120
- name: "名稱",
121
- priority: 2
122
- },
123
- category: {
124
- type: 'C',
125
- name: "分類",
126
- priority: 3
127
- }
128
- },
129
- init: function(){
130
- var tint, textRenderer, ref$, this$ = this;
131
- this.tint = tint = new chart.utils.tint();
132
- this.g = Object.fromEntries(['view', 'unit', 'legend'].map(function(it){
133
- return [it, d3.select(this$.layout.getGroup(it))];
134
- }));
135
- this.textRenderer = textRenderer = document.createElement('div');
136
- import$(textRenderer.style, {
137
- textAlign: 'right',
138
- fontSize: '0.9em',
139
- padding: ".5em .5em",
140
- lineHeight: '1.1em',
141
- whiteSpace: "pre-line",
142
- display: 'inline-block',
143
- position: 'absolute',
144
- top: 0,
145
- left: 0,
146
- opacity: 0,
147
- pointerEvents: 'none',
148
- userSelect: 'none',
149
- zIndex: 0
150
- });
151
- root.appendChild(textRenderer);
152
- this.legend = new chart.utils.legend({
153
- layout: this.layout,
154
- name: 'legend',
155
- root: this.root,
156
- shape: function(d){
157
- return d3.select(this).attr('fill', tint.get(d.key));
55
+ },
56
+ init: function(arg$){
57
+ var root, context, pubsub, t;
58
+ root = arg$.root, context = arg$.context, pubsub = arg$.pubsub, t = arg$.t;
59
+ return pubsub.fire('init', {
60
+ mod: mod({
61
+ root: root,
62
+ context: context,
63
+ t: t
64
+ })
65
+ });
66
+ }
67
+ };
68
+ mod = function(arg$){
69
+ var root, context, t, chart, d3, ldcolor, wrapSvgText;
70
+ root = arg$.root, context = arg$.context, t = arg$.t;
71
+ chart = context.chart, d3 = context.d3, ldcolor = context.ldcolor, wrapSvgText = context.wrapSvgText;
72
+ return {
73
+ sample: function(){
74
+ return {
75
+ 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){
76
+ return {
77
+ val: Math.random().toFixed(2),
78
+ cat: Math.floor(1 + 6 * Math.random())
79
+ };
80
+ }),
81
+ binding: {
82
+ color: {
83
+ key: 'cat'
158
84
  },
159
- direction: ((ref$ = this.cfg).legend || (ref$.legend = {})).position === 'bottom' ? 'horizontal' : 'vertical',
160
- cfg: {
161
- selectable: true
162
- }
163
- });
164
- this.legend.on('select', function(){
165
- this$.bind();
166
- this$.resize();
167
- return this$.render();
168
- });
169
- return this.tip = new chart.utils.tip({
170
- root: this.root,
171
- accessor: function(arg$){
172
- var evt, data, v;
173
- evt = arg$.evt;
174
- if (!(evt.target && (data = d3.select(evt.target).datum()))) {
175
- return null;
176
- }
177
- v = isNaN(data.data.area)
178
- ? '-'
179
- : data.data.area.toFixed(2) + "" + (this$.binding.area.unit || '');
180
- return {
181
- name: data.data.name,
182
- value: v
183
- };
85
+ area: {
86
+ key: 'val',
87
+ unit: 'MB'
184
88
  },
185
- range: function(){
186
- return this$.layout.getNode('view').getBoundingClientRect();
89
+ name: {
90
+ key: 'cat'
91
+ },
92
+ category: {
93
+ key: 'cat'
187
94
  }
188
- });
95
+ }
96
+ };
97
+ },
98
+ config: {
99
+ unitPosition: {
100
+ type: 'choice',
101
+ values: ['inner', 'outside', 'none']
102
+ }
103
+ },
104
+ dimension: {
105
+ color: {
106
+ type: 'RC',
107
+ name: "顏色",
108
+ priority: 4
189
109
  },
190
- destroy: function(){
191
- return this.tip.destroy();
110
+ area: {
111
+ type: 'R',
112
+ name: "面積",
113
+ priority: 1
192
114
  },
193
- parse: function(){
194
- var hash, k, v;
195
- this.tint.reset();
196
- hash = {};
197
- this.data.map(function(d, i){
198
- d.id = "name-" + i;
199
- if (!d.category || d.category === "") {
200
- return d.category = t("other");
201
- }
202
- });
203
- if (!this.binding.category) {
204
- this.data.map(function(d){
205
- return d.category = 'root-1';
206
- });
115
+ name: {
116
+ type: 'NC',
117
+ name: "名稱",
118
+ priority: 2
119
+ },
120
+ category: {
121
+ type: 'C',
122
+ name: "分類",
123
+ priority: 3
124
+ }
125
+ },
126
+ init: function(){
127
+ var tint, textRenderer, ref$, this$ = this;
128
+ this.tint = tint = new chart.utils.tint();
129
+ this.g = Object.fromEntries(['view', 'unit', 'legend'].map(function(it){
130
+ return [it, d3.select(this$.layout.getGroup(it))];
131
+ }));
132
+ this.textRenderer = textRenderer = document.createElement('div');
133
+ import$(textRenderer.style, {
134
+ textAlign: 'right',
135
+ fontSize: '0.9em',
136
+ padding: ".5em .5em",
137
+ lineHeight: '1.1em',
138
+ whiteSpace: "pre-line",
139
+ display: 'inline-block',
140
+ position: 'absolute',
141
+ top: 0,
142
+ left: 0,
143
+ opacity: 0,
144
+ pointerEvents: 'none',
145
+ userSelect: 'none',
146
+ zIndex: 0
147
+ });
148
+ root.appendChild(textRenderer);
149
+ this.legend = new chart.utils.legend({
150
+ layout: this.layout,
151
+ name: 'legend',
152
+ root: this.root,
153
+ shape: function(d){
154
+ return d3.select(this).attr('fill', tint.get(d.key));
155
+ },
156
+ direction: ((ref$ = this.cfg).legend || (ref$.legend = {})).position === 'bottom' ? 'horizontal' : 'vertical',
157
+ cfg: {
158
+ selectable: true
207
159
  }
208
- this.data.map(function(it){
209
- return hash[it.category] = {
210
- id: it.category,
211
- category: 'root'
212
- };
213
- });
214
- this.cats = Array.from(new Set(this.data.map(function(it){
215
- return it.category;
216
- }))).filter(function(it){
217
- return it !== 'root-1';
218
- });
219
- this.data = this.data.concat((function(){
220
- var ref$, results$ = [];
221
- for (k in ref$ = hash) {
222
- v = ref$[k];
223
- results$.push(v);
160
+ });
161
+ this.legend.on('select', function(){
162
+ this$.bind();
163
+ this$.resize();
164
+ return this$.render();
165
+ });
166
+ return this.tip = new chart.utils.tip({
167
+ root: this.root,
168
+ accessor: function(arg$){
169
+ var evt, data, v;
170
+ evt = arg$.evt;
171
+ if (!(evt.target && (data = d3.select(evt.target).datum()))) {
172
+ return null;
224
173
  }
225
- return results$;
226
- }()), [{
227
- id: 'root'
228
- }]);
229
- return this.legend.data(this.cats.map(function(it){
174
+ v = isNaN(data.data.area)
175
+ ? '-'
176
+ : data.data.area.toFixed(2) + "" + (this$.binding.area.unit || '');
230
177
  return {
231
- key: it,
232
- text: it
178
+ name: data.data.name,
179
+ value: v
233
180
  };
234
- }));
235
- },
236
- bind: function(){
237
- var data, s, this$ = this;
238
- data = this.data.filter(function(it){
239
- var ref$;
240
- return it.id === 'root' || ((ref$ = it.category) === 'root' || ref$ === 'root-1') || this$.legend.isSelected(it.category);
241
- });
242
- s = d3.stratify().id(function(it){
243
- return it.id;
244
- }).parentId(function(it){
245
- return it.category;
181
+ },
182
+ range: function(){
183
+ return this$.layout.getNode('view').getBoundingClientRect();
184
+ }
185
+ });
186
+ },
187
+ destroy: function(){
188
+ return this.tip.destroy();
189
+ },
190
+ parse: function(){
191
+ var hash, k, v;
192
+ this.tint.reset();
193
+ hash = {};
194
+ this.data.map(function(d, i){
195
+ d.id = "name-" + i;
196
+ if (!d.category || d.category === "") {
197
+ return d.category = t("other");
198
+ }
199
+ });
200
+ if (!this.binding.category) {
201
+ this.data.map(function(d){
202
+ return d.category = 'root-1';
246
203
  });
247
- return this.ret = s(data);
248
- },
249
- resize: function(){
250
- var ref$, ref1$, x$, box, tree;
251
- this.root.querySelector('.pdl-layout').classList.toggle('legend-bottom', ((ref$ = this.cfg).legend || (ref$.legend = {})).position === 'bottom');
252
- this.tip.toggle(((ref$ = this.cfg).tip || (ref$.tip = {})).enabled != null ? this.cfg.tip.enabled : true);
253
- this.unit = {
254
- inner: ((ref$ = this.cfg).unit || (ref$.unit = {})).position === 'inner' ? this.binding.area.unit || '' : '',
255
- outer: (ref$ = ((ref1$ = this.cfg).unit || (ref1$.unit = {})).position) === 'inner' || ref$ === 'none'
256
- ? ''
257
- : this.binding.area.unit ? t('unit') + ": " + (this.binding.area.unit || '') : ''
204
+ }
205
+ this.data.map(function(it){
206
+ return hash[it.category] = {
207
+ id: it.category,
208
+ category: 'root'
258
209
  };
259
- x$ = this.layout.getNode('unit');
260
- x$.style.display = !this.unit.outer ? 'none' : '';
261
- x$.textContent = this.unit.outer;
262
- this.legend.config(this.cfg.legend);
263
- this.legend.update();
264
- this.layout.update(false);
265
- this.ret.sum(function(it){
266
- return it.area;
267
- });
268
- box = this.layout.getBox('view');
269
- tree = d3.treemap().padding(1).size([box.width, box.height])(this.ret);
270
- this.nodes = this.ret.leaves().filter(function(it){
271
- return it.data._raw;
272
- });
273
- this.nodes.map(function(it){
274
- return it._raw = it.data._raw;
275
- });
276
- return this.extent = d3.extent(this.nodes.map(function(it){
277
- return it.value;
278
- }));
279
- },
280
- render: function(){
281
- var cfg, unit, binding, layout, textRenderer, tint, x$, y$, this$ = this;
282
- cfg = this.cfg, unit = this.unit, binding = this.binding, layout = this.layout, textRenderer = this.textRenderer, tint = this.tint;
283
- tint.set(cfg.palette);
284
- this.g.unit.call(function(){
285
- var node, ret;
286
- node = layout.getNode('unit');
287
- ret = wrapSvgText({
288
- node: node,
289
- useRange: true
290
- });
291
- this$.g.unit.node().textContent = '';
292
- return this$.g.unit.node().appendChild(ret);
293
- });
294
- x$ = this.g.view.selectAll('rect.data').data(this.nodes, function(it){
295
- return it._raw._idx;
296
- });
297
- x$.exit().remove();
298
- x$.enter().append('rect').attr('class', 'data').attr('x', function(it){
299
- return (it.x1 + it.x0) / 2 - (it.x1 - it.x0) / 4;
300
- }).attr('y', function(it){
301
- return (it.y1 + it.y0) / 2 - (it.y1 - it.y0) / 4;
302
- }).attr('width', function(it){
303
- return (it.x1 - it.x0) / 2;
304
- }).attr('height', function(it){
305
- return (it.y1 - it.y0) / 2;
306
- }).attr('fill', function(it){
307
- return tint.get(it.data.color || it.data.category);
308
- }).style('opacity', 0);
309
- this.g.view.selectAll('rect').transition().duration(350).attr('x', function(it){
310
- return it.x0;
311
- }).attr('y', function(it){
312
- return it.y0;
313
- }).attr('width', function(it){
314
- return it.x1 - it.x0;
315
- }).attr('height', function(it){
316
- return it.y1 - it.y0;
317
- }).attr('fill', function(it){
318
- var v;
319
- v = (it.value - this$.extent[0]) / (this$.extent[1] - this$.extent[0]) - 0.5;
320
- return tint.get(it.data.color || it.data.category);
321
- }).style('opacity', 1);
322
- y$ = this.g.view.selectAll('g.label').data(this.nodes, function(it){
323
- return it._raw._idx;
210
+ });
211
+ this.cats = Array.from(new Set(this.data.map(function(it){
212
+ return it.category;
213
+ }))).filter(function(it){
214
+ return it !== 'root-1';
215
+ });
216
+ this.data = this.data.concat((function(){
217
+ var ref$, results$ = [];
218
+ for (k in ref$ = hash) {
219
+ v = ref$[k];
220
+ results$.push(v);
221
+ }
222
+ return results$;
223
+ }()), [{
224
+ id: 'root'
225
+ }]);
226
+ return this.legend.data(this.cats.map(function(it){
227
+ return {
228
+ key: it,
229
+ text: it
230
+ };
231
+ }));
232
+ },
233
+ bind: function(){
234
+ var data, s, this$ = this;
235
+ data = this.data.filter(function(it){
236
+ var ref$;
237
+ return it.id === 'root' || ((ref$ = it.category) === 'root' || ref$ === 'root-1') || this$.legend.isSelected(it.category);
238
+ });
239
+ s = d3.stratify().id(function(it){
240
+ return it.id;
241
+ }).parentId(function(it){
242
+ return it.category;
243
+ });
244
+ return this.ret = s(data);
245
+ },
246
+ resize: function(){
247
+ var ref$, ref1$, x$, box, tree;
248
+ this.root.querySelector('.pdl-layout').classList.toggle('legend-bottom', ((ref$ = this.cfg).legend || (ref$.legend = {})).position === 'bottom');
249
+ this.tip.toggle(((ref$ = this.cfg).tip || (ref$.tip = {})).enabled != null ? this.cfg.tip.enabled : true);
250
+ this.unit = {
251
+ inner: ((ref$ = this.cfg).unit || (ref$.unit = {})).position === 'inner' ? this.binding.area.unit || '' : '',
252
+ outer: (ref$ = ((ref1$ = this.cfg).unit || (ref1$.unit = {})).position) === 'inner' || ref$ === 'none'
253
+ ? ''
254
+ : this.binding.area.unit ? t('unit') + ": " + (this.binding.area.unit || '') : ''
255
+ };
256
+ x$ = this.layout.getNode('unit');
257
+ x$.style.display = !this.unit.outer ? 'none' : '';
258
+ x$.textContent = this.unit.outer;
259
+ this.legend.config(this.cfg.legend);
260
+ this.legend.update();
261
+ this.layout.update(false);
262
+ this.ret.sum(function(it){
263
+ return it.area;
264
+ });
265
+ box = this.layout.getBox('view');
266
+ tree = d3.treemap().padding(1).size([box.width, box.height])(this.ret);
267
+ this.nodes = this.ret.leaves().filter(function(it){
268
+ return it.data._raw;
269
+ });
270
+ this.nodes.map(function(it){
271
+ return it._raw = it.data._raw;
272
+ });
273
+ return this.extent = d3.extent(this.nodes.map(function(it){
274
+ return it.value;
275
+ }));
276
+ },
277
+ render: function(){
278
+ var cfg, unit, binding, layout, textRenderer, tint, x$, y$, this$ = this;
279
+ cfg = this.cfg, unit = this.unit, binding = this.binding, layout = this.layout, textRenderer = this.textRenderer, tint = this.tint;
280
+ tint.set(cfg.palette);
281
+ this.g.unit.call(function(){
282
+ var node, ret;
283
+ node = layout.getNode('unit');
284
+ ret = wrapSvgText({
285
+ node: node,
286
+ useRange: true
324
287
  });
325
- y$.exit().remove();
326
- y$.enter().append('g').attr('class', 'label data').attr('transform', function(d, i){
327
- return "translate(" + d.x0 + "," + d.y0 + ")";
328
- }).attr('opacity', 0).style('pointer-events', 'none').style('cursor', 'pointer');
329
- this.g.view.selectAll('g.label').attr('font-size', '0.9em').each(function(d, i){
330
- var area, ret;
331
- textRenderer.style.width = (d.x1 - d.x0) + "px";
332
- area = d.data.area;
333
- area = d3.format('.3s')(area);
334
- textRenderer.innerHTML = "<div>" + (d.data.name || '') + "</div>\n<div>" + area + unit.inner + "</div>";
335
- ret = wrapSvgText({
336
- node: textRenderer,
337
- useRange: true
338
- });
339
- this.textContent = '';
340
- return this.appendChild(ret);
341
- }).transition().duration(350).attr('transform', function(d, i){
342
- return "translate(" + d.x0 + "," + d.y0 + ")";
343
- }).attr('fill', function(it){
344
- return tint.text(it.data.color || it.data.category);
345
- }).attr('opacity', function(d, i){
346
- var box;
347
- box = this.getBBox();
348
- return box.width > d.x1 - d.x0 || box.height > d.y1 - d.y0 ? 0 : 1;
288
+ this$.g.unit.node().textContent = '';
289
+ return this$.g.unit.node().appendChild(ret);
290
+ });
291
+ x$ = this.g.view.selectAll('rect.data').data(this.nodes, function(it){
292
+ return it._raw._idx;
293
+ });
294
+ x$.exit().remove();
295
+ x$.enter().append('rect').attr('class', 'data').attr('x', function(it){
296
+ return (it.x1 + it.x0) / 2 - (it.x1 - it.x0) / 4;
297
+ }).attr('y', function(it){
298
+ return (it.y1 + it.y0) / 2 - (it.y1 - it.y0) / 4;
299
+ }).attr('width', function(it){
300
+ return (it.x1 - it.x0) / 2;
301
+ }).attr('height', function(it){
302
+ return (it.y1 - it.y0) / 2;
303
+ }).attr('fill', function(it){
304
+ return tint.get(it.data.color || it.data.category);
305
+ }).style('opacity', 0);
306
+ this.g.view.selectAll('rect').transition().duration(350).attr('x', function(it){
307
+ return it.x0;
308
+ }).attr('y', function(it){
309
+ return it.y0;
310
+ }).attr('width', function(it){
311
+ return it.x1 - it.x0;
312
+ }).attr('height', function(it){
313
+ return it.y1 - it.y0;
314
+ }).attr('fill', function(it){
315
+ var v;
316
+ v = (it.value - this$.extent[0]) / (this$.extent[1] - this$.extent[0]) - 0.5;
317
+ return tint.get(it.data.color || it.data.category);
318
+ }).style('opacity', 1);
319
+ y$ = this.g.view.selectAll('g.label').data(this.nodes, function(it){
320
+ return it._raw._idx;
321
+ });
322
+ y$.exit().remove();
323
+ y$.enter().append('g').attr('class', 'label data').attr('transform', function(d, i){
324
+ return "translate(" + d.x0 + "," + d.y0 + ")";
325
+ }).attr('opacity', 0).style('pointer-events', 'none').style('cursor', 'pointer');
326
+ this.g.view.selectAll('g.label').attr('font-size', '0.9em').each(function(d, i){
327
+ var area, ret;
328
+ textRenderer.style.width = (d.x1 - d.x0) + "px";
329
+ area = d.data.area;
330
+ area = d3.format('.3s')(area);
331
+ textRenderer.innerHTML = "<div>" + (d.data.name || '') + "</div>\n<div>" + area + unit.inner + "</div>";
332
+ ret = wrapSvgText({
333
+ node: textRenderer,
334
+ useRange: true
349
335
  });
350
- return this.legend.render();
351
- }
352
- };
336
+ this.textContent = '';
337
+ return this.appendChild(ret);
338
+ }).transition().duration(350).attr('transform', function(d, i){
339
+ return "translate(" + d.x0 + "," + d.y0 + ")";
340
+ }).attr('fill', function(it){
341
+ return tint.text(it.data.color || it.data.category);
342
+ }).attr('opacity', function(d, i){
343
+ var box;
344
+ box = this.getBBox();
345
+ return box.width > d.x1 - d.x0 || box.height > d.y1 - d.y0 ? 0 : 1;
346
+ });
347
+ return this.legend.render();
348
+ }
353
349
  };
354
- return blockFactory;
355
- });
350
+ };
356
351
  function import$(obj, src){
357
352
  var own = {}.hasOwnProperty;
358
353
  for (var key in src) if (own.call(src, key)) obj[key] = src[key];