@plotdb/chart 0.0.2

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 (177) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +50 -0
  3. package/build +39 -0
  4. package/dist/chart.css +8 -0
  5. package/dist/chart.js +603 -0
  6. package/dist/chart.min.css +1 -0
  7. package/dist/chart.min.js +1 -0
  8. package/dist/data/index.js +73 -0
  9. package/dist/utils/axis.js +357 -0
  10. package/dist/utils/axis.min.js +1 -0
  11. package/dist/utils/config.js +33 -0
  12. package/dist/utils/config.min.js +1 -0
  13. package/dist/utils/data.js +238 -0
  14. package/dist/utils/data.min.js +1 -0
  15. package/dist/utils/format.js +70 -0
  16. package/dist/utils/format.min.js +1 -0
  17. package/dist/utils/legend.css +40 -0
  18. package/dist/utils/legend.js +263 -0
  19. package/dist/utils/legend.min.css +1 -0
  20. package/dist/utils/legend.min.js +1 -0
  21. package/dist/utils/tint.js +138 -0
  22. package/dist/utils/tint.min.js +1 -0
  23. package/dist/utils/tip.js +148 -0
  24. package/dist/utils/tip.min.js +1 -0
  25. package/doc/charts.md +58 -0
  26. package/doc/config.md +44 -0
  27. package/doc/draft/chart.md +146 -0
  28. package/doc/draft/data.md +8 -0
  29. package/doc/draft/definition.md +0 -0
  30. package/doc/draft/events.md +0 -0
  31. package/doc/draft/filter.md +0 -0
  32. package/doc/draft/lifecycle.md +89 -0
  33. package/doc/spec.md +89 -0
  34. package/doc/todo.md +27 -0
  35. package/doc/utils/tip.md +84 -0
  36. package/package.json +83 -0
  37. package/src/chart.ls +320 -0
  38. package/src/chart.styl +6 -0
  39. package/src/data/en-US/category +20 -0
  40. package/src/data/en-US/fruit +39 -0
  41. package/src/data/en-US/movie +125 -0
  42. package/src/data/en-US/name +58 -0
  43. package/src/data/index.ls +34 -0
  44. package/src/data/zh-TW/category +20 -0
  45. package/src/data/zh-TW/fruits +38 -0
  46. package/src/data/zh-TW/movie +125 -0
  47. package/src/data/zh-TW/names +105 -0
  48. package/src/utils/axis.ls +229 -0
  49. package/src/utils/config.ls +11 -0
  50. package/src/utils/data.ls +104 -0
  51. package/src/utils/format.ls +30 -0
  52. package/src/utils/legend.ls +134 -0
  53. package/src/utils/legend.styl +37 -0
  54. package/src/utils/tint.ls +66 -0
  55. package/src/utils/tip.ls +97 -0
  56. package/web/src/pug/base.pug +19 -0
  57. package/web/src/pug/block/axis/0.0.1/index.ls +38 -0
  58. package/web/src/pug/block/axis/0.0.1/index.pug +1 -0
  59. package/web/src/pug/block/axis-bubble/0.0.1/index.ls +141 -0
  60. package/web/src/pug/block/axis-bubble/0.0.1/index.pug +1 -0
  61. package/web/src/pug/block/bar/0.0.1/index.ls +274 -0
  62. package/web/src/pug/block/bar/0.0.1/index.pug +35 -0
  63. package/web/src/pug/block/bar-list/0.0.1/index.ls +85 -0
  64. package/web/src/pug/block/bar-list/0.0.1/index.pug +30 -0
  65. package/web/src/pug/block/bar-race/0.0.1/index.ls +83 -0
  66. package/web/src/pug/block/bar-race/0.0.1/index.pug +21 -0
  67. package/web/src/pug/block/base/0.0.1/index.ls +67 -0
  68. package/web/src/pug/block/base/0.0.1/index.pug +5 -0
  69. package/web/src/pug/block/blank/0.0.1/index.ls +25 -0
  70. package/web/src/pug/block/blank/0.0.1/index.pug +1 -0
  71. package/web/src/pug/block/bubble/0.0.1/index.ls +220 -0
  72. package/web/src/pug/block/bubble/0.0.1/index.pug +28 -0
  73. package/web/src/pug/block/curve-bar/0.0.1/index.ls +89 -0
  74. package/web/src/pug/block/curve-bar/0.0.1/index.pug +16 -0
  75. package/web/src/pug/block/curve-bar/0.0.1/sample.js +338 -0
  76. package/web/src/pug/block/dumbbell/0.0.1/index.ls +90 -0
  77. package/web/src/pug/block/dumbbell/0.0.1/index.pug +1 -0
  78. package/web/src/pug/block/empty/0.0.1/index.ls +27 -0
  79. package/web/src/pug/block/empty/0.0.1/index.pug +2 -0
  80. package/web/src/pug/block/gauge/0.0.1/index.ls +100 -0
  81. package/web/src/pug/block/gauge/0.0.1/index.pug +31 -0
  82. package/web/src/pug/block/gauge/0.0.1/sample.js +338 -0
  83. package/web/src/pug/block/line/0.0.1/index.ls +265 -0
  84. package/web/src/pug/block/line/0.0.1/index.pug +33 -0
  85. package/web/src/pug/block/number/0.0.1/index.ls +69 -0
  86. package/web/src/pug/block/number/0.0.1/index.pug +20 -0
  87. package/web/src/pug/block/percent-list/0.0.1/index.ls +167 -0
  88. package/web/src/pug/block/percent-list/0.0.1/index.pug +34 -0
  89. package/web/src/pug/block/pie/0.0.1/index.ls +125 -0
  90. package/web/src/pug/block/pie/0.0.1/index.pug +19 -0
  91. package/web/src/pug/block/pie/0.0.1/sample.js +338 -0
  92. package/web/src/pug/block/pie-bubble/0.0.1/index.ls +185 -0
  93. package/web/src/pug/block/pie-bubble/0.0.1/index.pug +40 -0
  94. package/web/src/pug/block/radar/0.0.1/index.ls +113 -0
  95. package/web/src/pug/block/radar/0.0.1/index.pug +1 -0
  96. package/web/src/pug/block/radar/0.0.1/xx +285 -0
  97. package/web/src/pug/block/scatter/0.0.1/index.ls +128 -0
  98. package/web/src/pug/block/scatter/0.0.1/index.pug +30 -0
  99. package/web/src/pug/block/sheet/0.0.1/index.ls +38 -0
  100. package/web/src/pug/block/sheet/0.0.1/index.pug +5 -0
  101. package/web/src/pug/block/table/0.0.1/index.ls +40 -0
  102. package/web/src/pug/block/table/0.0.1/index.pug +3 -0
  103. package/web/src/pug/block/taiwantown/0.0.1/index.ls +48 -0
  104. package/web/src/pug/block/taiwantown/0.0.1/index.pug +52 -0
  105. package/web/src/pug/block/taiwanvillage/0.0.1/index.ls +53 -0
  106. package/web/src/pug/block/taiwanvillage/0.0.1/index.pug +52 -0
  107. package/web/src/pug/block/treemap/0.0.1/index.ls +172 -0
  108. package/web/src/pug/block/treemap/0.0.1/index.pug +42 -0
  109. package/web/src/pug/block/voronoi-treemap/0.0.1/index.ls +174 -0
  110. package/web/src/pug/block/voronoi-treemap/0.0.1/index.pug +17 -0
  111. package/web/src/pug/block/voronoi-treemap/0.0.1/sample.js +241 -0
  112. package/web/src/pug/block/wordcloud/0.0.1/index.ls +61 -0
  113. package/web/src/pug/block/wordcloud/0.0.1/index.pug +1 -0
  114. package/web/src/pug/block/worldmap/0.0.1/index.ls +83 -0
  115. package/web/src/pug/block/worldmap/0.0.1/index.pug +12 -0
  116. package/web/src/pug/index.ls +72 -0
  117. package/web/src/pug/index.pug +52 -0
  118. package/web/src/styl/index.styl +0 -0
  119. package/web/static/assets/block/cache.js +4 -0
  120. package/web/static/assets/custom-lib/d3/d3-array.v2.min.js +2 -0
  121. package/web/static/assets/custom-lib/d3/d3-axis.v2.min.js +2 -0
  122. package/web/static/assets/custom-lib/d3/d3-brush.v2.min.js +2 -0
  123. package/web/static/assets/custom-lib/d3/d3-color.v2.min.js +2 -0
  124. package/web/static/assets/custom-lib/d3/d3-dispatch.v2.min.js +2 -0
  125. package/web/static/assets/custom-lib/d3/d3-drag.v2.min.js +2 -0
  126. package/web/static/assets/custom-lib/d3/d3-ease.v2.min.js +2 -0
  127. package/web/static/assets/custom-lib/d3/d3-force-boundary.v0.0.1.min.js +2 -0
  128. package/web/static/assets/custom-lib/d3/d3-force.v2.min.js +2 -0
  129. package/web/static/assets/custom-lib/d3/d3-format.v2.min.js +2 -0
  130. package/web/static/assets/custom-lib/d3/d3-hierarchy.v2.min.js +2 -0
  131. package/web/static/assets/custom-lib/d3/d3-interpolate.v2.min.js +2 -0
  132. package/web/static/assets/custom-lib/d3/d3-path.v2.min.js +2 -0
  133. package/web/static/assets/custom-lib/d3/d3-quadtree.v2.min.js +2 -0
  134. package/web/static/assets/custom-lib/d3/d3-random.v2.min.js +2 -0
  135. package/web/static/assets/custom-lib/d3/d3-scale-chromatic.v1.min.js +2 -0
  136. package/web/static/assets/custom-lib/d3/d3-selection.v2.min.js +2 -0
  137. package/web/static/assets/custom-lib/d3/d3-shape.v2.min.js +2 -0
  138. package/web/static/assets/custom-lib/d3/d3-timer.v2.min.js +2 -0
  139. package/web/static/assets/custom-lib/d3/d3-transition.v2.min.js +2 -0
  140. package/web/static/assets/custom-lib/d3/d3.v4.js +17178 -0
  141. package/web/static/assets/custom-lib/d3/d3.v4.min.js +2 -0
  142. package/web/static/assets/data/countrycode.json +1 -0
  143. package/web/static/assets/data/world-110m.json +1 -0
  144. package/web/static/assets/data/zh-to-alpha2.json +1 -0
  145. package/web/static/assets/img/fluid.svg +16 -0
  146. package/web/static/block/axis/0.0.1/index.html +79 -0
  147. package/web/static/block/axis-bubble/0.0.1/index.html +222 -0
  148. package/web/static/block/bar/0.0.1/index.html +581 -0
  149. package/web/static/block/bar-list/0.0.1/index.html +231 -0
  150. package/web/static/block/bar-race/0.0.1/index.html +184 -0
  151. package/web/static/block/base/0.0.1/index.html +197 -0
  152. package/web/static/block/blank/0.0.1/index.html +42 -0
  153. package/web/static/block/bubble/0.0.1/index.html +402 -0
  154. package/web/static/block/bubble/0.0.1/test.html +0 -0
  155. package/web/static/block/curve-bar/0.0.1/index.html +148 -0
  156. package/web/static/block/dumbbell/0.0.1/index.html +178 -0
  157. package/web/static/block/empty/0.0.1/index.html +76 -0
  158. package/web/static/block/gauge/0.0.1/index.html +150 -0
  159. package/web/static/block/line/0.0.1/index.html +540 -0
  160. package/web/static/block/number/0.0.1/index.html +152 -0
  161. package/web/static/block/percent-list/0.0.1/index.html +316 -0
  162. package/web/static/block/pie/0.0.1/index.html +281 -0
  163. package/web/static/block/pie-bubble/0.0.1/index.html +358 -0
  164. package/web/static/block/radar/0.0.1/index.html +149 -0
  165. package/web/static/block/scatter/0.0.1/index.html +251 -0
  166. package/web/static/block/sheet/0.0.1/index.html +103 -0
  167. package/web/static/block/table/0.0.1/index.html +73 -0
  168. package/web/static/block/taiwantown/0.0.1/index.html +210 -0
  169. package/web/static/block/taiwanvillage/0.0.1/index.html +220 -0
  170. package/web/static/block/treemap/0.0.1/index.html +360 -0
  171. package/web/static/block/voronoi-treemap/0.0.1/index.html +350 -0
  172. package/web/static/block/wordcloud/0.0.1/index.html +92 -0
  173. package/web/static/block/worldmap/0.0.1/index.html +207 -0
  174. package/web/static/css/index.css +0 -0
  175. package/web/static/css/index.min.css +0 -0
  176. package/web/static/favicon.ico +0 -0
  177. package/web/static/index.html +153 -0
