@plotdb/chart 1.0.1 → 1.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 (164) hide show
  1. package/package.json +3 -1
  2. package/CHANGELOG.md +0 -29
  3. package/build +0 -45
  4. package/doc/charts.md +0 -58
  5. package/doc/config.md +0 -44
  6. package/doc/draft/chart.md +0 -146
  7. package/doc/draft/data.md +0 -8
  8. package/doc/draft/definition.md +0 -0
  9. package/doc/draft/events.md +0 -0
  10. package/doc/draft/filter.md +0 -0
  11. package/doc/draft/lifecycle.md +0 -89
  12. package/doc/spec.md +0 -89
  13. package/doc/todo.md +0 -27
  14. package/doc/utils/tip.md +0 -84
  15. package/src/data/en-US/category +0 -20
  16. package/src/data/en-US/fruit +0 -39
  17. package/src/data/en-US/movie +0 -125
  18. package/src/data/en-US/name +0 -58
  19. package/src/data/index.ls +0 -34
  20. package/src/data/zh-TW/category +0 -20
  21. package/src/data/zh-TW/fruits +0 -38
  22. package/src/data/zh-TW/movie +0 -125
  23. package/src/data/zh-TW/names +0 -105
  24. package/src/index.ls +0 -323
  25. package/src/index.styl +0 -6
  26. package/src/utils/axis.ls +0 -229
  27. package/src/utils/config.ls +0 -11
  28. package/src/utils/data.ls +0 -104
  29. package/src/utils/format.ls +0 -30
  30. package/src/utils/legend.ls +0 -134
  31. package/src/utils/legend.styl +0 -37
  32. package/src/utils/tint.ls +0 -66
  33. package/src/utils/tip.ls +0 -97
  34. package/web/src/pug/base.pug +0 -21
  35. package/web/src/pug/block/axis/0.0.1/index.ls +0 -32
  36. package/web/src/pug/block/axis/0.0.1/index.pug +0 -1
  37. package/web/src/pug/block/axis-bubble/0.0.1/index.ls +0 -137
  38. package/web/src/pug/block/axis-bubble/0.0.1/index.pug +0 -1
  39. package/web/src/pug/block/bar/0.0.1/index.ls +0 -270
  40. package/web/src/pug/block/bar/0.0.1/index.pug +0 -35
  41. package/web/src/pug/block/bar-list/0.0.1/index.ls +0 -81
  42. package/web/src/pug/block/bar-list/0.0.1/index.pug +0 -30
  43. package/web/src/pug/block/bar-race/0.0.1/index.ls +0 -79
  44. package/web/src/pug/block/bar-race/0.0.1/index.pug +0 -21
  45. package/web/src/pug/block/base/0.0.1/index.ls +0 -66
  46. package/web/src/pug/block/base/0.0.1/index.pug +0 -5
  47. package/web/src/pug/block/blank/0.0.1/index.ls +0 -21
  48. package/web/src/pug/block/blank/0.0.1/index.pug +0 -1
  49. package/web/src/pug/block/bubble/0.0.1/index.ls +0 -218
  50. package/web/src/pug/block/bubble/0.0.1/index.pug +0 -42
  51. package/web/src/pug/block/curve-bar/0.0.1/index.ls +0 -85
  52. package/web/src/pug/block/curve-bar/0.0.1/index.pug +0 -16
  53. package/web/src/pug/block/curve-bar/0.0.1/sample.js +0 -338
  54. package/web/src/pug/block/dumbbell/0.0.1/index.ls +0 -86
  55. package/web/src/pug/block/dumbbell/0.0.1/index.pug +0 -1
  56. package/web/src/pug/block/empty/0.0.1/index.ls +0 -28
  57. package/web/src/pug/block/empty/0.0.1/index.pug +0 -2
  58. package/web/src/pug/block/gauge/0.0.1/index.ls +0 -96
  59. package/web/src/pug/block/gauge/0.0.1/index.pug +0 -31
  60. package/web/src/pug/block/gauge/0.0.1/sample.js +0 -338
  61. package/web/src/pug/block/line/0.0.1/index.ls +0 -297
  62. package/web/src/pug/block/line/0.0.1/index.pug +0 -33
  63. package/web/src/pug/block/number/0.0.1/index.ls +0 -65
  64. package/web/src/pug/block/number/0.0.1/index.pug +0 -20
  65. package/web/src/pug/block/percent-list/0.0.1/index.ls +0 -161
  66. package/web/src/pug/block/percent-list/0.0.1/index.pug +0 -34
  67. package/web/src/pug/block/pie/0.0.1/index.ls +0 -121
  68. package/web/src/pug/block/pie/0.0.1/index.pug +0 -19
  69. package/web/src/pug/block/pie/0.0.1/sample.js +0 -338
  70. package/web/src/pug/block/pie-bubble/0.0.1/index.ls +0 -181
  71. package/web/src/pug/block/pie-bubble/0.0.1/index.pug +0 -40
  72. package/web/src/pug/block/radar/0.0.1/index.ls +0 -109
  73. package/web/src/pug/block/radar/0.0.1/index.pug +0 -1
  74. package/web/src/pug/block/radar/0.0.1/xx +0 -285
  75. package/web/src/pug/block/scatter/0.0.1/index.ls +0 -124
  76. package/web/src/pug/block/scatter/0.0.1/index.pug +0 -30
  77. package/web/src/pug/block/sheet/0.0.1/index.ls +0 -34
  78. package/web/src/pug/block/sheet/0.0.1/index.pug +0 -5
  79. package/web/src/pug/block/table/0.0.1/index.ls +0 -36
  80. package/web/src/pug/block/table/0.0.1/index.pug +0 -3
  81. package/web/src/pug/block/taiwancounty/0.0.1/index.ls +0 -70
  82. package/web/src/pug/block/taiwancounty/0.0.1/index.pug +0 -64
  83. package/web/src/pug/block/taiwantown/0.0.1/index.ls +0 -44
  84. package/web/src/pug/block/taiwantown/0.0.1/index.pug +0 -52
  85. package/web/src/pug/block/taiwanvillage/0.0.1/index.ls +0 -49
  86. package/web/src/pug/block/taiwanvillage/0.0.1/index.pug +0 -52
  87. package/web/src/pug/block/treemap/0.0.1/index.ls +0 -168
  88. package/web/src/pug/block/treemap/0.0.1/index.pug +0 -42
  89. package/web/src/pug/block/voronoi-treemap/0.0.1/index.ls +0 -170
  90. package/web/src/pug/block/voronoi-treemap/0.0.1/index.pug +0 -17
  91. package/web/src/pug/block/voronoi-treemap/0.0.1/sample.js +0 -241
  92. package/web/src/pug/block/wordcloud/0.0.1/index.ls +0 -57
  93. package/web/src/pug/block/wordcloud/0.0.1/index.pug +0 -1
  94. package/web/src/pug/block/worldmap/0.0.1/index.ls +0 -77
  95. package/web/src/pug/block/worldmap/0.0.1/index.pug +0 -12
  96. package/web/src/pug/index.ls +0 -72
  97. package/web/src/pug/index.pug +0 -51
  98. package/web/src/styl/index.styl +0 -6
  99. package/web/static/assets/block/cache.js +0 -4
  100. package/web/static/assets/custom-lib/d3/d3-array.v2.js +0 -1182
  101. package/web/static/assets/custom-lib/d3/d3-array.v2.min.js +0 -2
  102. package/web/static/assets/custom-lib/d3/d3-array.v3.js +0 -1273
  103. package/web/static/assets/custom-lib/d3/d3-array.v3.min.js +0 -1273
  104. package/web/static/assets/custom-lib/d3/d3-axis.v2.min.js +0 -2
  105. package/web/static/assets/custom-lib/d3/d3-brush.v2.min.js +0 -2
  106. package/web/static/assets/custom-lib/d3/d3-color.v2.min.js +0 -2
  107. package/web/static/assets/custom-lib/d3/d3-dispatch.v2.min.js +0 -2
  108. package/web/static/assets/custom-lib/d3/d3-drag.v2.min.js +0 -2
  109. package/web/static/assets/custom-lib/d3/d3-ease.v2.min.js +0 -2
  110. package/web/static/assets/custom-lib/d3/d3-force-boundary.v0.0.1.min.js +0 -2
  111. package/web/static/assets/custom-lib/d3/d3-force.v2.min.js +0 -2
  112. package/web/static/assets/custom-lib/d3/d3-format.v2.min.js +0 -2
  113. package/web/static/assets/custom-lib/d3/d3-geo.v2.js +0 -3127
  114. package/web/static/assets/custom-lib/d3/d3-geo.v2.min.js +0 -2
  115. package/web/static/assets/custom-lib/d3/d3-hierarchy.v2.min.js +0 -2
  116. package/web/static/assets/custom-lib/d3/d3-interpolate.v2.min.js +0 -2
  117. package/web/static/assets/custom-lib/d3/d3-path.v2.min.js +0 -2
  118. package/web/static/assets/custom-lib/d3/d3-quadtree.v2.min.js +0 -2
  119. package/web/static/assets/custom-lib/d3/d3-random.v2.min.js +0 -2
  120. package/web/static/assets/custom-lib/d3/d3-scale-chromatic.v1.min.js +0 -2
  121. package/web/static/assets/custom-lib/d3/d3-selection.v2.min.js +0 -2
  122. package/web/static/assets/custom-lib/d3/d3-shape.v2.min.js +0 -2
  123. package/web/static/assets/custom-lib/d3/d3-timer.v2.min.js +0 -2
  124. package/web/static/assets/custom-lib/d3/d3-transition.v2.min.js +0 -2
  125. package/web/static/assets/custom-lib/d3/d3.v4.js +0 -17178
  126. package/web/static/assets/custom-lib/d3/d3.v4.min.js +0 -2
  127. package/web/static/assets/custom-lib/d3/d3.v6.js +0 -19708
  128. package/web/static/assets/data/countrycode.json +0 -1
  129. package/web/static/assets/data/world-110m.json +0 -1
  130. package/web/static/assets/data/zh-to-alpha2.json +0 -1
  131. package/web/static/assets/img/fluid.svg +0 -16
  132. package/web/static/block/axis/0.0.1/index.html +0 -74
  133. package/web/static/block/axis-bubble/0.0.1/index.html +0 -217
  134. package/web/static/block/bar/0.0.1/index.html +0 -576
  135. package/web/static/block/bar-list/0.0.1/index.html +0 -226
  136. package/web/static/block/bar-race/0.0.1/index.html +0 -179
  137. package/web/static/block/base/0.0.1/index.html +0 -197
  138. package/web/static/block/blank/0.0.1/index.html +0 -37
  139. package/web/static/block/bubble/0.0.1/index.html +0 -422
  140. package/web/static/block/bubble/0.0.1/test.html +0 -0
  141. package/web/static/block/curve-bar/0.0.1/index.html +0 -143
  142. package/web/static/block/dumbbell/0.0.1/index.html +0 -173
  143. package/web/static/block/empty/0.0.1/index.html +0 -76
  144. package/web/static/block/gauge/0.0.1/index.html +0 -145
  145. package/web/static/block/line/0.0.1/index.html +0 -566
  146. package/web/static/block/number/0.0.1/index.html +0 -147
  147. package/web/static/block/percent-list/0.0.1/index.html +0 -311
  148. package/web/static/block/pie/0.0.1/index.html +0 -276
  149. package/web/static/block/pie-bubble/0.0.1/index.html +0 -353
  150. package/web/static/block/radar/0.0.1/index.html +0 -144
  151. package/web/static/block/scatter/0.0.1/index.html +0 -246
  152. package/web/static/block/sheet/0.0.1/index.html +0 -98
  153. package/web/static/block/table/0.0.1/index.html +0 -67
  154. package/web/static/block/taiwancounty/0.0.1/index.html +0 -197
  155. package/web/static/block/taiwantown/0.0.1/index.html +0 -205
  156. package/web/static/block/taiwanvillage/0.0.1/index.html +0 -215
  157. package/web/static/block/treemap/0.0.1/index.html +0 -355
  158. package/web/static/block/voronoi-treemap/0.0.1/index.html +0 -345
  159. package/web/static/block/wordcloud/0.0.1/index.html +0 -87
  160. package/web/static/block/worldmap/0.0.1/index.html +0 -202
  161. package/web/static/css/index.css +0 -6
  162. package/web/static/css/index.min.css +0 -1
  163. package/web/static/favicon.ico +0 -0
  164. package/web/static/index.html +0 -153
