@plotdb/chart 0.0.2 → 1.0.3

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 (164) hide show
  1. package/README.md +3 -3
  2. package/dist/chart.js +18 -12
  3. package/dist/chart.min.js +1 -1
  4. package/dist/index.css +8 -0
  5. package/dist/index.js +609 -0
  6. package/dist/index.min.css +1 -0
  7. package/dist/index.min.js +1 -0
  8. package/dist/utils/axis.js +6 -0
  9. package/dist/utils/axis.min.js +1 -1
  10. package/package.json +22 -11
  11. package/CHANGELOG.md +0 -11
  12. package/build +0 -39
  13. package/doc/charts.md +0 -58
  14. package/doc/config.md +0 -44
  15. package/doc/draft/chart.md +0 -146
  16. package/doc/draft/data.md +0 -8
  17. package/doc/draft/definition.md +0 -0
  18. package/doc/draft/events.md +0 -0
  19. package/doc/draft/filter.md +0 -0
  20. package/doc/draft/lifecycle.md +0 -89
  21. package/doc/spec.md +0 -89
  22. package/doc/todo.md +0 -27
  23. package/doc/utils/tip.md +0 -84
  24. package/src/chart.ls +0 -320
  25. package/src/chart.styl +0 -6
  26. package/src/data/en-US/category +0 -20
  27. package/src/data/en-US/fruit +0 -39
  28. package/src/data/en-US/movie +0 -125
  29. package/src/data/en-US/name +0 -58
  30. package/src/data/index.ls +0 -34
  31. package/src/data/zh-TW/category +0 -20
  32. package/src/data/zh-TW/fruits +0 -38
  33. package/src/data/zh-TW/movie +0 -125
  34. package/src/data/zh-TW/names +0 -105
  35. package/src/utils/axis.ls +0 -229
  36. package/src/utils/config.ls +0 -11
  37. package/src/utils/data.ls +0 -104
  38. package/src/utils/format.ls +0 -30
  39. package/src/utils/legend.ls +0 -134
  40. package/src/utils/legend.styl +0 -37
  41. package/src/utils/tint.ls +0 -66
  42. package/src/utils/tip.ls +0 -97
  43. package/web/src/pug/base.pug +0 -19
  44. package/web/src/pug/block/axis/0.0.1/index.ls +0 -38
  45. package/web/src/pug/block/axis/0.0.1/index.pug +0 -1
  46. package/web/src/pug/block/axis-bubble/0.0.1/index.ls +0 -141
  47. package/web/src/pug/block/axis-bubble/0.0.1/index.pug +0 -1
  48. package/web/src/pug/block/bar/0.0.1/index.ls +0 -274
  49. package/web/src/pug/block/bar/0.0.1/index.pug +0 -35
  50. package/web/src/pug/block/bar-list/0.0.1/index.ls +0 -85
  51. package/web/src/pug/block/bar-list/0.0.1/index.pug +0 -30
  52. package/web/src/pug/block/bar-race/0.0.1/index.ls +0 -83
  53. package/web/src/pug/block/bar-race/0.0.1/index.pug +0 -21
  54. package/web/src/pug/block/base/0.0.1/index.ls +0 -67
  55. package/web/src/pug/block/base/0.0.1/index.pug +0 -5
  56. package/web/src/pug/block/blank/0.0.1/index.ls +0 -25
  57. package/web/src/pug/block/blank/0.0.1/index.pug +0 -1
  58. package/web/src/pug/block/bubble/0.0.1/index.ls +0 -220
  59. package/web/src/pug/block/bubble/0.0.1/index.pug +0 -28
  60. package/web/src/pug/block/curve-bar/0.0.1/index.ls +0 -89
  61. package/web/src/pug/block/curve-bar/0.0.1/index.pug +0 -16
  62. package/web/src/pug/block/curve-bar/0.0.1/sample.js +0 -338
  63. package/web/src/pug/block/dumbbell/0.0.1/index.ls +0 -90
  64. package/web/src/pug/block/dumbbell/0.0.1/index.pug +0 -1
  65. package/web/src/pug/block/empty/0.0.1/index.ls +0 -27
  66. package/web/src/pug/block/empty/0.0.1/index.pug +0 -2
  67. package/web/src/pug/block/gauge/0.0.1/index.ls +0 -100
  68. package/web/src/pug/block/gauge/0.0.1/index.pug +0 -31
  69. package/web/src/pug/block/gauge/0.0.1/sample.js +0 -338
  70. package/web/src/pug/block/line/0.0.1/index.ls +0 -265
  71. package/web/src/pug/block/line/0.0.1/index.pug +0 -33
  72. package/web/src/pug/block/number/0.0.1/index.ls +0 -69
  73. package/web/src/pug/block/number/0.0.1/index.pug +0 -20
  74. package/web/src/pug/block/percent-list/0.0.1/index.ls +0 -167
  75. package/web/src/pug/block/percent-list/0.0.1/index.pug +0 -34
  76. package/web/src/pug/block/pie/0.0.1/index.ls +0 -125
  77. package/web/src/pug/block/pie/0.0.1/index.pug +0 -19
  78. package/web/src/pug/block/pie/0.0.1/sample.js +0 -338
  79. package/web/src/pug/block/pie-bubble/0.0.1/index.ls +0 -185
  80. package/web/src/pug/block/pie-bubble/0.0.1/index.pug +0 -40
  81. package/web/src/pug/block/radar/0.0.1/index.ls +0 -113
  82. package/web/src/pug/block/radar/0.0.1/index.pug +0 -1
  83. package/web/src/pug/block/radar/0.0.1/xx +0 -285
  84. package/web/src/pug/block/scatter/0.0.1/index.ls +0 -128
  85. package/web/src/pug/block/scatter/0.0.1/index.pug +0 -30
  86. package/web/src/pug/block/sheet/0.0.1/index.ls +0 -38
  87. package/web/src/pug/block/sheet/0.0.1/index.pug +0 -5
  88. package/web/src/pug/block/table/0.0.1/index.ls +0 -40
  89. package/web/src/pug/block/table/0.0.1/index.pug +0 -3
  90. package/web/src/pug/block/taiwantown/0.0.1/index.ls +0 -48
  91. package/web/src/pug/block/taiwantown/0.0.1/index.pug +0 -52
  92. package/web/src/pug/block/taiwanvillage/0.0.1/index.ls +0 -53
  93. package/web/src/pug/block/taiwanvillage/0.0.1/index.pug +0 -52
  94. package/web/src/pug/block/treemap/0.0.1/index.ls +0 -172
  95. package/web/src/pug/block/treemap/0.0.1/index.pug +0 -42
  96. package/web/src/pug/block/voronoi-treemap/0.0.1/index.ls +0 -174
  97. package/web/src/pug/block/voronoi-treemap/0.0.1/index.pug +0 -17
  98. package/web/src/pug/block/voronoi-treemap/0.0.1/sample.js +0 -241
  99. package/web/src/pug/block/wordcloud/0.0.1/index.ls +0 -61
  100. package/web/src/pug/block/wordcloud/0.0.1/index.pug +0 -1
  101. package/web/src/pug/block/worldmap/0.0.1/index.ls +0 -83
  102. package/web/src/pug/block/worldmap/0.0.1/index.pug +0 -12
  103. package/web/src/pug/index.ls +0 -72
  104. package/web/src/pug/index.pug +0 -52
  105. package/web/src/styl/index.styl +0 -0
  106. package/web/static/assets/block/cache.js +0 -4
  107. package/web/static/assets/custom-lib/d3/d3-array.v2.min.js +0 -2
  108. package/web/static/assets/custom-lib/d3/d3-axis.v2.min.js +0 -2
  109. package/web/static/assets/custom-lib/d3/d3-brush.v2.min.js +0 -2
  110. package/web/static/assets/custom-lib/d3/d3-color.v2.min.js +0 -2
  111. package/web/static/assets/custom-lib/d3/d3-dispatch.v2.min.js +0 -2
  112. package/web/static/assets/custom-lib/d3/d3-drag.v2.min.js +0 -2
  113. package/web/static/assets/custom-lib/d3/d3-ease.v2.min.js +0 -2
  114. package/web/static/assets/custom-lib/d3/d3-force-boundary.v0.0.1.min.js +0 -2
  115. package/web/static/assets/custom-lib/d3/d3-force.v2.min.js +0 -2
  116. package/web/static/assets/custom-lib/d3/d3-format.v2.min.js +0 -2
  117. package/web/static/assets/custom-lib/d3/d3-hierarchy.v2.min.js +0 -2
  118. package/web/static/assets/custom-lib/d3/d3-interpolate.v2.min.js +0 -2
  119. package/web/static/assets/custom-lib/d3/d3-path.v2.min.js +0 -2
  120. package/web/static/assets/custom-lib/d3/d3-quadtree.v2.min.js +0 -2
  121. package/web/static/assets/custom-lib/d3/d3-random.v2.min.js +0 -2
  122. package/web/static/assets/custom-lib/d3/d3-scale-chromatic.v1.min.js +0 -2
  123. package/web/static/assets/custom-lib/d3/d3-selection.v2.min.js +0 -2
  124. package/web/static/assets/custom-lib/d3/d3-shape.v2.min.js +0 -2
  125. package/web/static/assets/custom-lib/d3/d3-timer.v2.min.js +0 -2
  126. package/web/static/assets/custom-lib/d3/d3-transition.v2.min.js +0 -2
  127. package/web/static/assets/custom-lib/d3/d3.v4.js +0 -17178
  128. package/web/static/assets/custom-lib/d3/d3.v4.min.js +0 -2
  129. package/web/static/assets/data/countrycode.json +0 -1
  130. package/web/static/assets/data/world-110m.json +0 -1
  131. package/web/static/assets/data/zh-to-alpha2.json +0 -1
  132. package/web/static/assets/img/fluid.svg +0 -16
  133. package/web/static/block/axis/0.0.1/index.html +0 -79
  134. package/web/static/block/axis-bubble/0.0.1/index.html +0 -222
  135. package/web/static/block/bar/0.0.1/index.html +0 -581
  136. package/web/static/block/bar-list/0.0.1/index.html +0 -231
  137. package/web/static/block/bar-race/0.0.1/index.html +0 -184
  138. package/web/static/block/base/0.0.1/index.html +0 -197
  139. package/web/static/block/blank/0.0.1/index.html +0 -42
  140. package/web/static/block/bubble/0.0.1/index.html +0 -402
  141. package/web/static/block/bubble/0.0.1/test.html +0 -0
  142. package/web/static/block/curve-bar/0.0.1/index.html +0 -148
  143. package/web/static/block/dumbbell/0.0.1/index.html +0 -178
  144. package/web/static/block/empty/0.0.1/index.html +0 -76
  145. package/web/static/block/gauge/0.0.1/index.html +0 -150
  146. package/web/static/block/line/0.0.1/index.html +0 -540
  147. package/web/static/block/number/0.0.1/index.html +0 -152
  148. package/web/static/block/percent-list/0.0.1/index.html +0 -316
  149. package/web/static/block/pie/0.0.1/index.html +0 -281
  150. package/web/static/block/pie-bubble/0.0.1/index.html +0 -358
  151. package/web/static/block/radar/0.0.1/index.html +0 -149
  152. package/web/static/block/scatter/0.0.1/index.html +0 -251
  153. package/web/static/block/sheet/0.0.1/index.html +0 -103
  154. package/web/static/block/table/0.0.1/index.html +0 -73
  155. package/web/static/block/taiwantown/0.0.1/index.html +0 -210
  156. package/web/static/block/taiwanvillage/0.0.1/index.html +0 -220
  157. package/web/static/block/treemap/0.0.1/index.html +0 -360
  158. package/web/static/block/voronoi-treemap/0.0.1/index.html +0 -350
  159. package/web/static/block/wordcloud/0.0.1/index.html +0 -92
  160. package/web/static/block/worldmap/0.0.1/index.html +0 -207
  161. package/web/static/css/index.css +0 -0
  162. package/web/static/css/index.min.css +0 -0
  163. package/web/static/favicon.ico +0 -0
  164. package/web/static/index.html +0 -153