@@ -0,0 +1,238 @@
1
+ (function(){
2
+ var main;
3
+ main = {
4
+ number: function(opt){
5
+ var data, len;
6
+ opt == null && (opt = {});
7
+ data = opt.data.filter(function(it){
8
+ return !(!it || (it + "").trim() === '');
9
+ });
10
+ len = data.filter(function(it){
11
+ return !isNaN(parseFloat(it));
12
+ }).length;
13
+ return len / data.length;
14
+ },
15
+ serial: function(opt){
16
+ var data, hash, i$, to$, i, delta, k;
17
+ opt == null && (opt = {});
18
+ data = [].concat(opt.data);
19
+ data.sort(function(a, b){
20
+ return b - a;
21
+ });
22
+ hash = {};
23
+ for (i$ = 1, to$ = data.length; i$ < to$; ++i$) {
24
+ i = i$;
25
+ if (isNaN(data[i]) || isNaN(data[i - 1])) {
26
+ hash[data[i] > data[i - 1]
27
+ ? data[i] + ":" + data[i - 1]
28
+ : data[i - 1] + ":" + data[i]] = true;
29
+ } else {
30
+ delta = data[i] - data[i - 1];
31
+ }
32
+ hash[delta] = true;
33
+ }
34
+ return 1 / ((function(){
35
+ var results$ = [];
36
+ for (k in hash) {
37
+ results$.push(k);
38
+ }
39
+ return results$;
40
+ }()).filter(function(it){
41
+ return it !== '0';
42
+ }).length || 2);
43
+ },
44
+ text: function(opt){
45
+ opt == null && (opt = {});
46
+ return 1 - this.number(opt);
47
+ },
48
+ category: function(opt){
49
+ var len, maxlen, ret, ref$, ref1$, ref2$;
50
+ opt == null && (opt = {});
51
+ len = Array.from(new Set(opt.data)).length;
52
+ maxlen = opt.data.length;
53
+ ret = (ref$ = (ref1$ = 1 - ((ref2$ = len - 2) > 0 ? ref2$ : 0) / maxlen - 1 / maxlen) > 0 ? ref1$ : 0) < 1 ? ref$ : 1;
54
+ if (this.number(opt)) {
55
+ ret = ret * 0.9;
56
+ }
57
+ return ret;
58
+ },
59
+ parse: function(data){
60
+ var head, body;
61
+ if (Array.isArray(data)) {
62
+ head = data.slice(0, 1)[0];
63
+ body = data.slice(1);
64
+ body = body.map(function(d, i){
65
+ var ret;
66
+ ret = {};
67
+ head.map(function(h, j){
68
+ return ret[h] = d[j];
69
+ });
70
+ return ret;
71
+ });
72
+ return {
73
+ head: head,
74
+ body: body
75
+ };
76
+ }
77
+ return data;
78
+ },
79
+ autotype: function(data){
80
+ var head, res$, k, type, i$, len$, key, d, ret, list;
81
+ data == null && (data = []);
82
+ res$ = [];
83
+ for (k in data[0] || {}) {
84
+ res$.push(k);
85
+ }
86
+ head = res$;
87
+ type = [];
88
+ for (i$ = 0, len$ = head.length; i$ < len$; ++i$) {
89
+ key = head[i$];
90
+ d = data.map(fn$);
91
+ ret = {
92
+ key: key,
93
+ types: {
94
+ R: main.number({
95
+ data: d
96
+ }),
97
+ O: main.serial({
98
+ data: d
99
+ }),
100
+ N: main.text({
101
+ data: d
102
+ }),
103
+ C: main.category({
104
+ data: d
105
+ })
106
+ }
107
+ };
108
+ list = ['R', 'O', 'N', 'C'].map(fn1$);
109
+ list.sort(fn2$);
110
+ ret.type = list[0][0];
111
+ type.push(ret);
112
+ }
113
+ return type;
114
+ function fn$(it){
115
+ return it[key];
116
+ }
117
+ function fn1$(it){
118
+ return [it, ret.types[it]];
119
+ }
120
+ function fn2$(a, b){
121
+ return b[1] - a[1];
122
+ }
123
+ },
124
+ autobind: function(data, dimension){
125
+ var datatypes, dims, k, v, i$, len$, dim, ts, j$, to$, i, t, k$, to1$, dt, ret;
126
+ data == null && (data = []);
127
+ dimension == null && (dimension = {});
128
+ datatypes = this.autotype(data);
129
+ dims = (function(){
130
+ var ref$, results$ = [];
131
+ for (k in ref$ = dimension) {
132
+ v = ref$[k];
133
+ results$.push({
134
+ k: k,
135
+ v: v
136
+ });
137
+ }
138
+ return results$;
139
+ }()).filter(function(it){
140
+ return !it.v.passive;
141
+ });
142
+ dims.sort(function(a, b){
143
+ var ret, ref$, ma, mb;
144
+ ret = (a.v.priority || 100) - (b.v.priority || 100);
145
+ if (ret !== 0) {
146
+ return ret;
147
+ }
148
+ ref$ = [a.v.type || 'R', b.v.type || 'R'].map(function(t){
149
+ return Math.min.apply(Math, (function(){
150
+ var i$, to$, results$ = [];
151
+ for (i$ = 0, to$ = t.length; i$ < to$; ++i$) {
152
+ results$.push(i$);
153
+ }
154
+ return results$;
155
+ }()).map(function(i){
156
+ return "CONR".indexOf(t[i]);
157
+ }));
158
+ }), ma = ref$[0], mb = ref$[1];
159
+ return ma - mb;
160
+ });
161
+ for (i$ = 0, len$ = dims.length; i$ < len$; ++i$) {
162
+ dim = dims[i$];
163
+ dim.bind = null;
164
+ ts = dim.v.type || 'RNOC';
165
+ for (j$ = 0, to$ = ts.length; j$ < to$; ++j$) {
166
+ i = j$;
167
+ t = ts[i];
168
+ datatypes.sort(fn$);
169
+ for (k$ = 0, to1$ = datatypes.length; k$ < to1$; ++k$) {
170
+ i = k$;
171
+ dt = datatypes[i];
172
+ if (dt.types[t] < 0.5 || dt.used || (t === 'C' && dt.types.R > 0.5)) {
173
+ continue;
174
+ }
175
+ dim.bind = dim.v.multiple ? [dt] : dt;
176
+ dt.used = true;
177
+ break;
178
+ }
179
+ }
180
+ }
181
+ for (i$ = 0, len$ = dims.length; i$ < len$; ++i$) {
182
+ dim = dims[i$];
183
+ if (!dim.v.multiple) {
184
+ continue;
185
+ }
186
+ ts = dim.v.type || 'RNOC';
187
+ for (j$ = 0, to$ = ts.length; j$ < to$; ++j$) {
188
+ i = j$;
189
+ t = ts[i];
190
+ datatypes.sort(fn1$);
191
+ for (k$ = 0, to1$ = datatypes.length; k$ < to1$; ++k$) {
192
+ i = k$;
193
+ dt = datatypes[i];
194
+ if (dt.types[t] < 0.5 || dt.used || (t === 'C' && dt.types.R > 0.5)) {
195
+ continue;
196
+ }
197
+ dim.bind.push(dt);
198
+ dt.used = true;
199
+ }
200
+ }
201
+ }
202
+ ret = {};
203
+ for (i$ = 0, len$ = dims.length; i$ < len$; ++i$) {
204
+ dim = dims[i$];
205
+ if (dim.bind) {
206
+ ret[dim.k] = dim.bind;
207
+ (Array.isArray(dim.bind)
208
+ ? dim.bind
209
+ : [dim.bind]).map(fn2$);
210
+ }
211
+ }
212
+ return ret;
213
+ function fn$(a, b){
214
+ var ret;
215
+ ret = (b.types[t] || 0) - (a.types[t] || 0);
216
+ if (b.types[t] === a.types[t] && t === 'R') {
217
+ return (a.types.O || 0) - (b.types.O || 0);
218
+ }
219
+ return ret;
220
+ }
221
+ function fn1$(a, b){
222
+ var ret;
223
+ ret = (b[t] || 0) - (a[t] || 0);
224
+ if (b[t] === a[t] && t === 'R') {
225
+ return (a.O || 0) - (b.O || 0);
226
+ }
227
+ return ret;
228
+ }
229
+ function fn2$(it){
230
+ var ref$;
231
+ return ref$ = it.used, delete it.used, ref$;
232
+ }
233
+ }
234
+ };
235
+ if (typeof chart != 'undefined' && chart !== null) {
236
+ (chart.utils || (chart.utils = {})).data = main;
237
+ }
238
+ }).call(this);
@@ -0,0 +1 @@
1
+ (function(){var main;main={number:function(opt){var data,len;opt==null&&(opt={});data=opt.data.filter(function(it){return!(!it||(it+"").trim()==="")});len=data.filter(function(it){return!isNaN(parseFloat(it))}).length;return len/data.length},serial:function(opt){var data,hash,i$,to$,i,delta,k;opt==null&&(opt={});data=[].concat(opt.data);data.sort(function(a,b){return b-a});hash={};for(i$=1,to$=data.length;i$<to$;++i$){i=i$;if(isNaN(data[i])||isNaN(data[i-1])){hash[data[i]>data[i-1]?data[i]+":"+data[i-1]:data[i-1]+":"+data[i]]=true}else{delta=data[i]-data[i-1]}hash[delta]=true}return 1/(function(){var results$=[];for(k in hash){results$.push(k)}return results$}().filter(function(it){return it!=="0"}).length||2)},text:function(opt){opt==null&&(opt={});return 1-this.number(opt)},category:function(opt){var len,maxlen,ret,ref$,ref1$,ref2$;opt==null&&(opt={});len=Array.from(new Set(opt.data)).length;maxlen=opt.data.length;ret=(ref$=(ref1$=1-((ref2$=len-2)>0?ref2$:0)/maxlen-1/maxlen)>0?ref1$:0)<1?ref$:1;if(this.number(opt)){ret=ret*.9}return ret},parse:function(data){var head,body;if(Array.isArray(data)){head=data.slice(0,1)[0];body=data.slice(1);body=body.map(function(d,i){var ret;ret={};head.map(function(h,j){return ret[h]=d[j]});return ret});return{head:head,body:body}}return data},autotype:function(data){var head,res$,k,type,i$,len$,key,d,ret,list;data==null&&(data=[]);res$=[];for(k in data[0]||{}){res$.push(k)}head=res$;type=[];for(i$=0,len$=head.length;i$<len$;++i$){key=head[i$];d=data.map(fn$);ret={key:key,types:{R:main.number({data:d}),O:main.serial({data:d}),N:main.text({data:d}),C:main.category({data:d})}};list=["R","O","N","C"].map(fn1$);list.sort(fn2$);ret.type=list[0][0];type.push(ret)}return type;function fn$(it){return it[key]}function fn1$(it){return[it,ret.types[it]]}function fn2$(a,b){return b[1]-a[1]}},autobind:function(data,dimension){var datatypes,dims,k,v,i$,len$,dim,ts,j$,to$,i,t,k$,to1$,dt,ret;data==null&&(data=[]);dimension==null&&(dimension={});datatypes=this.autotype(data);dims=function(){var ref$,results$=[];for(k in ref$=dimension){v=ref$[k];results$.push({k:k,v:v})}return results$}().filter(function(it){return!it.v.passive});dims.sort(function(a,b){var ret,ref$,ma,mb;ret=(a.v.priority||100)-(b.v.priority||100);if(ret!==0){return ret}ref$=[a.v.type||"R",b.v.type||"R"].map(function(t){return Math.min.apply(Math,function(){var i$,to$,results$=[];for(i$=0,to$=t.length;i$<to$;++i$){results$.push(i$)}return results$}().map(function(i){return"CONR".indexOf(t[i])}))}),ma=ref$[0],mb=ref$[1];return ma-mb});for(i$=0,len$=dims.length;i$<len$;++i$){dim=dims[i$];dim.bind=null;ts=dim.v.type||"RNOC";for(j$=0,to$=ts.length;j$<to$;++j$){i=j$;t=ts[i];datatypes.sort(fn$);for(k$=0,to1$=datatypes.length;k$<to1$;++k$){i=k$;dt=datatypes[i];if(dt.types[t]<.5||dt.used||t==="C"&&dt.types.R>.5){continue}dim.bind=dim.v.multiple?[dt]:dt;dt.used=true;break}}}for(i$=0,len$=dims.length;i$<len$;++i$){dim=dims[i$];if(!dim.v.multiple){continue}ts=dim.v.type||"RNOC";for(j$=0,to$=ts.length;j$<to$;++j$){i=j$;t=ts[i];datatypes.sort(fn1$);for(k$=0,to1$=datatypes.length;k$<to1$;++k$){i=k$;dt=datatypes[i];if(dt.types[t]<.5||dt.used||t==="C"&&dt.types.R>.5){continue}dim.bind.push(dt);dt.used=true}}}ret={};for(i$=0,len$=dims.length;i$<len$;++i$){dim=dims[i$];if(dim.bind){ret[dim.k]=dim.bind;(Array.isArray(dim.bind)?dim.bind:[dim.bind]).map(fn2$)}}return ret;function fn$(a,b){var ret;ret=(b.types[t]||0)-(a.types[t]||0);if(b.types[t]===a.types[t]&&t==="R"){return(a.types.O||0)-(b.types.O||0)}return ret}function fn1$(a,b){var ret;ret=(b[t]||0)-(a[t]||0);if(b[t]===a[t]&&t==="R"){return(a.O||0)-(b.O||0)}return ret}function fn2$(it){var ref$;return ref$=it.used,delete it.used,ref$}}};if(typeof chart!="undefined"&&chart!==null){(chart.utils||(chart.utils={})).data=main}}).call(this);
@@ -0,0 +1,70 @@
1
+ (function(){
2
+ var format;
3
+ format = {};
4
+ format.auto = function(list){
5
+ var s, intRate, diffs, i, diffAvg, type, size;
6
+ list == null && (list = []);
7
+ return d3.format(".3s");
8
+ list = list.map(function(it){
9
+ return +it;
10
+ }).filter(function(it){
11
+ return !isNaN(it);
12
+ });
13
+ if (!list.length) {
14
+ return d3.format("d");
15
+ }
16
+ list.sort(function(a, b){
17
+ return a - b;
18
+ });
19
+ s = Math.max.apply(Math, list.map(function(it){
20
+ var s, ref$;
21
+ s = 1;
22
+ while (it) {
23
+ if (it % 10) {
24
+ break;
25
+ }
26
+ it = Math.floor(it / 10);
27
+ s++;
28
+ }
29
+ return (ref$ = Math.ceil(Math.log(it || 1) / Math.log(10) - s)) > 0 ? ref$ : 0;
30
+ }));
31
+ intRate = list.filter(function(it){
32
+ return Math.floor(it) === it;
33
+ }).length / list.length;
34
+ diffs = (function(){
35
+ var i$, to$, results$ = [];
36
+ for (i$ = 1, to$ = list.length; i$ < to$; ++i$) {
37
+ i = i$;
38
+ results$.push(Math.abs(list[i] - list[i - 1]));
39
+ }
40
+ return results$;
41
+ }()).map(function(it){
42
+ return Math.log(it ? it : 1) / Math.log(10);
43
+ });
44
+ diffAvg = diffs.reduce(function(a, b){
45
+ return a + b;
46
+ }, 0) / list.length;
47
+ type = intRate > 0.9 ? "s" : "f";
48
+ size = diffAvg >= 0
49
+ ? s > 0 ? s : 0
50
+ : Math.ceil(Math.abs(diffAvg));
51
+ return d3.format("." + size + type);
52
+ };
53
+ format.simple = function(v){
54
+ if (isNaN(v = +v)) {
55
+ return v;
56
+ }
57
+ return v >= 1000000000
58
+ ? (v / 1000000000).toFixed(0) + "G"
59
+ : v >= 1000000
60
+ ? (v / 1000000).toFixed(0) + "M"
61
+ : v >= 1000
62
+ ? (v / 1000).toFixed(0) + "K"
63
+ : Math.floor(v) === v
64
+ ? v.toFixed(0)
65
+ : v.toFixed(2);
66
+ };
67
+ if (typeof chart != 'undefined' && chart !== null) {
68
+ (chart.utils || (chart.utils = {})).format = format;
69
+ }
70
+ }).call(this);
@@ -0,0 +1 @@
1
+ (function(){var format;format={};format.auto=function(list){var s,intRate,diffs,i,diffAvg,type,size;list==null&&(list=[]);return d3.format(".3s");list=list.map(function(it){return+it}).filter(function(it){return!isNaN(it)});if(!list.length){return d3.format("d")}list.sort(function(a,b){return a-b});s=Math.max.apply(Math,list.map(function(it){var s,ref$;s=1;while(it){if(it%10){break}it=Math.floor(it/10);s++}return(ref$=Math.ceil(Math.log(it||1)/Math.log(10)-s))>0?ref$:0}));intRate=list.filter(function(it){return Math.floor(it)===it}).length/list.length;diffs=function(){var i$,to$,results$=[];for(i$=1,to$=list.length;i$<to$;++i$){i=i$;results$.push(Math.abs(list[i]-list[i-1]))}return results$}().map(function(it){return Math.log(it?it:1)/Math.log(10)});diffAvg=diffs.reduce(function(a,b){return a+b},0)/list.length;type=intRate>.9?"s":"f";size=diffAvg>=0?s>0?s:0:Math.ceil(Math.abs(diffAvg));return d3.format("."+size+type)};format.simple=function(v){if(isNaN(v=+v)){return v}return v>=1e9?(v/1e9).toFixed(0)+"G":v>=1e6?(v/1e6).toFixed(0)+"M":v>=1e3?(v/1e3).toFixed(0)+"K":Math.floor(v)===v?v.toFixed(0):v.toFixed(2)};if(typeof chart!="undefined"&&chart!==null){(chart.utils||(chart.utils={})).format=format}}).call(this);
@@ -0,0 +1,40 @@
1
+ .pdlg {
2
+ height: 100%;
3
+ width: 100%;
4
+ display: flex;
5
+ align-items: start;
6
+ justify-content: center;
7
+ }
8
+ .pdlg > div {
9
+ display: flex;
10
+ align-items: center;
11
+ line-height: 1em;
12
+ }
13
+ .pdlg > div [ld=shape] {
14
+ display: inline-block;
15
+ width: 1em;
16
+ height: 1em;
17
+ margin-right: 0.5em;
18
+ background: #999;
19
+ flex: 0 0 auto;
20
+ line-height: 1em;
21
+ }
22
+ .pdlg > div [ld=text] {
23
+ color: #999;
24
+ padding-right: 0.25em;
25
+ line-height: 1.2em;
26
+ }
27
+ .pdlg.vertical {
28
+ flex-direction: column;
29
+ align-items: start;
30
+ }
31
+ .pdlg.vertical > div {
32
+ margin-bottom: 0.5em;
33
+ }
34
+ .pdlg.horizontal > div {
35
+ margin-right: 0.5em;
36
+ }
37
+ g.pdlg-g {
38
+ cursor: pointer;
39
+ transition: opacity 0.15s ease-in-out;
40
+ }
@@ -0,0 +1,263 @@
1
+ (function(){
2
+ var svgns, legend;
3
+ svgns = "http://www.w3.org/2000/svg";
4
+ legend = function(opt){
5
+ var x$, nodeLayout, nodeRender, gl, gs, gt, this$ = this;
6
+ opt == null && (opt = {});
7
+ this._data = opt.data || [];
8
+ this.name = opt.name || 'legend';
9
+ this.cfg = opt.cfg || {};
10
+ this.root = typeof opt.root === 'string'
11
+ ? document.querySelector(opt.root)
12
+ : opt.root;
13
+ this.dir = opt.direction || 'vertical';
14
+ this.evtHandler = {};
15
+ this._picked = Object.fromEntries(this._data.map(function(it){
16
+ return [it.key, true];
17
+ }));
18
+ this.layout = opt.layout || new layout({
19
+ root: this.root
20
+ });
21
+ x$ = this.layout;
22
+ x$.on('update', function(){
23
+ return this$.update();
24
+ });
25
+ x$.on('render', function(){
26
+ return this$.render();
27
+ });
28
+ this.id = Math.random().toString(36).substring(2);
29
+ nodeLayout = this.layout.getNode(this.name);
30
+ nodeRender = this.layout.getGroup(this.name);
31
+ if (!nodeLayout.querySelector('[ld-each=legend]')) {
32
+ nodeLayout.innerHTML = "<div class=\"pdlg " + this.dir + "\">\n <div ld-each=\"legend\">\n <div class=\"pdl-cell\" ld=\"shape\" data-only></div>\n <div class=\"pdl-cell\" ld=\"text\" data-only></div>\n </div>\n</div>";
33
+ }
34
+ if (!nodeRender.querySelector('[ld-each=legend]')) {
35
+ gl = document.createElementNS(svgns, "g");
36
+ gs = document.createElementNS(svgns, "g");
37
+ gt = document.createElementNS(svgns, "g");
38
+ gl.classList.add('pdlg-g');
39
+ gl.setAttribute('ld-each', 'legend');
40
+ gs.setAttribute('ld', 'shape');
41
+ gt.setAttribute('ld', 'text');
42
+ gl.appendChild(gs);
43
+ gl.appendChild(gt);
44
+ nodeRender.appendChild(gl);
45
+ }
46
+ this._func = [
47
+ {
48
+ key: "all",
49
+ type: "func",
50
+ text: "全選"
51
+ }, {
52
+ key: "none",
53
+ type: "func",
54
+ text: "全不選"
55
+ }
56
+ ];
57
+ this.view = {
58
+ layout: new ldview({
59
+ root: this.layout.getNode(this.name),
60
+ initRender: false,
61
+ handler: {
62
+ legend: {
63
+ list: function(){
64
+ return this$._data.concat(this$.cfg.selectable
65
+ ? this$._func
66
+ : []);
67
+ },
68
+ key: function(it){
69
+ return it.key;
70
+ },
71
+ view: {
72
+ handler: {
73
+ shape: function(arg$){
74
+ var node, ctx;
75
+ node = arg$.node, ctx = arg$.ctx;
76
+ return node.setAttribute('data-name', this$._name(ctx, "shape"));
77
+ },
78
+ text: function(arg$){
79
+ var node, ctx;
80
+ node = arg$.node, ctx = arg$.ctx;
81
+ node.setAttribute('data-name', this$._name(ctx, "text"));
82
+ return node.innerText = ctx.text;
83
+ }
84
+ }
85
+ }
86
+ }
87
+ }
88
+ }),
89
+ render: new ldview({
90
+ root: this.layout.getGroup(this.name),
91
+ initRender: false,
92
+ handler: {
93
+ legend: {
94
+ list: function(){
95
+ return this$._data.concat(this$.cfg.selectable
96
+ ? this$._func
97
+ : []);
98
+ },
99
+ key: function(it){
100
+ return it.key;
101
+ },
102
+ view: {
103
+ action: {
104
+ click: {
105
+ "@": function(arg$){
106
+ var node, ctx, k;
107
+ node = arg$.node, ctx = arg$.ctx;
108
+ if (!this$.cfg.selectable) {
109
+ return;
110
+ }
111
+ if (ctx.type === 'func') {
112
+ for (k in this$._picked) {
113
+ this$._picked[k] = ctx.key === 'all' ? true : false;
114
+ }
115
+ } else {
116
+ this$._picked[ctx.key] = !this$._picked[ctx.key];
117
+ }
118
+ this$.view.render.render('legend');
119
+ return this$.fire('select', this$._picked);
120
+ }
121
+ }
122
+ },
123
+ handler: {
124
+ "@": function(arg$){
125
+ var node, ctx;
126
+ node = arg$.node, ctx = arg$.ctx;
127
+ return node.style.opacity = !this$.cfg.selectable || ctx.type === 'func' || this$._picked[ctx.key] ? 1 : 0.3;
128
+ },
129
+ "shape": function(arg$){
130
+ var node, ctx, n, box, rbox;
131
+ node = arg$.node, ctx = arg$.ctx;
132
+ if (ctx.type === 'func') {
133
+ node.style.display = 'none';
134
+ return;
135
+ }
136
+ if (!node.querySelector('circle')) {
137
+ node.appendChild(document.createElementNS(svgns, 'circle'));
138
+ }
139
+ n = node.querySelector('circle');
140
+ box = this$.layout.getBox(this$._name(ctx, 'shape'));
141
+ rbox = this$.layout.getBox(this$.name);
142
+ n.setAttribute('cx', ".5em");
143
+ n.setAttribute('cy', ".5em");
144
+ n.setAttribute('r', ".5em");
145
+ n.setAttribute('transform', "translate(" + (box.x - rbox.x) + ", " + (box.y - rbox.y) + ")");
146
+ if (typeof opt.shape === 'function') {
147
+ return opt.shape.call(n, ctx);
148
+ }
149
+ },
150
+ "text": function(arg$){
151
+ var node, ctx, n, nbox, rbox, ret;
152
+ node = arg$.node, ctx = arg$.ctx;
153
+ n = this$.layout.getNode(this$._name(ctx, 'text'));
154
+ nbox = this$.layout.getBox(this$._name(ctx, 'text'));
155
+ rbox = this$.layout.getBox(this$.name);
156
+ node.setAttribute('transform', "translate(" + (nbox.x - rbox.x) + ", " + (nbox.y - rbox.y) + ")");
157
+ node.textContent = "";
158
+ ret = wrapSvgText({
159
+ node: n,
160
+ useRange: true
161
+ });
162
+ return node.appendChild(ret);
163
+ }
164
+ }
165
+ }
166
+ }
167
+ }
168
+ })
169
+ };
170
+ this.update();
171
+ return this;
172
+ };
173
+ legend.prototype = import$(Object.create(Object.prototype), {
174
+ _name: function(ctx, type){
175
+ type == null && (type = "s");
176
+ return "pdlg-" + type + "-" + this.id + "-" + (ctx.type || '') + "-" + ctx.key;
177
+ },
178
+ enabled: function(){
179
+ return this._data && this._data.length && (!(this.cfg.enabled != null) || this.cfg.enabled);
180
+ },
181
+ update: function(){
182
+ var val, ref$;
183
+ val = this.enabled() ? '' : '0px';
184
+ ref$ = this.layout.getNode('legend').style;
185
+ ref$.width = val;
186
+ ref$.height = val;
187
+ ref$.padding = val;
188
+ ref$.margin = val;
189
+ return this.view.layout.render();
190
+ },
191
+ render: function(){
192
+ var enabled, g;
193
+ enabled = this.enabled();
194
+ g = this.layout.getGroup(this.name);
195
+ g.style.display = enabled ? '' : 'none';
196
+ if (enabled) {
197
+ return this.view.render.render();
198
+ }
199
+ },
200
+ config: function(cfg){
201
+ var node, this$ = this;
202
+ if (!(cfg != null)) {
203
+ return this.cfg;
204
+ }
205
+ this.cfg = cfg;
206
+ this.dir = this.cfg.position === 'bottom' ? 'horizontal' : 'vertical';
207
+ node = this.layout.getNode(this.name).querySelector('.pdlg');
208
+ return ['horizontal', 'vertical'].map(function(it){
209
+ return node.classList.toggle(it, this$.dir === it);
210
+ });
211
+ },
212
+ data: function(data){
213
+ var hash;
214
+ data == null && (data = []);
215
+ hash = {};
216
+ data.map(function(d, i){
217
+ return hash[d.key] = i;
218
+ });
219
+ this._data = data.filter(function(d, i){
220
+ return hash[d.key] === i;
221
+ });
222
+ this._picked = Object.fromEntries(this._data.map(function(d){
223
+ return [d.key, true];
224
+ }));
225
+ this.update();
226
+ this.layout.update(false);
227
+ return this.view.render.render();
228
+ },
229
+ on: function(n, cb){
230
+ var this$ = this;
231
+ return (Array.isArray(n)
232
+ ? n
233
+ : [n]).map(function(n){
234
+ var ref$;
235
+ return ((ref$ = this$.evtHandler)[n] || (ref$[n] = [])).push(cb);
236
+ });
237
+ },
238
+ fire: function(n){
239
+ var v, res$, i$, to$, ref$, len$, cb, results$ = [];
240
+ res$ = [];
241
+ for (i$ = 1, to$ = arguments.length; i$ < to$; ++i$) {
242
+ res$.push(arguments[i$]);
243
+ }
244
+ v = res$;
245
+ for (i$ = 0, len$ = (ref$ = this.evtHandler[n] || []).length; i$ < len$; ++i$) {
246
+ cb = ref$[i$];
247
+ results$.push(cb.apply(this, v));
248
+ }
249
+ return results$;
250
+ },
251
+ isSelected: function(key){
252
+ return !!this._picked[key];
253
+ }
254
+ });
255
+ if (typeof chart != 'undefined' && chart !== null) {
256
+ (chart.utils || (chart.utils = {})).legend = legend;
257
+ }
258
+ function import$(obj, src){
259
+ var own = {}.hasOwnProperty;
260
+ for (var key in src) if (own.call(src, key)) obj[key] = src[key];
261
+ return obj;
262
+ }
263
+ }).call(this);
@@ -0,0 +1 @@
1
+ .pdlg{height:100%;width:100%;display:flex;align-items:start;justify-content:center}.pdlg>div{display:flex;align-items:center;line-height:1em}.pdlg>div [ld=shape]{display:inline-block;width:1em;height:1em;margin-right:.5em;background:#999;flex:0 0 auto;line-height:1em}.pdlg>div [ld=text]{color:#999;padding-right:.25em;line-height:1.2em}.pdlg.vertical{flex-direction:column;align-items:start}.pdlg.vertical>div{margin-bottom:.5em}.pdlg.horizontal>div{margin-right:.5em}g.pdlg-g{cursor:pointer;transition:opacity .15s ease-in-out}
@@ -0,0 +1 @@
1
+ (function(){var svgns,legend;svgns="http://www.w3.org/2000/svg";legend=function(opt){var x$,nodeLayout,nodeRender,gl,gs,gt,this$=this;opt==null&&(opt={});this._data=opt.data||[];this.name=opt.name||"legend";this.cfg=opt.cfg||{};this.root=typeof opt.root==="string"?document.querySelector(opt.root):opt.root;this.dir=opt.direction||"vertical";this.evtHandler={};this._picked=Object.fromEntries(this._data.map(function(it){return[it.key,true]}));this.layout=opt.layout||new layout({root:this.root});x$=this.layout;x$.on("update",function(){return this$.update()});x$.on("render",function(){return this$.render()});this.id=Math.random().toString(36).substring(2);nodeLayout=this.layout.getNode(this.name);nodeRender=this.layout.getGroup(this.name);if(!nodeLayout.querySelector("[ld-each=legend]")){nodeLayout.innerHTML='<div class="pdlg '+this.dir+'">\n <div ld-each="legend">\n <div class="pdl-cell" ld="shape" data-only></div>\n <div class="pdl-cell" ld="text" data-only></div>\n </div>\n</div>'}if(!nodeRender.querySelector("[ld-each=legend]")){gl=document.createElementNS(svgns,"g");gs=document.createElementNS(svgns,"g");gt=document.createElementNS(svgns,"g");gl.classList.add("pdlg-g");gl.setAttribute("ld-each","legend");gs.setAttribute("ld","shape");gt.setAttribute("ld","text");gl.appendChild(gs);gl.appendChild(gt);nodeRender.appendChild(gl)}this._func=[{key:"all",type:"func",text:"全選"},{key:"none",type:"func",text:"全不選"}];this.view={layout:new ldview({root:this.layout.getNode(this.name),initRender:false,handler:{legend:{list:function(){return this$._data.concat(this$.cfg.selectable?this$._func:[])},key:function(it){return it.key},view:{handler:{shape:function(arg$){var node,ctx;node=arg$.node,ctx=arg$.ctx;return node.setAttribute("data-name",this$._name(ctx,"shape"))},text:function(arg$){var node,ctx;node=arg$.node,ctx=arg$.ctx;node.setAttribute("data-name",this$._name(ctx,"text"));return node.innerText=ctx.text}}}}}}),render:new ldview({root:this.layout.getGroup(this.name),initRender:false,handler:{legend:{list:function(){return this$._data.concat(this$.cfg.selectable?this$._func:[])},key:function(it){return it.key},view:{action:{click:{"@":function(arg$){var node,ctx,k;node=arg$.node,ctx=arg$.ctx;if(!this$.cfg.selectable){return}if(ctx.type==="func"){for(k in this$._picked){this$._picked[k]=ctx.key==="all"?true:false}}else{this$._picked[ctx.key]=!this$._picked[ctx.key]}this$.view.render.render("legend");return this$.fire("select",this$._picked)}}},handler:{"@":function(arg$){var node,ctx;node=arg$.node,ctx=arg$.ctx;return node.style.opacity=!this$.cfg.selectable||ctx.type==="func"||this$._picked[ctx.key]?1:.3},shape:function(arg$){var node,ctx,n,box,rbox;node=arg$.node,ctx=arg$.ctx;if(ctx.type==="func"){node.style.display="none";return}if(!node.querySelector("circle")){node.appendChild(document.createElementNS(svgns,"circle"))}n=node.querySelector("circle");box=this$.layout.getBox(this$._name(ctx,"shape"));rbox=this$.layout.getBox(this$.name);n.setAttribute("cx",".5em");n.setAttribute("cy",".5em");n.setAttribute("r",".5em");n.setAttribute("transform","translate("+(box.x-rbox.x)+", "+(box.y-rbox.y)+")");if(typeof opt.shape==="function"){return opt.shape.call(n,ctx)}},text:function(arg$){var node,ctx,n,nbox,rbox,ret;node=arg$.node,ctx=arg$.ctx;n=this$.layout.getNode(this$._name(ctx,"text"));nbox=this$.layout.getBox(this$._name(ctx,"text"));rbox=this$.layout.getBox(this$.name);node.setAttribute("transform","translate("+(nbox.x-rbox.x)+", "+(nbox.y-rbox.y)+")");node.textContent="";ret=wrapSvgText({node:n,useRange:true});return node.appendChild(ret)}}}}}})};this.update();return this};legend.prototype=import$(Object.create(Object.prototype),{_name:function(ctx,type){type==null&&(type="s");return"pdlg-"+type+"-"+this.id+"-"+(ctx.type||"")+"-"+ctx.key},enabled:function(){return this._data&&this._data.length&&(!(this.cfg.enabled!=null)||this.cfg.enabled)},update:function(){var val,ref$;val=this.enabled()?"":"0px";ref$=this.layout.getNode("legend").style;ref$.width=val;ref$.height=val;ref$.padding=val;ref$.margin=val;return this.view.layout.render()},render:function(){var enabled,g;enabled=this.enabled();g=this.layout.getGroup(this.name);g.style.display=enabled?"":"none";if(enabled){return this.view.render.render()}},config:function(cfg){var node,this$=this;if(!(cfg!=null)){return this.cfg}this.cfg=cfg;this.dir=this.cfg.position==="bottom"?"horizontal":"vertical";node=this.layout.getNode(this.name).querySelector(".pdlg");return["horizontal","vertical"].map(function(it){return node.classList.toggle(it,this$.dir===it)})},data:function(data){var hash;data==null&&(data=[]);hash={};data.map(function(d,i){return hash[d.key]=i});this._data=data.filter(function(d,i){return hash[d.key]===i});this._picked=Object.fromEntries(this._data.map(function(d){return[d.key,true]}));this.update();this.layout.update(false);return this.view.render.render()},on:function(n,cb){var this$=this;return(Array.isArray(n)?n:[n]).map(function(n){var ref$;return((ref$=this$.evtHandler)[n]||(ref$[n]=[])).push(cb)})},fire:function(n){var v,res$,i$,to$,ref$,len$,cb,results$=[];res$=[];for(i$=1,to$=arguments.length;i$<to$;++i$){res$.push(arguments[i$])}v=res$;for(i$=0,len$=(ref$=this.evtHandler[n]||[]).length;i$<len$;++i$){cb=ref$[i$];results$.push(cb.apply(this,v))}return results$},isSelected:function(key){return!!this._picked[key]}});if(typeof chart!="undefined"&&chart!==null){(chart.utils||(chart.utils={})).legend=legend}function import$(obj,src){var own={}.hasOwnProperty;for(var key in src)if(own.call(src,key))obj[key]=src[key];return obj}}).call(this);