@@ -1,246 +0,0 @@
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">var mod;
22
- module.exports = {
23
- pkg: {
24
- name: 'scatter',
25
- version: '0.0.1',
26
- extend: {
27
- name: "base",
28
- version: "0.0.1"
29
- },
30
- dependencies: [{
31
- url: "http://cdn.jsdelivr.net/npm/d3-delaunay@6/dist/d3-delaunay.min.js"
32
- }]
33
- },
34
- init: function(arg$){
35
- var root, context, pubsub;
36
- root = arg$.root, context = arg$.context, pubsub = arg$.pubsub;
37
- return pubsub.fire('init', {
38
- mod: mod({
39
- context: context
40
- })
41
- });
42
- }
43
- };
44
- mod = function(arg$){
45
- var context, d3, chart, names;
46
- context = arg$.context;
47
- d3 = context.d3, chart = context.chart;
48
- 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"];
49
- return {
50
- sample: function(){
51
- return {
52
- 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){
53
- var ret;
54
- ret = {
55
- x: Math.random(),
56
- y: Math.random(),
57
- name: names[Math.floor(Math.random() * names.length)]
58
- };
59
- return ret;
60
- }),
61
- binding: {
62
- x: {
63
- key: 'x'
64
- },
65
- y: {
66
- key: 'y'
67
- },
68
- name: {
69
- key: 'name'
70
- }
71
- }
72
- };
73
- },
74
- config: {},
75
- dimension: {
76
- x: {
77
- type: 'R',
78
- name: "x axis"
79
- },
80
- y: {
81
- type: 'R',
82
- name: "y axis"
83
- },
84
- radius: {
85
- type: 'R',
86
- name: "radius"
87
- },
88
- category: {
89
- type: 'CN',
90
- name: "category"
91
- },
92
- name: {
93
- type: 'N',
94
- name: "name"
95
- }
96
- },
97
- init: function(){
98
- var tint, this$ = this;
99
- this.tint = tint = new chart.utils.tint();
100
- ['view', 'yaxis', 'xaxis'].map(function(it){
101
- return (this$.g || (this$.g = {}))[it] = d3.select(this$.layout.getGroup(it));
102
- });
103
- return this.path = d3.select(this.svg).append('path');
104
- },
105
- parse: function(){},
106
- resize: function(){
107
- var ref$, w, h, box, this$ = this;
108
- ref$ = [this.box.width, this.box.height], w = ref$[0], h = ref$[1];
109
- this.extent = {
110
- x: d3.extent(this.data.map(function(it){
111
- return it.x;
112
- })),
113
- y: d3.extent(this.data.map(function(it){
114
- return it.y;
115
- }))
116
- };
117
- box = this.layout.getBox('view');
118
- this.scale = {
119
- x: d3.scaleLinear().domain(this.extent.x).range([0, box.width]),
120
- y: d3.scaleLinear().domain(this.extent.y).range([0, box.height])
121
- };
122
- this.pts = this.data.map(function(d){
123
- return [this$.scale.x(d.x), this$.scale.y(d.y)];
124
- });
125
- this.delaunay = d3.Delaunay.from(this.pts);
126
- this.voronoi = this.delaunay.voronoi([0, 0, box.width, box.height]);
127
- return this.cells = this.pts.map(function(point, i){
128
- var x, y, polygon, centroid, ref$, cx, cy, area, angle;
129
- x = point[0], y = point[1];
130
- polygon = this$.voronoi.cellPolygon(i);
131
- ref$ = centroid = d3.polygonCentroid(polygon), cx = ref$[0], cy = ref$[1];
132
- area = -d3.polygonArea(polygon);
133
- angle = (Math.round(Math.atan2(cy - y, cx - x) / Math.PI * 2) + 4) % 4;
134
- return {
135
- point: point,
136
- polygon: polygon,
137
- centroid: centroid,
138
- area: area,
139
- angle: angle
140
- };
141
- });
142
- },
143
- render: function(){
144
- var scale, x$, y$;
145
- scale = this.scale;
146
- x$ = this.g.view.selectAll('circle.data').data(this.data);
147
- x$.exit().remove();
148
- x$.enter().append('circle').attr('class', 'data').attr('cx', function(d, i){
149
- return scale.x(d.x);
150
- }).attr('cy', function(d, i){
151
- return scale.y(d.y);
152
- }).attr('r', 3).attr('fill', '#000');
153
- y$ = this.g.view.selectAll('text').data(this.data);
154
- y$.exit().remove();
155
- y$.enter().append('text').text(function(d, i){
156
- return d.name;
157
- }).attr('x', function(d, i){
158
- if (d.nb) {
159
- return d.nb.x;
160
- } else {
161
- return scale.x(d.x);
162
- }
163
- }).attr('y', function(d, i){
164
- if (d.nb) {
165
- return d.nb.y;
166
- } else {
167
- return scale.y(d.y);
168
- }
169
- }).attr('text-anchor', 'middle').attr('dominant-baseline', 'middle');
170
- this.g.view.selectAll('text').data(this.data).attr('x', function(d, i){
171
- if (d.nb) {
172
- return d.nb.x;
173
- } else {
174
- return scale.x(d.x);
175
- }
176
- }).attr('y', function(d, i){
177
- if (d.nb) {
178
- return d.nb.y;
179
- } else {
180
- return scale.y(d.y) - 20;
181
- }
182
- }).attr('opacity', function(d, i){
183
- if (d.nb) {
184
- if (d.nb.show) {
185
- return 1;
186
- } else {
187
- return 0;
188
- }
189
- } else {
190
- return 1;
191
- }
192
- });
193
- return this.path.attr('d', this.voronoi.render()).attr('stroke', '#000').attr('transform', this.g.view.node().getAttribute('transform'));
194
- },
195
- tick: function(){
196
- var scale, rbox, i$, to$, i, d, ref$, r, j$, k$, j, a, b, data;
197
- scale = this.scale;
198
- this.g.view.selectAll('text').each(function(d, i){
199
- return d.box = this.getBoundingClientRect();
200
- });
201
- rbox = this.layout.getBox('view');
202
- for (i$ = 0, to$ = this.data.length; i$ < to$; ++i$) {
203
- i = i$;
204
- d = this.data[i].box;
205
- if (!this.data[i].nb) {
206
- this.data[i].nb = {
207
- x: scale.x(this.data[i].x),
208
- y: scale.y(this.data[i].y) - 20
209
- };
210
- }
211
- ref$ = this.data[i].nb;
212
- ref$.width = d.width;
213
- ref$.height = d.height;
214
- ref$.show = true;
215
- }
216
- for (i$ = 20; i$ < 200; i$ += 20) {
217
- r = i$;
218
- for (j$ = 0, to$ = this.data.length; j$ < to$; ++j$) {
219
- i = j$;
220
- for (k$ = 0; k$ < i; ++k$) {
221
- j = k$;
222
- ref$ = [this.data[i].nb, this.data[j].nb], a = ref$[0], b = ref$[1];
223
- 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))) {
224
- d = Math.random() * Math.PI * 2;
225
- data = this.data[i];
226
- ref$ = data.nb;
227
- ref$.x = scale.x(data.x) + Math.cos(d) * r;
228
- ref$.y = scale.y(data.y) + Math.sin(d) * r;
229
- }
230
- }
231
- }
232
- }
233
- for (i$ = 0, to$ = this.data.length; i$ < to$; ++i$) {
234
- i = i$;
235
- for (j$ = 0; j$ < i; ++j$) {
236
- j = j$;
237
- ref$ = [this.data[i].nb, this.data[j].nb], a = ref$[0], b = ref$[1];
238
- 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))) {
239
- this.data[i].nb.show = false;
240
- }
241
- }
242
- }
243
- return this.render();
244
- }
245
- };
246
- };</script></div>
@@ -1,98 +0,0 @@
1
- <div><div plug="layout"></div><style type="text/css"></style><script type="@plotdb/block">var mod;
2
- module.exports = {
3
- pkg: {
4
- name: 'bar',
5
- version: '0.0.1',
6
- extend: {
7
- name: "base",
8
- version: "0.0.1"
9
- },
10
- dependencies: [
11
- {
12
- url: "/assets/lib/@plotdb/sheet/main/index.min.js"
13
- }, {
14
- url: "/assets/lib/@plotdb/sheet/main/index.min.css"
15
- }
16
- ]
17
- },
18
- init: function(arg$){
19
- var root, context, t, pubsub;
20
- root = arg$.root, context = arg$.context, t = arg$.t, pubsub = arg$.pubsub;
21
- return pubsub.fire('init', {
22
- mod: mod({
23
- context: context,
24
- t: t
25
- }),
26
- prepareSvg: false,
27
- layout: false
28
- });
29
- }
30
- };
31
- mod = function(arg$){
32
- var context, t, chart, sheet;
33
- context = arg$.context, t = arg$.t;
34
- chart = context.chart, sheet = context.sheet;
35
- return {
36
- sample: function(){
37
- return {
38
- 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){
39
- return Object.fromEntries([1, 2, 3, 4, 5].map(function(it){
40
- return ["col" + it, (Math.random() * 100).toFixed(2)];
41
- }));
42
- }),
43
- binding: {
44
- column: [1, 2, 3, 4, 5].map(function(it){
45
- return {
46
- key: "col" + it
47
- };
48
- })
49
- }
50
- };
51
- },
52
- config: {},
53
- dimension: {
54
- column: {
55
- type: 'NCOR',
56
- multiple: true,
57
- name: 'column'
58
- }
59
- },
60
- init: function(){
61
- var this$ = this;
62
- this.sheet = new sheet({
63
- root: this.root.querySelector('[plug=layout]'),
64
- frozen: {
65
- row: 1
66
- },
67
- editing: false,
68
- idx: {
69
- row: true,
70
- col: true
71
- }
72
- });
73
- this.data = [this.binding.column.map(function(it){
74
- return it.name || it.key;
75
- })].concat(this.raw.map(function(r){
76
- return this$.binding.column.map(function(c){
77
- return r[c.key];
78
- });
79
- }));
80
- return this.sheet.data(this.data);
81
- },
82
- filter: function(filters, internal){
83
- internal == null && (internal = false);
84
- },
85
- parse: function(){
86
- var head;
87
- head = this.binding.column.map(function(it){
88
- return it.name || it.key;
89
- });
90
- this.parsed = [head].concat(this.data.map(function(it){
91
- return it.column;
92
- }));
93
- return this.sheet.data(this.parsed);
94
- },
95
- resize: function(){},
96
- render: function(){}
97
- };
98
- };</script></div>
@@ -1,67 +0,0 @@
1
- <div style="height:100%"><plug name="layout"></plug><script type="@plotdb/block">module.exports = {
2
- pkg: {
3
- name: 'table',
4
- version: '0.0.1',
5
- extend: {
6
- name: "empty",
7
- version: "0.0.1"
8
- },
9
- dependencies: [
10
- {
11
- url: "/assets/lib/gridjs/main/gridjs.production.min.js"
12
- }, {
13
- url: "/assets/lib/gridjs/main/theme/mermaid.min.css"
14
- }
15
- ]
16
- },
17
- init: function(arg$){
18
- var root, context, pubsub, gridjs;
19
- root = arg$.root, context = arg$.context, pubsub = arg$.pubsub;
20
- gridjs = context.gridjs;
21
- return pubsub.fire('init', {
22
- layout: false,
23
- prepareSvg: false,
24
- mod: {
25
- init: function(){
26
- var grid;
27
- this.grid = grid = new gridjs.Grid({
28
- columns: [' ', ' ', ' ', ' ', ' '],
29
- height: this.root.getBoundingClientRect().height + "px",
30
- fixedHeader: true,
31
- sort: true,
32
- search: false,
33
- resizable: true,
34
- data: [].concat([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(function(){
35
- return [];
36
- }))
37
- });
38
- return grid.render(this.root);
39
- },
40
- parse: function(){
41
- var head, res$, k, raw;
42
- res$ = [];
43
- for (k in this.raw[0] || {}) {
44
- res$.push(k);
45
- }
46
- head = res$;
47
- head.length;
48
- raw = this.raw;
49
- console.log(raw);
50
- return;
51
- return this.grid.updateConfig({
52
- columns: raw[0],
53
- data: raw.slice(1).concat((function(){
54
- var i$, to$, ref$, results$ = [];
55
- for (i$ = 0, to$ = (ref$ = 20 - raw.length) > 0 ? ref$ : 0; i$ <= to$; ++i$) {
56
- results$.push(i$);
57
- }
58
- return results$;
59
- }()).map(function(){
60
- return [];
61
- }))
62
- }).forceRender();
63
- }
64
- }
65
- });
66
- }
67
- };</script></div>
@@ -1,197 +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="legend">123</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(5em);
4
- }
5
- </style><script type="@plotdb/block">var mod;
6
- module.exports = {
7
- pkg: {
8
- name: 'taiwancounty',
9
- version: '0.0.1',
10
- extend: {
11
- name: "base",
12
- version: "0.0.1"
13
- },
14
- dependencies: [
15
- {
16
- url: "https://d3js.org/topojson.v2.min.js",
17
- async: false
18
- }, {
19
- url: "https://d3js.org/d3-geo.v2.min.js",
20
- async: false
21
- }, {
22
- name: "pdmaptw",
23
- version: "local",
24
- path: "index.min.js",
25
- async: false
26
- }, {
27
- name: "pdmaptw",
28
- version: "local",
29
- path: "county.map.js"
30
- }
31
- ]
32
- },
33
- init: function(arg$){
34
- var root, context, pubsub;
35
- root = arg$.root, context = arg$.context, pubsub = arg$.pubsub;
36
- return pubsub.fire('init', {
37
- mod: mod({
38
- context: context
39
- })
40
- }).then(function(it){
41
- return it[0];
42
- });
43
- }
44
- };
45
- mod = function(arg$){
46
- var context, chart, d3, ldcolor, pdmaptw, topojson;
47
- context = arg$.context;
48
- chart = context.chart, d3 = context.d3, ldcolor = context.ldcolor, pdmaptw = context.pdmaptw, topojson = context.topojson;
49
- return {
50
- sample: function(){
51
- return pdmaptw.get('county').then(function(arg$){
52
- var meta, topo;
53
- meta = arg$.meta, topo = arg$.topo;
54
- return {
55
- raw: meta.name.map(function(it){
56
- return {
57
- val: Math.random(),
58
- name: pdmaptw.normalize(it)
59
- };
60
- }),
61
- binding: {
62
- color: {
63
- key: 'val'
64
- },
65
- name: {
66
- key: 'name'
67
- }
68
- }
69
- };
70
- });
71
- },
72
- config: {
73
- palette: {
74
- type: 'palette'
75
- }
76
- },
77
- dimension: {
78
- name: {
79
- type: 'N',
80
- name: "國家"
81
- },
82
- color: {
83
- type: 'R',
84
- name: "顏色"
85
- }
86
- },
87
- init: function(){
88
- var scale, this$ = this;
89
- this.g = this.layout.getGroup('view');
90
- this.obj = new pdmaptw({
91
- root: this.g,
92
- type: 'county'
93
- });
94
- this.scale = scale = {
95
- color: d3.interpolateTurbo
96
- };
97
- this.legend = new chart.utils.legend({
98
- root: this.root,
99
- name: 'legend',
100
- layout: this.layout,
101
- shape: function(d){
102
- return d3.select(this).attr('fill', scale.color(d.key));
103
- }
104
- });
105
- this.tip = new chart.utils.tip({
106
- root: this.root,
107
- accessor: function(arg$){
108
- var evt, data;
109
- evt = arg$.evt;
110
- if (!(evt.target && (data = d3.select(evt.target).datum()))) {
111
- return null;
112
- }
113
- return {
114
- name: data.data.name,
115
- value: data.data.color
116
- };
117
- },
118
- range: function(){
119
- return this$.layout.getNode('view').getBoundingClientRect();
120
- }
121
- });
122
- return this.obj.init().then(function(){
123
- return this$.obj.fit({
124
- node: this$.g,
125
- box: this$.layout.getNode('view').getBoundingClientRect()
126
- });
127
- });
128
- },
129
- parse: function(){
130
- var this$ = this;
131
- this.extent = {
132
- c: [undefined, undefined]
133
- };
134
- return d3.select(this.svg).selectAll('path').each(function(d, i){
135
- d.data = this$.data.filter(function(it){
136
- return it.name === d.properties.name;
137
- })[0] || {};
138
- if (!(this$.extent.c[0] != null) || d.data.color < this$.extent.c[0]) {
139
- this$.extent.c[0] = d.data.color;
140
- }
141
- if (!(this$.extent.c[1] != null) || d.data.color > this$.extent.c[1]) {
142
- return this$.extent.c[1] = d.data.color;
143
- }
144
- });
145
- },
146
- resize: function(){
147
- var ref$, pal, len, this$ = this;
148
- this.tip.toggle(((ref$ = this.cfg).tip || (ref$.tip = {})).enabled != null ? this.cfg.tip.enabled : true);
149
- this.obj.fit(this.layout.getBox('view'));
150
- pal = this.cfg.palette
151
- ? this.cfg.palette.colors
152
- : ['#f00', '#999', '#00f'];
153
- len = pal.length;
154
- this.ticks = d3.quantize(function(it){
155
- return (1 - it) * (this$.extent.c[1] - this$.extent.c[0]) + this$.extent.c[0];
156
- }, len).map(function(it){
157
- var that;
158
- return {
159
- key: it,
160
- text: d3.format(this$.cfg.legendFormat || '.2f')(it) + ((that = this$.binding.color.unit) ? that : '')
161
- };
162
- });
163
- this.ticks.sort(function(a, b){
164
- return a.key - b.key;
165
- });
166
- if (this.cfg.palette) {
167
- this.scale.color = d3.scaleLinear().domain(this.ticks.map(function(it){
168
- return it.key;
169
- })).range(pal.map(function(it){
170
- return ldcolor.web(it.value || it);
171
- }));
172
- }
173
- this.legend.data(this.ticks);
174
- return this.obj.fit({
175
- node: this.g,
176
- box: this.layout.getBox('view')
177
- });
178
- },
179
- render: function(){
180
- var this$ = this;
181
- d3.select(this.svg).selectAll('path').transition().duration(350).attr('fill', function(d, i){
182
- return this$.scale.color(d.data.color);
183
- }).attr('fill-opacity', function(d, i){
184
- if (this$.cfg.dimEmpty) {
185
- if (d.data.color != null) {
186
- return 1;
187
- } else {
188
- return 0.2;
189
- }
190
- } else {
191
- return 1;
192
- }
193
- });
194
- return this.legend.render();
195
- }
196
- };
197
- };</script></div>