@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,251 @@
1
+ <div><div plug="layout"><div class="pdl-layout"><div data-type="layout"><div class="pdl-cell" data-name="axis-left"></div><div class="pdl-cell" data-name="view"></div><div class="pdl-cell"></div><div class="pdl-cell" data-name="axis-bottom"></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: 2em 1fr;
4
+ grid-template-rows: 1fr 1em 3em;
5
+ padding: 20px 20px 0 20px;
6
+ }
7
+ .pdl-layout > div[data-type=layout] .pdl-cell[data-name=legend] {
8
+ grid-column: 1/span 2;
9
+ grid-row: 3;
10
+ }
11
+ /*
12
+ .pdl-layout > div[data-type=layout]
13
+ display: grid
14
+ grid-template-columns: 2em 1fr 5em
15
+ grid-template-rows: 1fr 1em
16
+ padding: 20px 20px 0 20px
17
+ .pdl-cell[data-name=legend]
18
+ grid-column: 3
19
+ grid-row: 1 / span 2
20
+ */
21
+ </style><script type="@plotdb/block">(function(it){
22
+ return it();
23
+ })(function(){
24
+ var blockFactory, mod;
25
+ blockFactory = {
26
+ pkg: {
27
+ name: 'scatter',
28
+ version: '0.0.1',
29
+ extend: {
30
+ name: "base",
31
+ version: "0.0.1"
32
+ },
33
+ dependencies: [{
34
+ url: "http://cdn.jsdelivr.net/npm/d3-delaunay@6/dist/d3-delaunay.min.js"
35
+ }]
36
+ },
37
+ init: function(arg$){
38
+ var root, context, pubsub;
39
+ root = arg$.root, context = arg$.context, pubsub = arg$.pubsub;
40
+ return pubsub.fire('init', {
41
+ mod: mod({
42
+ context: context
43
+ })
44
+ });
45
+ }
46
+ };
47
+ mod = function(arg$){
48
+ var context, d3, chart, names;
49
+ context = arg$.context;
50
+ d3 = context.d3, chart = context.chart;
51
+ names = ["The Glenn Miller Story", "The Fifth Element", "Forrest Gump", "Finding Nemo", "The Fly", "First Blood", "You Can't Take It with You", "Man of the Year", "From Hell", "The Easy Rider", "The English Patient", "The Extra-Terrestial", "Edward Scissorhands", "Empire of the Sun", "Encounters of the Third Kind", "Elizabeth: The Golden Age"];
52
+ return {
53
+ sample: function(){
54
+ return {
55
+ 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){
56
+ var ret;
57
+ ret = {
58
+ x: Math.random(),
59
+ y: Math.random(),
60
+ name: names[Math.floor(Math.random() * names.length)]
61
+ };
62
+ return ret;
63
+ }),
64
+ binding: {
65
+ x: {
66
+ key: 'x'
67
+ },
68
+ y: {
69
+ key: 'y'
70
+ },
71
+ name: {
72
+ key: 'name'
73
+ }
74
+ }
75
+ };
76
+ },
77
+ config: {},
78
+ dimension: {
79
+ x: {
80
+ type: 'R',
81
+ name: "x axis"
82
+ },
83
+ y: {
84
+ type: 'R',
85
+ name: "y axis"
86
+ },
87
+ radius: {
88
+ type: 'R',
89
+ name: "radius"
90
+ },
91
+ category: {
92
+ type: 'CN',
93
+ name: "category"
94
+ },
95
+ name: {
96
+ type: 'N',
97
+ name: "name"
98
+ }
99
+ },
100
+ init: function(){
101
+ var tint, this$ = this;
102
+ this.tint = tint = new chart.utils.tint();
103
+ ['view', 'yaxis', 'xaxis'].map(function(it){
104
+ return (this$.g || (this$.g = {}))[it] = d3.select(this$.layout.getGroup(it));
105
+ });
106
+ return this.path = d3.select(this.svg).append('path');
107
+ },
108
+ parse: function(){},
109
+ resize: function(){
110
+ var ref$, w, h, box, this$ = this;
111
+ ref$ = [this.box.width, this.box.height], w = ref$[0], h = ref$[1];
112
+ this.extent = {
113
+ x: d3.extent(this.data.map(function(it){
114
+ return it.x;
115
+ })),
116
+ y: d3.extent(this.data.map(function(it){
117
+ return it.y;
118
+ }))
119
+ };
120
+ box = this.layout.getBox('view');
121
+ this.scale = {
122
+ x: d3.scaleLinear().domain(this.extent.x).range([0, box.width]),
123
+ y: d3.scaleLinear().domain(this.extent.y).range([0, box.height])
124
+ };
125
+ this.pts = this.data.map(function(d){
126
+ return [this$.scale.x(d.x), this$.scale.y(d.y)];
127
+ });
128
+ this.delaunay = d3.Delaunay.from(this.pts);
129
+ this.voronoi = this.delaunay.voronoi([0, 0, box.width, box.height]);
130
+ return this.cells = this.pts.map(function(point, i){
131
+ var x, y, polygon, centroid, ref$, cx, cy, area, angle;
132
+ x = point[0], y = point[1];
133
+ polygon = this$.voronoi.cellPolygon(i);
134
+ ref$ = centroid = d3.polygonCentroid(polygon), cx = ref$[0], cy = ref$[1];
135
+ area = -d3.polygonArea(polygon);
136
+ angle = (Math.round(Math.atan2(cy - y, cx - x) / Math.PI * 2) + 4) % 4;
137
+ return {
138
+ point: point,
139
+ polygon: polygon,
140
+ centroid: centroid,
141
+ area: area,
142
+ angle: angle
143
+ };
144
+ });
145
+ },
146
+ render: function(){
147
+ var scale, x$, y$;
148
+ scale = this.scale;
149
+ x$ = this.g.view.selectAll('circle.data').data(this.data);
150
+ x$.exit().remove();
151
+ x$.enter().append('circle').attr('class', 'data').attr('cx', function(d, i){
152
+ return scale.x(d.x);
153
+ }).attr('cy', function(d, i){
154
+ return scale.y(d.y);
155
+ }).attr('r', 3).attr('fill', '#000');
156
+ y$ = this.g.view.selectAll('text').data(this.data);
157
+ y$.exit().remove();
158
+ y$.enter().append('text').text(function(d, i){
159
+ return d.name;
160
+ }).attr('x', function(d, i){
161
+ if (d.nb) {
162
+ return d.nb.x;
163
+ } else {
164
+ return scale.x(d.x);
165
+ }
166
+ }).attr('y', function(d, i){
167
+ if (d.nb) {
168
+ return d.nb.y;
169
+ } else {
170
+ return scale.y(d.y);
171
+ }
172
+ }).attr('text-anchor', 'middle').attr('dominant-baseline', 'middle');
173
+ this.g.view.selectAll('text').data(this.data).attr('x', function(d, i){
174
+ if (d.nb) {
175
+ return d.nb.x;
176
+ } else {
177
+ return scale.x(d.x);
178
+ }
179
+ }).attr('y', function(d, i){
180
+ if (d.nb) {
181
+ return d.nb.y;
182
+ } else {
183
+ return scale.y(d.y) - 20;
184
+ }
185
+ }).attr('opacity', function(d, i){
186
+ if (d.nb) {
187
+ if (d.nb.show) {
188
+ return 1;
189
+ } else {
190
+ return 0;
191
+ }
192
+ } else {
193
+ return 1;
194
+ }
195
+ });
196
+ return this.path.attr('d', this.voronoi.render()).attr('stroke', '#000').attr('transform', this.g.view.node().getAttribute('transform'));
197
+ },
198
+ tick: function(){
199
+ var scale, rbox, i$, to$, i, d, ref$, r, j$, k$, j, a, b, data;
200
+ scale = this.scale;
201
+ this.g.view.selectAll('text').each(function(d, i){
202
+ return d.box = this.getBoundingClientRect();
203
+ });
204
+ rbox = this.layout.getBox('view');
205
+ for (i$ = 0, to$ = this.data.length; i$ < to$; ++i$) {
206
+ i = i$;
207
+ d = this.data[i].box;
208
+ if (!this.data[i].nb) {
209
+ this.data[i].nb = {
210
+ x: scale.x(this.data[i].x),
211
+ y: scale.y(this.data[i].y) - 20
212
+ };
213
+ }
214
+ ref$ = this.data[i].nb;
215
+ ref$.width = d.width;
216
+ ref$.height = d.height;
217
+ ref$.show = true;
218
+ }
219
+ for (i$ = 20; i$ < 200; i$ += 20) {
220
+ r = i$;
221
+ for (j$ = 0, to$ = this.data.length; j$ < to$; ++j$) {
222
+ i = j$;
223
+ for (k$ = 0; k$ < i; ++k$) {
224
+ j = k$;
225
+ ref$ = [this.data[i].nb, this.data[j].nb], a = ref$[0], b = ref$[1];
226
+ if (((a.x >= b.x && a.x <= b.x + b.width) || (a.x + a.width >= b.x && a.x + a.width <= b.x + b.width)) && ((a.y >= b.y && a.y <= b.y + b.height) || (a.y + a.height >= b.y && a.y + a.height <= b.y + b.height))) {
227
+ d = Math.random() * Math.PI * 2;
228
+ data = this.data[i];
229
+ ref$ = data.nb;
230
+ ref$.x = scale.x(data.x) + Math.cos(d) * r;
231
+ ref$.y = scale.y(data.y) + Math.sin(d) * r;
232
+ }
233
+ }
234
+ }
235
+ }
236
+ for (i$ = 0, to$ = this.data.length; i$ < to$; ++i$) {
237
+ i = i$;
238
+ for (j$ = 0; j$ < i; ++j$) {
239
+ j = j$;
240
+ ref$ = [this.data[i].nb, this.data[j].nb], a = ref$[0], b = ref$[1];
241
+ if (((a.x >= b.x && a.x <= b.x + b.width) || (a.x + a.width >= b.x && a.x + a.width <= b.x + b.width)) && ((a.y >= b.y && a.y <= b.y + b.height) || (a.y + a.height >= b.y && a.y + a.height <= b.y + b.height))) {
242
+ this.data[i].nb.show = false;
243
+ }
244
+ }
245
+ }
246
+ return this.render();
247
+ }
248
+ };
249
+ };
250
+ return blockFactory;
251
+ });</script></div>
@@ -0,0 +1,103 @@
1
+ <div><div plug="layout"></div><style type="text/css"></style><script type="@plotdb/block">(function(it){
2
+ return it();
3
+ })(function(){
4
+ var blockFactory, mod;
5
+ blockFactory = {
6
+ pkg: {
7
+ name: 'bar',
8
+ version: '0.0.1',
9
+ extend: {
10
+ name: "base",
11
+ version: "0.0.1"
12
+ },
13
+ dependencies: [
14
+ {
15
+ url: "/assets/lib/@plotdb/sheet/main/index.min.js"
16
+ }, {
17
+ url: "/assets/lib/@plotdb/sheet/main/index.min.css"
18
+ }
19
+ ]
20
+ },
21
+ init: function(arg$){
22
+ var root, context, t, pubsub;
23
+ root = arg$.root, context = arg$.context, t = arg$.t, pubsub = arg$.pubsub;
24
+ return pubsub.fire('init', {
25
+ mod: mod({
26
+ context: context,
27
+ t: t
28
+ }),
29
+ prepareSvg: false,
30
+ layout: false
31
+ });
32
+ }
33
+ };
34
+ mod = function(arg$){
35
+ var context, t, chart, sheet;
36
+ context = arg$.context, t = arg$.t;
37
+ chart = context.chart, sheet = context.sheet;
38
+ return {
39
+ sample: function(){
40
+ return {
41
+ raw: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20].map(function(val){
42
+ return Object.fromEntries([1, 2, 3, 4, 5].map(function(it){
43
+ return ["col" + it, (Math.random() * 100).toFixed(2)];
44
+ }));
45
+ }),
46
+ binding: {
47
+ column: [1, 2, 3, 4, 5].map(function(it){
48
+ return {
49
+ key: "col" + it
50
+ };
51
+ })
52
+ }
53
+ };
54
+ },
55
+ config: {},
56
+ dimension: {
57
+ column: {
58
+ type: 'NCOR',
59
+ multiple: true,
60
+ name: 'column'
61
+ }
62
+ },
63
+ init: function(){
64
+ var this$ = this;
65
+ this.sheet = new sheet({
66
+ root: this.root.querySelector('[plug=layout]'),
67
+ frozen: {
68
+ row: 1
69
+ },
70
+ editing: false,
71
+ idx: {
72
+ row: true,
73
+ col: true
74
+ }
75
+ });
76
+ this.data = [this.binding.column.map(function(it){
77
+ return it.name || it.key;
78
+ })].concat(this.raw.map(function(r){
79
+ return this$.binding.column.map(function(c){
80
+ return r[c.key];
81
+ });
82
+ }));
83
+ return this.sheet.data(this.data);
84
+ },
85
+ filter: function(filters, internal){
86
+ internal == null && (internal = false);
87
+ },
88
+ parse: function(){
89
+ var head;
90
+ head = this.binding.column.map(function(it){
91
+ return it.name || it.key;
92
+ });
93
+ this.parsed = [head].concat(this.data.map(function(it){
94
+ return it.column;
95
+ }));
96
+ return this.sheet.data(this.parsed);
97
+ },
98
+ resize: function(){},
99
+ render: function(){}
100
+ };
101
+ };
102
+ return blockFactory;
103
+ });</script></div>
@@ -0,0 +1,73 @@
1
+ <div style="height:100%"><plug name="layout"></plug><script type="@plotdb/block">(function(it){
2
+ return it();
3
+ })(function(){
4
+ var blockFactory;
5
+ blockFactory = {
6
+ pkg: {
7
+ name: 'table',
8
+ version: '0.0.1',
9
+ extend: {
10
+ name: "empty",
11
+ version: "0.0.1"
12
+ },
13
+ dependencies: [
14
+ {
15
+ url: "/assets/lib/gridjs/main/gridjs.production.min.js"
16
+ }, {
17
+ url: "/assets/lib/gridjs/main/theme/mermaid.min.css"
18
+ }
19
+ ]
20
+ },
21
+ init: function(arg$){
22
+ var root, context, pubsub, gridjs;
23
+ root = arg$.root, context = arg$.context, pubsub = arg$.pubsub;
24
+ gridjs = context.gridjs;
25
+ return pubsub.fire('init', {
26
+ layout: false,
27
+ prepareSvg: false,
28
+ mod: {
29
+ init: function(){
30
+ var grid;
31
+ this.grid = grid = new gridjs.Grid({
32
+ columns: [' ', ' ', ' ', ' ', ' '],
33
+ height: this.root.getBoundingClientRect().height + "px",
34
+ fixedHeader: true,
35
+ sort: true,
36
+ search: false,
37
+ resizable: true,
38
+ data: [].concat([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(function(){
39
+ return [];
40
+ }))
41
+ });
42
+ return grid.render(this.root);
43
+ },
44
+ parse: function(){
45
+ var head, res$, k, raw;
46
+ res$ = [];
47
+ for (k in this.raw[0] || {}) {
48
+ res$.push(k);
49
+ }
50
+ head = res$;
51
+ head.length;
52
+ raw = this.raw;
53
+ console.log(raw);
54
+ return;
55
+ return this.grid.updateConfig({
56
+ columns: raw[0],
57
+ data: raw.slice(1).concat((function(){
58
+ var i$, to$, ref$, results$ = [];
59
+ for (i$ = 0, to$ = (ref$ = 20 - raw.length) > 0 ? ref$ : 0; i$ <= to$; ++i$) {
60
+ results$.push(i$);
61
+ }
62
+ return results$;
63
+ }()).map(function(){
64
+ return [];
65
+ }))
66
+ }).forceRender();
67
+ }
68
+ }
69
+ });
70
+ }
71
+ };
72
+ return blockFactory;
73
+ });</script></div>
@@ -0,0 +1,210 @@
1
+ <div><script type="@plotdb/block">(function(it){
2
+ return it();
3
+ })(function(){
4
+ var blockFactory, mod;
5
+ blockFactory = {
6
+ pkg: {
7
+ name: 'taiwantown',
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;
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;
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
+ };
58
+ return {
59
+ raw: val.towns,
60
+ binding: {
61
+ color: {
62
+ key: 'val'
63
+ },
64
+ name: {
65
+ key: 'town'
66
+ }
67
+ }
68
+ };
69
+ },
70
+ config: {},
71
+ dimension: {
72
+ name: {
73
+ type: 'N',
74
+ name: "國家"
75
+ },
76
+ color: {
77
+ type: 'R',
78
+ name: "顏色"
79
+ }
80
+ },
81
+ init: function(){
82
+ var this$ = this;
83
+ this.obj = pdmaptw.create({
84
+ root: this.svg,
85
+ type: 'town',
86
+ baseurl: 'https://cdn.jsdelivr.net/npm/pdmaptw@0.0.2/dist'
87
+ });
88
+ return this.obj.init().then(function(){
89
+ return this$.obj.fit();
90
+ });
91
+ },
92
+ parse: function(){
93
+ var this$ = this;
94
+ return d3.select(this.svg).selectAll('path').each(function(d, i){
95
+ return d.data = this$.data.filter(function(it){
96
+ return it.name === d.properties.name;
97
+ })[0] || {};
98
+ });
99
+ },
100
+ resize: function(){},
101
+ render: function(){
102
+ var this$ = this;
103
+ this.color = d3.interpolateTurbo;
104
+ if (this.cfg != null && this.cfg.palette) {
105
+ this.color = d3.interpolateDiscrete(this.cfg.palette.colors.map(function(it){
106
+ return ldColor.web(it.value || it);
107
+ }));
108
+ }
109
+ return d3.select(this.svg).selectAll('path').transition().duration(350).attr('fill', function(d, i){
110
+ return this$.color(d.data.color);
111
+ });
112
+ }
113
+ };
114
+ };
115
+ return blockFactory;
116
+ });</script></div><div><script type="@plotdb/block">({
117
+ pkg: {
118
+ name: 'taiwantown',
119
+ version: '0.0.1',
120
+ dependencies: [
121
+ {
122
+ url: "https://d3js.org/d3.v4.js",
123
+ async: false
124
+ }, "https://d3js.org/d3-format.v2.min.js", "https://d3js.org/d3-array.v2.min.js", "https://d3js.org/topojson.v2.min.js", {
125
+ url: "https://d3js.org/d3-color.v1.min.js",
126
+ async: false
127
+ }, {
128
+ url: "https://d3js.org/d3-interpolate.v1.min.js",
129
+ async: false
130
+ }, {
131
+ url: "https://d3js.org/d3-scale-chromatic.v1.min.js",
132
+ async: false
133
+ }, "/js/map.list.js", "https://cdn.jsdelivr.net/npm/pdmaptw@0.0.2/dist/pdmaptw.min.js"
134
+ ]
135
+ },
136
+ init: function(arg$){
137
+ var root, context, counties, towns, c;
138
+ root = arg$.root, context = arg$.context;
139
+ counties = context.counties.map(function(d, i){
140
+ return {
141
+ val: Math.random(),
142
+ county: d
143
+ };
144
+ });
145
+ towns = context.towns.map(function(d, i){
146
+ return {
147
+ val: Math.random(),
148
+ town: d
149
+ };
150
+ });
151
+ c = new chart({
152
+ root: root,
153
+ raw: towns,
154
+ mod: this.mod({
155
+ context: context
156
+ }),
157
+ binding: {
158
+ color: {
159
+ name: 'val'
160
+ },
161
+ name: {
162
+ name: 'town'
163
+ }
164
+ }
165
+ });
166
+ c.init().then(function(){
167
+ return c.render();
168
+ });
169
+ return this.c = c;
170
+ },
171
+ 'interface': function(){
172
+ return this.c;
173
+ },
174
+ mod: function(arg$){
175
+ var context;
176
+ context = arg$.context;
177
+ return {
178
+ init: function(){
179
+ var this$ = this;
180
+ this.obj = context.pdmaptw.create({
181
+ root: this.svg,
182
+ type: 'town',
183
+ baseurl: 'https://cdn.jsdelivr.net/npm/pdmaptw@0.0.2/dist'
184
+ });
185
+ return this.obj.init().then(function(){
186
+ return this$.obj.fit();
187
+ });
188
+ },
189
+ parse: function(){
190
+ var this$ = this;
191
+ return d3.select(this.svg).selectAll('path').each(function(d, i){
192
+ return d.data = this$.data.filter(function(it){
193
+ return it.name === d.properties.name;
194
+ })[0] || {};
195
+ });
196
+ },
197
+ resize: function(){},
198
+ render: function(){
199
+ var this$ = this;
200
+ this.color = d3.interpolateTurbo;
201
+ if (config.pal) {
202
+ this.color = d3.interpolateDiscrete(config.pal);
203
+ }
204
+ return d3.select(this.svg).selectAll('path').transition().duration(350).attr('fill', function(d, i){
205
+ return this$.color(d.data.color);
206
+ });
207
+ }
208
+ };
209
+ }
210
+ });</script></div>