@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
@@ -9,342 +9,337 @@
9
9
  grid-column: 2;
10
10
  padding: 0 0.5em 0 0.5em;
11
11
  }
12
- </style><script type="@plotdb/block">(function(it){
13
- return it();
14
- })(function(){
15
- var blockFactory, mod;
16
- blockFactory = {
17
- pkg: {
18
- name: 'voronoi-treemap',
19
- version: '0.0.1',
20
- extend: {
21
- name: "base",
22
- version: "0.0.1"
23
- },
24
- dependencies: [{
25
- name: "@zbryikt/voronoijs",
26
- version: "main",
27
- path: "voronoi.min.js"
28
- }]
12
+ </style><script type="@plotdb/block">var mod;
13
+ module.exports = {
14
+ pkg: {
15
+ name: 'voronoi-treemap',
16
+ version: '0.0.1',
17
+ extend: {
18
+ name: "base",
19
+ version: "0.0.1"
29
20
  },
30
- init: function(arg$){
31
- var root, context, pubsub;
32
- root = arg$.root, context = arg$.context, pubsub = arg$.pubsub;
33
- return pubsub.fire('init', {
34
- mod: mod({
35
- context: context
36
- })
37
- }).then(function(it){
38
- return it[0];
39
- });
40
- }
41
- };
42
- mod = function(arg$){
43
- var context, d3, ldcolor, voronoi, chart;
44
- context = arg$.context;
45
- d3 = context.d3, ldcolor = context.ldcolor, voronoi = context.voronoi, chart = context.chart;
46
- return {
47
- sample: function(){
48
- return {
49
- 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, 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].map(function(val){
50
- return {
51
- val: Math.random() * 10,
52
- cat: Math.floor(1 + 10 * Math.random()),
53
- name: val
54
- };
55
- }),
56
- binding: {
57
- name: {
58
- key: 'name'
59
- },
60
- area: {
61
- key: 'val'
62
- },
63
- category: {
64
- key: 'cat'
65
- }
21
+ dependencies: [{
22
+ name: "@zbryikt/voronoijs",
23
+ version: "main",
24
+ path: "voronoi.min.js"
25
+ }]
26
+ },
27
+ init: function(arg$){
28
+ var root, context, pubsub;
29
+ root = arg$.root, context = arg$.context, pubsub = arg$.pubsub;
30
+ return pubsub.fire('init', {
31
+ mod: mod({
32
+ context: context
33
+ })
34
+ }).then(function(it){
35
+ return it[0];
36
+ });
37
+ }
38
+ };
39
+ mod = function(arg$){
40
+ var context, d3, ldcolor, voronoi, chart;
41
+ context = arg$.context;
42
+ d3 = context.d3, ldcolor = context.ldcolor, voronoi = context.voronoi, chart = context.chart;
43
+ return {
44
+ sample: function(){
45
+ return {
46
+ 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, 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].map(function(val){
47
+ return {
48
+ val: Math.random() * 10,
49
+ cat: Math.floor(1 + 10 * Math.random()),
50
+ name: val
51
+ };
52
+ }),
53
+ binding: {
54
+ name: {
55
+ key: 'name'
56
+ },
57
+ area: {
58
+ key: 'val'
59
+ },
60
+ category: {
61
+ key: 'cat'
66
62
  }
67
- };
63
+ }
64
+ };
65
+ },
66
+ config: {},
67
+ dimension: {
68
+ area: {
69
+ type: 'R',
70
+ name: "area"
68
71
  },
69
- config: {},
70
- dimension: {
71
- area: {
72
- type: 'R',
73
- name: "area"
74
- },
75
- name: {
76
- type: 'N',
77
- desc: "name"
72
+ name: {
73
+ type: 'N',
74
+ desc: "name"
75
+ },
76
+ category: {
77
+ type: 'N',
78
+ desc: "category"
79
+ }
80
+ },
81
+ init: function(){
82
+ var tint, g, this$ = this;
83
+ this.tint = tint = new chart.utils.tint();
84
+ this.g = Object.fromEntries(['view', 'legend'].map(function(it){
85
+ return [it, d3.select(this$.layout.getGroup(it))];
86
+ }));
87
+ this.layout.getGroup('view').appendChild(g = document.createElementNS("http://www.w3.org/2000/svg", "g"));
88
+ this.g.shape = d3.select(g);
89
+ this.siteBoxes = [];
90
+ this.legend = new chart.utils.legend({
91
+ layout: this.layout,
92
+ name: 'legend',
93
+ root: this.root,
94
+ shape: function(d){
95
+ return d3.select(this).attr('fill', tint.get(d.key));
78
96
  },
79
- category: {
80
- type: 'N',
81
- desc: "category"
97
+ cfg: {
98
+ selectable: true
82
99
  }
83
- },
84
- init: function(){
85
- var tint, g, this$ = this;
86
- this.tint = tint = new chart.utils.tint();
87
- this.g = Object.fromEntries(['view', 'legend'].map(function(it){
88
- return [it, d3.select(this$.layout.getGroup(it))];
89
- }));
90
- this.layout.getGroup('view').appendChild(g = document.createElementNS("http://www.w3.org/2000/svg", "g"));
91
- this.g.shape = d3.select(g);
92
- this.siteBoxes = [];
93
- this.legend = new chart.utils.legend({
94
- layout: this.layout,
95
- name: 'legend',
96
- root: this.root,
97
- shape: function(d){
98
- return d3.select(this).attr('fill', tint.get(d.key));
99
- },
100
- cfg: {
101
- selectable: true
100
+ });
101
+ this.legend.on('select', function(){
102
+ this$.bind();
103
+ this$.resize();
104
+ return this$.render();
105
+ });
106
+ this.tip = new chart.utils.tip({
107
+ root: this.root,
108
+ accessor: function(arg$){
109
+ var evt, data;
110
+ evt = arg$.evt;
111
+ if (!(evt.target && (data = d3.select(evt.target).datum()))) {
112
+ return null;
102
113
  }
103
- });
104
- this.legend.on('select', function(){
105
- this$.bind();
106
- this$.resize();
107
- return this$.render();
108
- });
109
- this.tip = new chart.utils.tip({
110
- root: this.root,
111
- accessor: function(arg$){
112
- var evt, data;
113
- evt = arg$.evt;
114
- if (!(evt.target && (data = d3.select(evt.target).datum()))) {
115
- return null;
114
+ if (Array.isArray(data)) {
115
+ if (!this$._sites) {
116
+ return;
116
117
  }
117
- if (Array.isArray(data)) {
118
- if (!this$._sites) {
119
- return;
120
- }
121
- if (!(data.idx != null)) {
122
- return;
123
- }
124
- if (!(data = this$._sites[data.idx])) {
125
- return;
126
- }
118
+ if (!(data.idx != null)) {
119
+ return;
120
+ }
121
+ if (!(data = this$._sites[data.idx])) {
122
+ return;
127
123
  }
128
- return {
129
- name: data.name,
130
- value: data.area.toFixed(2) + "" + (this$.binding.area.unit || '')
131
- };
132
- },
133
- range: function(){
134
- return this$.layout.getNode('view').getBoundingClientRect();
135
124
  }
136
- });
137
- return this.start();
138
- },
139
- parse: function(){
140
- this.data.map(function(it){
141
- return it.key = it.name, it.value = it.area, it;
142
- });
143
- this.total = this.data.reduce(function(a, b){
144
- return a + b.area;
145
- }, 0);
146
- this.cats = Array.from(new Set(this.data.map(function(d){
147
- return d.category;
148
- })));
149
- return this.legend.data(this.cats.map(function(it){
150
125
  return {
151
- key: it,
152
- text: it
126
+ name: data.name,
127
+ value: data.area.toFixed(2) + "" + (this$.binding.area.unit || '')
153
128
  };
154
- }));
155
- },
156
- bind: function(){
157
- var data, box, ref$, w, h, sites, x$, y$, this$ = this;
158
- data = this.data.filter(function(it){
159
- return this$.legend.isSelected(it.category);
160
- });
161
- this.parsed = {
162
- children: d3.nest().key(function(it){
163
- return it.category;
164
- }).entries(data).map(function(it){
165
- return it.children = it.values, it;
166
- })
129
+ },
130
+ range: function(){
131
+ return this$.layout.getNode('view').getBoundingClientRect();
132
+ }
133
+ });
134
+ return this.start();
135
+ },
136
+ parse: function(){
137
+ this.data.map(function(it){
138
+ return it.key = it.name, it.value = it.area, it;
139
+ });
140
+ this.total = this.data.reduce(function(a, b){
141
+ return a + b.area;
142
+ }, 0);
143
+ this.cats = Array.from(new Set(this.data.map(function(d){
144
+ return d.category;
145
+ })));
146
+ return this.legend.data(this.cats.map(function(it){
147
+ return {
148
+ key: it,
149
+ text: it
167
150
  };
168
- box = this.box || this.svg.getBoundingClientRect();
169
- ref$ = [box.width, box.height], w = ref$[0], h = ref$[1];
170
- w = h = Math.min(w, h);
171
- this.treemap = new voronoi.Treemap(this.parsed, voronoi.Polygon.create(w, h, 60), w, h);
172
- sites = this.treemap.getSites();
173
- x$ = this.g.shape.selectAll('path.data').data(this.treemap.getPolygons());
174
- x$.exit().remove();
175
- x$.enter().append('path').attr('class', 'data').each(function(d, i){
176
- return d.idx = i;
177
- });
178
- this.g.shape.selectAll('path.data').attr('class', function(d, i){
179
- if (sites[i].lv <= 0) {
180
- return 'data group';
151
+ }));
152
+ },
153
+ bind: function(){
154
+ var data, box, ref$, w, h, sites, x$, y$, this$ = this;
155
+ data = this.data.filter(function(it){
156
+ return this$.legend.isSelected(it.category);
157
+ });
158
+ this.parsed = {
159
+ children: d3.nest().key(function(it){
160
+ return it.category;
161
+ }).entries(data).map(function(it){
162
+ return it.children = it.values, it;
163
+ })
164
+ };
165
+ box = this.box || this.svg.getBoundingClientRect();
166
+ ref$ = [box.width, box.height], w = ref$[0], h = ref$[1];
167
+ w = h = Math.min(w, h);
168
+ this.treemap = new voronoi.Treemap(this.parsed, voronoi.Polygon.create(w, h, 60), w, h);
169
+ sites = this.treemap.getSites();
170
+ x$ = this.g.shape.selectAll('path.data').data(this.treemap.getPolygons());
171
+ x$.exit().remove();
172
+ x$.enter().append('path').attr('class', 'data').each(function(d, i){
173
+ return d.idx = i;
174
+ });
175
+ this.g.shape.selectAll('path.data').attr('class', function(d, i){
176
+ if (sites[i].lv <= 0) {
177
+ return 'data group';
178
+ } else {
179
+ return 'data';
180
+ }
181
+ });
182
+ this.polygons = this.g.shape.selectAll('path.data');
183
+ y$ = this.g.shape.selectAll('g.label').data(sites);
184
+ y$.exit().remove();
185
+ y$.enter().append('g').attr('class', 'label').each(function(d, i){
186
+ var x$;
187
+ x$ = d3.select(this);
188
+ x$.append('text').attr('class', 'name').attr('font-size', '.8em');
189
+ x$.append('text').attr('class', 'value');
190
+ return x$;
191
+ });
192
+ this.sites = this.g.shape.selectAll('g.label');
193
+ return this.sites.each(function(d, i){
194
+ return d3.select(this).selectAll('text').data([d, d]).attr('text-anchor', 'middle').attr('dominant-baseline', 'center');
195
+ });
196
+ },
197
+ resize: function(){
198
+ var box, ref$, w, h, s, sites;
199
+ box = this.layout.getBox('view');
200
+ ref$ = [box.width, box.height], w = ref$[0], h = ref$[1];
201
+ s = Math.min(w, h);
202
+ this.legend.config(this.cfg.legend);
203
+ this.legend.update();
204
+ this.layout.update(false);
205
+ this.g.shape.attr('transform', "translate(" + (w / 2 - s / 2) + "," + (h / 2 - s / 2) + ")");
206
+ this.scale = {
207
+ x: d3.scaleLinear().domain([0, w]).range([0, w]),
208
+ y: d3.scaleLinear().domain([0, h]).range([0, h]),
209
+ color: d3.interpolateTurbo
210
+ };
211
+ if (this.cfg != null && this.cfg.palette) {
212
+ this.scale.color = d3.interpolateDiscrete(this.cfg.palette.colors.map(function(it){
213
+ return ldcolor.web(it.value || it);
214
+ }));
215
+ }
216
+ this.tint.set(this.cfg.palette);
217
+ sites = this.treemap.getSites();
218
+ this.count = 0;
219
+ return this.gbox = this.svg.getBoundingClientRect();
220
+ },
221
+ render: function(tick){
222
+ var sites, polygons, ref$, w, h, siteBoxes, boxes, this$ = this;
223
+ tick == null && (tick = false);
224
+ this._sites = sites = this.treemap.getSites();
225
+ polygons = this.treemap.getPolygons();
226
+ ref$ = [this.box.width, this.box.height], w = ref$[0], h = ref$[1];
227
+ if (!tick) {
228
+ this.legend.render();
229
+ this.sites.selectAll('.name').attr('dy', '0.88em').text(function(it){
230
+ var n;
231
+ n = (it.name || '') + "";
232
+ return n;
233
+ if (it.lv > 0) {
234
+ return n.substring(0, 7) + (n.length > 7 ? '...' : '');
181
235
  } else {
182
- return 'data';
236
+ return '';
183
237
  }
238
+ }).attr('fill', function(d, i){
239
+ if (ldcolor.hcl(this$.tint.get(d.category)).l > 60) {
240
+ return '#000';
241
+ } else {
242
+ return '#eee';
243
+ }
244
+ }).style('pointer-events', 'none');
245
+ this.sites.selectAll('.value').attr('dy', '-0.28em').text(function(it){
246
+ if (it.lv > 0) {
247
+ return (it.value || 0).toFixed(2);
248
+ } else {
249
+ return '';
250
+ }
251
+ }).attr('fill', function(d, i){
252
+ if (ldcolor.hcl(this$.tint.get(d.category)).l > 60) {
253
+ return '#000';
254
+ } else {
255
+ return '#eee';
256
+ }
257
+ }).style('pointer-events', 'none');
258
+ this.siteBoxes = siteBoxes = [];
259
+ this.sites.each(function(d, i){
260
+ return siteBoxes.push(this.getBoundingClientRect());
184
261
  });
185
- this.polygons = this.g.shape.selectAll('path.data');
186
- y$ = this.g.shape.selectAll('g.label').data(sites);
187
- y$.exit().remove();
188
- y$.enter().append('g').attr('class', 'label').each(function(d, i){
189
- var x$;
190
- x$ = d3.select(this);
191
- x$.append('text').attr('class', 'name').attr('font-size', '.8em');
192
- x$.append('text').attr('class', 'value');
193
- return x$;
194
- });
195
- this.sites = this.g.shape.selectAll('g.label');
196
- return this.sites.each(function(d, i){
197
- return d3.select(this).selectAll('text').data([d, d]).attr('text-anchor', 'middle').attr('dominant-baseline', 'center');
198
- });
199
- },
200
- resize: function(){
201
- var box, ref$, w, h, s, sites;
202
- box = this.layout.getBox('view');
203
- ref$ = [box.width, box.height], w = ref$[0], h = ref$[1];
204
- s = Math.min(w, h);
205
- this.legend.config(this.cfg.legend);
206
- this.legend.update();
207
- this.layout.update(false);
208
- this.g.shape.attr('transform', "translate(" + (w / 2 - s / 2) + "," + (h / 2 - s / 2) + ")");
209
- this.scale = {
210
- x: d3.scaleLinear().domain([0, w]).range([0, w]),
211
- y: d3.scaleLinear().domain([0, h]).range([0, h]),
212
- color: d3.interpolateTurbo
213
- };
214
- if (this.cfg != null && this.cfg.palette) {
215
- this.scale.color = d3.interpolateDiscrete(this.cfg.palette.colors.map(function(it){
216
- return ldcolor.web(it.value || it);
217
- }));
218
- }
219
- this.tint.set(this.cfg.palette);
220
- sites = this.treemap.getSites();
221
- this.count = 0;
222
- return this.gbox = this.svg.getBoundingClientRect();
223
- },
224
- render: function(tick){
225
- var sites, polygons, ref$, w, h, siteBoxes, boxes, this$ = this;
226
- tick == null && (tick = false);
227
- this._sites = sites = this.treemap.getSites();
228
- polygons = this.treemap.getPolygons();
229
- ref$ = [this.box.width, this.box.height], w = ref$[0], h = ref$[1];
230
- if (!tick) {
231
- this.legend.render();
232
- this.sites.selectAll('.name').attr('dy', '0.88em').text(function(it){
233
- var n;
234
- n = (it.name || '') + "";
235
- return n;
236
- if (it.lv > 0) {
237
- return n.substring(0, 7) + (n.length > 7 ? '...' : '');
238
- } else {
239
- return '';
240
- }
241
- }).attr('fill', function(d, i){
242
- if (ldcolor.hcl(this$.tint.get(d.category)).l > 60) {
243
- return '#000';
244
- } else {
245
- return '#eee';
246
- }
247
- }).style('pointer-events', 'none');
248
- this.sites.selectAll('.value').attr('dy', '-0.28em').text(function(it){
249
- if (it.lv > 0) {
250
- return (it.value || 0).toFixed(2);
251
- } else {
252
- return '';
253
- }
254
- }).attr('fill', function(d, i){
255
- if (ldcolor.hcl(this$.tint.get(d.category)).l > 60) {
256
- return '#000';
257
- } else {
258
- return '#eee';
259
- }
260
- }).style('pointer-events', 'none');
261
- this.siteBoxes = siteBoxes = [];
262
- this.sites.each(function(d, i){
263
- return siteBoxes.push(this.getBoundingClientRect());
264
- });
265
- this.polygons.attr('fill', function(d, i){
266
- return this$.tint.get(sites[i].category);
267
- }).attr('stroke', '#fff').attr('stroke-width', 1);
262
+ this.polygons.attr('fill', function(d, i){
263
+ return this$.tint.get(sites[i].category);
264
+ }).attr('stroke', '#fff').attr('stroke-width', 1);
265
+ }
266
+ siteBoxes = this.siteBoxes;
267
+ boxes = [];
268
+ this.polygons.data(polygons).attr('d', function(d, i){
269
+ var ret, ref$, min, max, i$, to$, idx, x, y;
270
+ d.idx = i;
271
+ if (!(d && d.length)) {
272
+ boxes.push({});
273
+ return "";
268
274
  }
269
- siteBoxes = this.siteBoxes;
270
- boxes = [];
271
- this.polygons.data(polygons).attr('d', function(d, i){
272
- var ret, ref$, min, max, i$, to$, idx, x, y;
273
- d.idx = i;
274
- if (!(d && d.length)) {
275
- boxes.push({});
276
- return "";
275
+ ret = [['M', d[0].x, d[0].y]];
276
+ ref$ = [
277
+ {
278
+ x: d[0].x,
279
+ y: d[0].y
280
+ }, {
281
+ x: d[0].x,
282
+ y: d[0].y
277
283
  }
278
- ret = [['M', d[0].x, d[0].y]];
279
- ref$ = [
280
- {
281
- x: d[0].x,
282
- y: d[0].y
283
- }, {
284
- x: d[0].x,
285
- y: d[0].y
286
- }
287
- ], min = ref$[0], max = ref$[1];
288
- for (i$ = 0, to$ = d.length; i$ < to$; ++i$) {
289
- idx = i$;
290
- ref$ = [d[idx].x, d[idx].y], x = ref$[0], y = ref$[1];
291
- if (min.x > x) {
292
- min.x = x;
293
- }
294
- if (max.x < x) {
295
- max.x = x;
296
- }
297
- if (min.y > y) {
298
- min.y = y;
299
- }
300
- if (max.y < y) {
301
- max.y = y;
302
- }
303
- ret.push(['L', x, y]);
284
+ ], min = ref$[0], max = ref$[1];
285
+ for (i$ = 0, to$ = d.length; i$ < to$; ++i$) {
286
+ idx = i$;
287
+ ref$ = [d[idx].x, d[idx].y], x = ref$[0], y = ref$[1];
288
+ if (min.x > x) {
289
+ min.x = x;
304
290
  }
305
- ret.push(['L', d[0].x, d[0].y]);
306
- boxes.push({
307
- x: min.x,
308
- y: min.y,
309
- width: max.x - min.x,
310
- height: max.y - min.y
311
- });
312
- return ret.map(function(it){
313
- return it.join(' ');
314
- }).join(' ');
315
- });
316
- return this.sites.each(function(d, i){
317
- var box, mybox;
318
- box = boxes[i];
319
- mybox = siteBoxes[i];
320
- if (!mybox) {
321
- mybox = this.getBoundingClientRect();
291
+ if (max.x < x) {
292
+ max.x = x;
322
293
  }
323
- return d3.select(this).attr('transform', function(){
324
- var x, y;
325
- x = box.x + box.width / 2;
326
- y = box.y + box.height / 2;
327
- if (isNaN(x)) {
328
- x = -10000;
329
- }
330
- if (isNaN(y)) {
331
- y = -10000;
332
- }
333
- return "translate(" + x + ", " + y + ")";
334
- }).attr('opacity', function(){
335
- var ref$, ref1$, ref2$;
336
- return (ref$ = 1 - 6 * ((ref1$ = mybox.width / ((ref2$ = box.width) > 0 ? ref2$ : 0) - 1) > 0 ? ref1$ : 0)) > 0 ? ref$ : 0;
337
- });
294
+ if (min.y > y) {
295
+ min.y = y;
296
+ }
297
+ if (max.y < y) {
298
+ max.y = y;
299
+ }
300
+ ret.push(['L', x, y]);
301
+ }
302
+ ret.push(['L', d[0].x, d[0].y]);
303
+ boxes.push({
304
+ x: min.x,
305
+ y: min.y,
306
+ width: max.x - min.x,
307
+ height: max.y - min.y
338
308
  });
339
- },
340
- tick: function(){
341
- this.count = (this.count || 0) + 1;
342
- if (this.count < 100) {
343
- this.treemap.compute();
344
- return this.render(true);
309
+ return ret.map(function(it){
310
+ return it.join(' ');
311
+ }).join(' ');
312
+ });
313
+ return this.sites.each(function(d, i){
314
+ var box, mybox;
315
+ box = boxes[i];
316
+ mybox = siteBoxes[i];
317
+ if (!mybox) {
318
+ mybox = this.getBoundingClientRect();
345
319
  }
320
+ return d3.select(this).attr('transform', function(){
321
+ var x, y;
322
+ x = box.x + box.width / 2;
323
+ y = box.y + box.height / 2;
324
+ if (isNaN(x)) {
325
+ x = -10000;
326
+ }
327
+ if (isNaN(y)) {
328
+ y = -10000;
329
+ }
330
+ return "translate(" + x + ", " + y + ")";
331
+ }).attr('opacity', function(){
332
+ var ref$, ref1$, ref2$;
333
+ return (ref$ = 1 - 6 * ((ref1$ = mybox.width / ((ref2$ = box.width) > 0 ? ref2$ : 0) - 1) > 0 ? ref1$ : 0)) > 0 ? ref$ : 0;
334
+ });
335
+ });
336
+ },
337
+ tick: function(){
338
+ this.count = (this.count || 0) + 1;
339
+ if (this.count < 100) {
340
+ this.treemap.compute();
341
+ return this.render(true);
346
342
  }
347
- };
343
+ }
348
344
  };
349
- return blockFactory;
350
- });</script></div>
345
+ };</script></div>