@@ -1,220 +0,0 @@
1
- <div><script type="@plotdb/block">(function(it){
2
- return it();
3
- })(function(){
4
- var blockFactory, mod;
5
- blockFactory = {
6
- pkg: {
7
- name: 'taiwanvillage',
8
- version: '0.0.1',
9
- extend: {
10
- name: "base",
11
- version: "0.0.1"
12
- },
13
- dependencies: [
14
- {
15
- url: "https://d3js.org/topojson.v2.min.js",
16
- async: false
17
- }, {
18
- url: "/js/work/map.list.js",
19
- async: false
20
- }, {
21
- url: "https://cdn.jsdelivr.net/npm/pdmaptw@0.0.2/dist/pdmaptw.min.js"
22
- }
23
- ]
24
- },
25
- init: function(arg$){
26
- var root, context, pubsub;
27
- root = arg$.root, context = arg$.context, pubsub = arg$.pubsub;
28
- return pubsub.fire('init', {
29
- mod: mod({
30
- context: context
31
- })
32
- }).then(function(it){
33
- return it[0];
34
- });
35
- }
36
- };
37
- mod = function(arg$){
38
- var context, d3, forceBoundary, ldColor, repeatString$, pdmaptw, counties, towns, villages;
39
- context = arg$.context;
40
- d3 = context.d3, forceBoundary = context.forceBoundary, ldColor = context.ldColor, repeatString$ = context.repeatString$, pdmaptw = context.pdmaptw, counties = context.counties, towns = context.towns, villages = context.villages;
41
- return {
42
- sample: function(){
43
- var val;
44
- val = {
45
- counties: counties.map(function(d, i){
46
- return {
47
- val: Math.random(),
48
- county: d
49
- };
50
- }),
51
- towns: towns.map(function(d, i){
52
- return {
53
- val: Math.random(),
54
- town: d
55
- };
56
- }),
57
- villages: villages.map(function(d, i){
58
- return {
59
- val: Math.random(),
60
- village: d
61
- };
62
- })
63
- };
64
- return {
65
- raw: val.villages,
66
- binding: {
67
- color: {
68
- key: 'val'
69
- },
70
- name: {
71
- key: 'village'
72
- }
73
- }
74
- };
75
- },
76
- config: {},
77
- dimension: {
78
- name: {
79
- type: 'N',
80
- name: "國家"
81
- },
82
- color: {
83
- type: 'R',
84
- name: "顏色"
85
- }
86
- },
87
- init: function(){
88
- var this$ = this;
89
- this.obj = pdmaptw.create({
90
- root: this.svg,
91
- type: 'village',
92
- baseurl: 'https://cdn.jsdelivr.net/npm/pdmaptw@0.0.2/dist'
93
- });
94
- return this.obj.init().then(function(){
95
- return this$.obj.fit();
96
- });
97
- },
98
- parse: function(){
99
- var this$ = this;
100
- d3.select(this.svg).selectAll('path').each(function(d, i){
101
- return d.data = this$.data.filter(function(it){
102
- return it.name === d.properties.name;
103
- })[0] || {};
104
- });
105
- d3.select(this.svg).selectAll('path').filter(function(d, i){
106
- return !/彰化縣/.exec(d.properties.name);
107
- }).remove();
108
- return this.obj.fit();
109
- },
110
- resize: function(){},
111
- render: function(){
112
- var this$ = this;
113
- this.color = d3.interpolateTurbo;
114
- if (this.cfg != null && this.cfg.palette) {
115
- this.color = d3.interpolateDiscrete(this.cfg.palette.colors.map(function(it){
116
- return ldColor.web(it.value || it);
117
- }));
118
- }
119
- return d3.select(this.svg).selectAll('path').transition().duration(350).attr('fill', function(d, i){
120
- return this$.color(d.data.color);
121
- });
122
- }
123
- };
124
- };
125
- return blockFactory;
126
- });</script></div><div><script type="@plotdb/block">({
127
- pkg: {
128
- name: 'taiwantown',
129
- version: '0.0.1',
130
- dependencies: [
131
- {
132
- url: "https://d3js.org/d3.v4.js",
133
- async: false
134
- }, "https://d3js.org/d3-format.v2.min.js", "https://d3js.org/d3-array.v2.min.js", "https://d3js.org/topojson.v2.min.js", {
135
- url: "https://d3js.org/d3-color.v1.min.js",
136
- async: false
137
- }, {
138
- url: "https://d3js.org/d3-interpolate.v1.min.js",
139
- async: false
140
- }, {
141
- url: "https://d3js.org/d3-scale-chromatic.v1.min.js",
142
- async: false
143
- }, "/js/map.list.js", "https://cdn.jsdelivr.net/npm/pdmaptw@0.0.2/dist/pdmaptw.min.js"
144
- ]
145
- },
146
- init: function(arg$){
147
- var root, context, counties, towns, c;
148
- root = arg$.root, context = arg$.context;
149
- counties = context.counties.map(function(d, i){
150
- return {
151
- val: Math.random(),
152
- county: d
153
- };
154
- });
155
- towns = context.towns.map(function(d, i){
156
- return {
157
- val: Math.random(),
158
- town: d
159
- };
160
- });
161
- c = new chart({
162
- root: root,
163
- raw: towns,
164
- mod: this.mod({
165
- context: context
166
- }),
167
- binding: {
168
- color: {
169
- name: 'val'
170
- },
171
- name: {
172
- name: 'town'
173
- }
174
- }
175
- });
176
- c.init().then(function(){
177
- return c.render();
178
- });
179
- return this.c = c;
180
- },
181
- 'interface': function(){
182
- return this.c;
183
- },
184
- mod: function(arg$){
185
- var context;
186
- context = arg$.context;
187
- return {
188
- init: function(){
189
- var this$ = this;
190
- this.obj = context.pdmaptw.create({
191
- root: this.svg,
192
- type: 'town',
193
- baseurl: 'https://cdn.jsdelivr.net/npm/pdmaptw@0.0.2/dist'
194
- });
195
- return this.obj.init().then(function(){
196
- return this$.obj.fit();
197
- });
198
- },
199
- parse: function(){
200
- var this$ = this;
201
- return d3.select(this.svg).selectAll('path').each(function(d, i){
202
- return d.data = this$.data.filter(function(it){
203
- return it.name === d.properties.name;
204
- })[0] || {};
205
- });
206
- },
207
- resize: function(){},
208
- render: function(){
209
- var this$ = this;
210
- this.color = d3.interpolateTurbo;
211
- if (config.pal) {
212
- this.color = d3.interpolateDiscrete(config.pal);
213
- }
214
- return d3.select(this.svg).selectAll('path').transition().duration(350).attr('fill', function(d, i){
215
- return this$.color(d.data.color);
216
- });
217
- }
218
- };
219
- }
220
- });</script></div>
@@ -1,360 +0,0 @@
1
- <div><div plug="layout"><div class="pdl-layout"><div data-type="layout"><div class="pdl-cell" data-name="view"></div><div class="pdl-cell" data-name="unit"></div><div class="pdl-cell" data-name="legend"></div></div><div data-type="render"></div></div></div><style type="text/css">.pdl-layout > div[data-type=layout] {
2
- display: grid;
3
- grid-template-columns: 1fr fit-content(10em);
4
- grid-template-rows: 1fr fit-content(1em);
5
- }
6
- .pdl-layout > div[data-type=layout] > .pdl-cell[data-name=view] {
7
- grid-area: 1/1;
8
- }
9
- .pdl-layout > div[data-type=layout] > .pdl-cell[data-name=legend] {
10
- grid-column: 2;
11
- grid-row: 1/span 2;
12
- padding: 0 0.5em 0 0.5em;
13
- }
14
- .pdl-layout > div[data-type=layout] > .pdl-cell[data-name=unit] {
15
- grid-column: 1;
16
- grid-row: 2;
17
- line-height: 1em;
18
- text-align: right;
19
- padding: 0.25em 0;
20
- }
21
- .pdl-layout.legend-bottom > div[data-type=layout] {
22
- grid-template-columns: 1fr fit-content(1em);
23
- grid-template-rows: 1fr fit-content(3em);
24
- }
25
- .pdl-layout.legend-bottom > div[data-type=layout] .pdl-cell[data-name=view] {
26
- grid-column: 1/span 2;
27
- grid-row: 1;
28
- }
29
- .pdl-layout.legend-bottom > div[data-type=layout] .pdl-cell[data-name=legend] {
30
- padding-top: 1em;
31
- grid-column: 1;
32
- grid-row: 2;
33
- }
34
- .pdl-layout.legend-bottom > div[data-type=layout] .pdl-cell[data-name=unit] {
35
- padding-top: 1em;
36
- grid-column: 2;
37
- grid-row: 2;
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
- }
58
- },
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
- });
69
- }
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));
158
- },
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
- };
184
- },
185
- range: function(){
186
- return this$.layout.getNode('view').getBoundingClientRect();
187
- }
188
- });
189
- },
190
- destroy: function(){
191
- return this.tip.destroy();
192
- },
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
- });
207
- }
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);
224
- }
225
- return results$;
226
- }()), [{
227
- id: 'root'
228
- }]);
229
- return this.legend.data(this.cats.map(function(it){
230
- return {
231
- key: it,
232
- text: it
233
- };
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;
246
- });
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 || '') : ''
258
- };
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;
324
- });
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;
349
- });
350
- return this.legend.render();
351
- }
352
- };
353
- };
354
- return blockFactory;
355
- });
356
- function import$(obj, src){
357
- var own = {}.hasOwnProperty;
358
- for (var key in src) if (own.call(src, key)) obj[key] = src[key];
359
- return obj;
360
- }</script></div>