@plotdb/chart 0.0.3 → 2.0.0

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 (194) hide show
  1. package/CHANGELOG.md +34 -1
  2. package/README.md +3 -3
  3. package/{dist/data → data}/index.js +0 -0
  4. package/{dist/chart.css → index.css} +0 -0
  5. package/{dist/chart.js → index.js} +3 -1
  6. package/{dist/chart.min.css → index.min.css} +0 -0
  7. package/index.min.js +1 -0
  8. package/package.json +1 -89
  9. package/{dist/utils → utils}/axis.js +6 -0
  10. package/utils/axis.min.js +1 -0
  11. package/{dist/utils → utils}/config.js +0 -0
  12. package/utils/config.min.js +1 -0
  13. package/{dist/utils → utils}/data.js +0 -0
  14. package/utils/data.min.js +1 -0
  15. package/{dist/utils → utils}/format.js +0 -0
  16. package/utils/format.min.js +1 -0
  17. package/{dist/utils → utils}/legend.css +0 -0
  18. package/{dist/utils → utils}/legend.js +0 -0
  19. package/{dist/utils → utils}/legend.min.css +0 -0
  20. package/utils/legend.min.js +1 -0
  21. package/{dist/utils → utils}/tint.js +0 -0
  22. package/utils/tint.min.js +1 -0
  23. package/{dist/utils → utils}/tip.js +0 -0
  24. package/utils/tip.min.js +1 -0
  25. package/build +0 -39
  26. package/dist/chart.min.js +0 -1
  27. package/dist/utils/axis.min.js +0 -1
  28. package/dist/utils/config.min.js +0 -1
  29. package/dist/utils/data.min.js +0 -1
  30. package/dist/utils/format.min.js +0 -1
  31. package/dist/utils/legend.min.js +0 -1
  32. package/dist/utils/tint.min.js +0 -1
  33. package/dist/utils/tip.min.js +0 -1
  34. package/doc/charts.md +0 -58
  35. package/doc/config.md +0 -44
  36. package/doc/draft/chart.md +0 -146
  37. package/doc/draft/data.md +0 -8
  38. package/doc/draft/definition.md +0 -0
  39. package/doc/draft/events.md +0 -0
  40. package/doc/draft/filter.md +0 -0
  41. package/doc/draft/lifecycle.md +0 -89
  42. package/doc/spec.md +0 -89
  43. package/doc/todo.md +0 -27
  44. package/doc/utils/tip.md +0 -84
  45. package/src/chart.ls +0 -323
  46. package/src/chart.styl +0 -6
  47. package/src/data/en-US/category +0 -20
  48. package/src/data/en-US/fruit +0 -39
  49. package/src/data/en-US/movie +0 -125
  50. package/src/data/en-US/name +0 -58
  51. package/src/data/index.ls +0 -34
  52. package/src/data/zh-TW/category +0 -20
  53. package/src/data/zh-TW/fruits +0 -38
  54. package/src/data/zh-TW/movie +0 -125
  55. package/src/data/zh-TW/names +0 -105
  56. package/src/utils/axis.ls +0 -229
  57. package/src/utils/config.ls +0 -11
  58. package/src/utils/data.ls +0 -104
  59. package/src/utils/format.ls +0 -30
  60. package/src/utils/legend.ls +0 -134
  61. package/src/utils/legend.styl +0 -37
  62. package/src/utils/tint.ls +0 -66
  63. package/src/utils/tip.ls +0 -97
  64. package/web/src/pug/base.pug +0 -20
  65. package/web/src/pug/block/axis/0.0.1/index.ls +0 -38
  66. package/web/src/pug/block/axis/0.0.1/index.pug +0 -1
  67. package/web/src/pug/block/axis-bubble/0.0.1/index.ls +0 -141
  68. package/web/src/pug/block/axis-bubble/0.0.1/index.pug +0 -1
  69. package/web/src/pug/block/bar/0.0.1/index.ls +0 -274
  70. package/web/src/pug/block/bar/0.0.1/index.pug +0 -35
  71. package/web/src/pug/block/bar-list/0.0.1/index.ls +0 -85
  72. package/web/src/pug/block/bar-list/0.0.1/index.pug +0 -30
  73. package/web/src/pug/block/bar-race/0.0.1/index.ls +0 -83
  74. package/web/src/pug/block/bar-race/0.0.1/index.pug +0 -21
  75. package/web/src/pug/block/base/0.0.1/index.ls +0 -67
  76. package/web/src/pug/block/base/0.0.1/index.pug +0 -5
  77. package/web/src/pug/block/blank/0.0.1/index.ls +0 -25
  78. package/web/src/pug/block/blank/0.0.1/index.pug +0 -1
  79. package/web/src/pug/block/bubble/0.0.1/index.ls +0 -220
  80. package/web/src/pug/block/bubble/0.0.1/index.pug +0 -28
  81. package/web/src/pug/block/curve-bar/0.0.1/index.ls +0 -89
  82. package/web/src/pug/block/curve-bar/0.0.1/index.pug +0 -16
  83. package/web/src/pug/block/curve-bar/0.0.1/sample.js +0 -338
  84. package/web/src/pug/block/dumbbell/0.0.1/index.ls +0 -90
  85. package/web/src/pug/block/dumbbell/0.0.1/index.pug +0 -1
  86. package/web/src/pug/block/empty/0.0.1/index.ls +0 -27
  87. package/web/src/pug/block/empty/0.0.1/index.pug +0 -2
  88. package/web/src/pug/block/gauge/0.0.1/index.ls +0 -100
  89. package/web/src/pug/block/gauge/0.0.1/index.pug +0 -31
  90. package/web/src/pug/block/gauge/0.0.1/sample.js +0 -338
  91. package/web/src/pug/block/line/0.0.1/index.ls +0 -302
  92. package/web/src/pug/block/line/0.0.1/index.pug +0 -33
  93. package/web/src/pug/block/number/0.0.1/index.ls +0 -69
  94. package/web/src/pug/block/number/0.0.1/index.pug +0 -20
  95. package/web/src/pug/block/percent-list/0.0.1/index.ls +0 -167
  96. package/web/src/pug/block/percent-list/0.0.1/index.pug +0 -34
  97. package/web/src/pug/block/pie/0.0.1/index.ls +0 -125
  98. package/web/src/pug/block/pie/0.0.1/index.pug +0 -19
  99. package/web/src/pug/block/pie/0.0.1/sample.js +0 -338
  100. package/web/src/pug/block/pie-bubble/0.0.1/index.ls +0 -185
  101. package/web/src/pug/block/pie-bubble/0.0.1/index.pug +0 -40
  102. package/web/src/pug/block/radar/0.0.1/index.ls +0 -113
  103. package/web/src/pug/block/radar/0.0.1/index.pug +0 -1
  104. package/web/src/pug/block/radar/0.0.1/xx +0 -285
  105. package/web/src/pug/block/scatter/0.0.1/index.ls +0 -128
  106. package/web/src/pug/block/scatter/0.0.1/index.pug +0 -30
  107. package/web/src/pug/block/sheet/0.0.1/index.ls +0 -38
  108. package/web/src/pug/block/sheet/0.0.1/index.pug +0 -5
  109. package/web/src/pug/block/table/0.0.1/index.ls +0 -40
  110. package/web/src/pug/block/table/0.0.1/index.pug +0 -3
  111. package/web/src/pug/block/taiwancounty/0.0.1/index.ls +0 -74
  112. package/web/src/pug/block/taiwancounty/0.0.1/index.pug +0 -64
  113. package/web/src/pug/block/taiwantown/0.0.1/index.ls +0 -48
  114. package/web/src/pug/block/taiwantown/0.0.1/index.pug +0 -52
  115. package/web/src/pug/block/taiwanvillage/0.0.1/index.ls +0 -53
  116. package/web/src/pug/block/taiwanvillage/0.0.1/index.pug +0 -52
  117. package/web/src/pug/block/treemap/0.0.1/index.ls +0 -172
  118. package/web/src/pug/block/treemap/0.0.1/index.pug +0 -42
  119. package/web/src/pug/block/voronoi-treemap/0.0.1/index.ls +0 -174
  120. package/web/src/pug/block/voronoi-treemap/0.0.1/index.pug +0 -17
  121. package/web/src/pug/block/voronoi-treemap/0.0.1/sample.js +0 -241
  122. package/web/src/pug/block/wordcloud/0.0.1/index.ls +0 -61
  123. package/web/src/pug/block/wordcloud/0.0.1/index.pug +0 -1
  124. package/web/src/pug/block/worldmap/0.0.1/index.ls +0 -81
  125. package/web/src/pug/block/worldmap/0.0.1/index.pug +0 -12
  126. package/web/src/pug/index.ls +0 -72
  127. package/web/src/pug/index.pug +0 -51
  128. package/web/src/styl/index.styl +0 -0
  129. package/web/static/assets/block/cache.js +0 -4
  130. package/web/static/assets/custom-lib/d3/d3-array.v2.js +0 -1182
  131. package/web/static/assets/custom-lib/d3/d3-array.v2.min.js +0 -2
  132. package/web/static/assets/custom-lib/d3/d3-array.v3.js +0 -1273
  133. package/web/static/assets/custom-lib/d3/d3-array.v3.min.js +0 -1273
  134. package/web/static/assets/custom-lib/d3/d3-axis.v2.min.js +0 -2
  135. package/web/static/assets/custom-lib/d3/d3-brush.v2.min.js +0 -2
  136. package/web/static/assets/custom-lib/d3/d3-color.v2.min.js +0 -2
  137. package/web/static/assets/custom-lib/d3/d3-dispatch.v2.min.js +0 -2
  138. package/web/static/assets/custom-lib/d3/d3-drag.v2.min.js +0 -2
  139. package/web/static/assets/custom-lib/d3/d3-ease.v2.min.js +0 -2
  140. package/web/static/assets/custom-lib/d3/d3-force-boundary.v0.0.1.min.js +0 -2
  141. package/web/static/assets/custom-lib/d3/d3-force.v2.min.js +0 -2
  142. package/web/static/assets/custom-lib/d3/d3-format.v2.min.js +0 -2
  143. package/web/static/assets/custom-lib/d3/d3-geo.v2.js +0 -3127
  144. package/web/static/assets/custom-lib/d3/d3-geo.v2.min.js +0 -2
  145. package/web/static/assets/custom-lib/d3/d3-hierarchy.v2.min.js +0 -2
  146. package/web/static/assets/custom-lib/d3/d3-interpolate.v2.min.js +0 -2
  147. package/web/static/assets/custom-lib/d3/d3-path.v2.min.js +0 -2
  148. package/web/static/assets/custom-lib/d3/d3-quadtree.v2.min.js +0 -2
  149. package/web/static/assets/custom-lib/d3/d3-random.v2.min.js +0 -2
  150. package/web/static/assets/custom-lib/d3/d3-scale-chromatic.v1.min.js +0 -2
  151. package/web/static/assets/custom-lib/d3/d3-selection.v2.min.js +0 -2
  152. package/web/static/assets/custom-lib/d3/d3-shape.v2.min.js +0 -2
  153. package/web/static/assets/custom-lib/d3/d3-timer.v2.min.js +0 -2
  154. package/web/static/assets/custom-lib/d3/d3-transition.v2.min.js +0 -2
  155. package/web/static/assets/custom-lib/d3/d3.v4.js +0 -17178
  156. package/web/static/assets/custom-lib/d3/d3.v4.min.js +0 -2
  157. package/web/static/assets/custom-lib/d3/d3.v6.js +0 -19708
  158. package/web/static/assets/data/countrycode.json +0 -1
  159. package/web/static/assets/data/world-110m.json +0 -1
  160. package/web/static/assets/data/zh-to-alpha2.json +0 -1
  161. package/web/static/assets/img/fluid.svg +0 -16
  162. package/web/static/block/axis/0.0.1/index.html +0 -79
  163. package/web/static/block/axis-bubble/0.0.1/index.html +0 -222
  164. package/web/static/block/bar/0.0.1/index.html +0 -581
  165. package/web/static/block/bar-list/0.0.1/index.html +0 -231
  166. package/web/static/block/bar-race/0.0.1/index.html +0 -184
  167. package/web/static/block/base/0.0.1/index.html +0 -197
  168. package/web/static/block/blank/0.0.1/index.html +0 -42
  169. package/web/static/block/bubble/0.0.1/index.html +0 -402
  170. package/web/static/block/bubble/0.0.1/test.html +0 -0
  171. package/web/static/block/curve-bar/0.0.1/index.html +0 -148
  172. package/web/static/block/dumbbell/0.0.1/index.html +0 -178
  173. package/web/static/block/empty/0.0.1/index.html +0 -76
  174. package/web/static/block/gauge/0.0.1/index.html +0 -150
  175. package/web/static/block/line/0.0.1/index.html +0 -571
  176. package/web/static/block/number/0.0.1/index.html +0 -152
  177. package/web/static/block/percent-list/0.0.1/index.html +0 -316
  178. package/web/static/block/pie/0.0.1/index.html +0 -281
  179. package/web/static/block/pie-bubble/0.0.1/index.html +0 -358
  180. package/web/static/block/radar/0.0.1/index.html +0 -149
  181. package/web/static/block/scatter/0.0.1/index.html +0 -251
  182. package/web/static/block/sheet/0.0.1/index.html +0 -103
  183. package/web/static/block/table/0.0.1/index.html +0 -73
  184. package/web/static/block/taiwancounty/0.0.1/index.html +0 -202
  185. package/web/static/block/taiwantown/0.0.1/index.html +0 -210
  186. package/web/static/block/taiwanvillage/0.0.1/index.html +0 -220
  187. package/web/static/block/treemap/0.0.1/index.html +0 -360
  188. package/web/static/block/voronoi-treemap/0.0.1/index.html +0 -350
  189. package/web/static/block/wordcloud/0.0.1/index.html +0 -92
  190. package/web/static/block/worldmap/0.0.1/index.html +0 -207
  191. package/web/static/css/index.css +0 -0
  192. package/web/static/css/index.min.css +0 -0
  193. package/web/static/favicon.ico +0 -0
  194. package/web/static/index.html +0 -153
@@ -1,149 +0,0 @@
1
- <div><script type="@plotdb/block">(function(it){
2
- return it();
3
- })(function(){
4
- var blockFactory, mod;
5
- blockFactory = {
6
- pkg: {
7
- name: 'radar',
8
- version: '0.0.1',
9
- extend: {
10
- name: "base",
11
- version: "0.0.1"
12
- },
13
- dependencies: []
14
- },
15
- init: function(arg$){
16
- var root, context, pubsub;
17
- root = arg$.root, context = arg$.context, pubsub = arg$.pubsub;
18
- return pubsub.fire('init', {
19
- mod: mod({
20
- context: context
21
- })
22
- }).then(function(it){
23
- return it[0];
24
- });
25
- }
26
- };
27
- mod = function(arg$){
28
- var context, d3, forceBoundary, ldColor, repeatString$;
29
- context = arg$.context;
30
- d3 = context.d3, forceBoundary = context.forceBoundary, ldColor = context.ldColor, repeatString$ = context.repeatString$;
31
- return {
32
- sample: function(){
33
- return {
34
- raw: [0, 1, 2, 3, 4].map(function(idx){
35
- return {
36
- val: [0, 1, 2].map(function(){
37
- return 0.5 + 0.5 * Math.random();
38
- }),
39
- cat: idx
40
- };
41
- }),
42
- binding: {
43
- radius: {
44
- key: 'val'
45
- },
46
- order: {
47
- key: 'cat'
48
- }
49
- }
50
- };
51
- },
52
- config: {},
53
- dimension: {
54
- radius: {
55
- type: 'R',
56
- name: "radius of point on radar line"
57
- },
58
- order: {
59
- type: 'R',
60
- name: "order of data point"
61
- }
62
- },
63
- init: function(){
64
- var svg, gs, this$ = this;
65
- svg = d3.select(this.svg);
66
- this.gs = gs = {};
67
- gs.all = svg.append('g');
68
- return this.line = d3.line().x(function(d, i){
69
- return this$.scale.r(d) * Math.cos(this$.scale.a(this$.orders[i]));
70
- }).y(function(d, i){
71
- return this$.scale.r(d) * -Math.sin(this$.scale.a(this$.orders[i]));
72
- });
73
- },
74
- parse: function(){
75
- this.orders = Array.from(new Set(this.data.map(function(it){
76
- return it.order;
77
- })));
78
- this.parsed = d3.transpose(this.data.map(function(it){
79
- return it.radius;
80
- }));
81
- this.parsed.map(function(d, i){
82
- return d.idx = i;
83
- });
84
- this.names = ['1', '2', '3'];
85
- this.radiusRange = d3.extent(this.parsed.map(function(d){
86
- return d3.extent(d);
87
- }).reduce(function(a, b){
88
- return a.concat(b);
89
- }, []));
90
- if (this.radiusRange[0] === this.radiusRange[1]) {
91
- return this.radiusRange[1]++;
92
- }
93
- },
94
- bind: function(){
95
- var x$, y$;
96
- x$ = this.gs.all.selectAll('path.data').data(this.parsed);
97
- x$.exit().attr('class', "").transition('exit').duration(500).attr('opacity', 0).remove();
98
- x$.enter().append('path').attr('class', 'data').attr('opacity', 0);
99
- y$ = this.gs.all.selectAll('g.data-group').data(this.parsed);
100
- y$.exit().attr('class', "").transition('exit').duration(500).attr('opacity', 0).remove();
101
- y$.enter().append('g').attr('class', 'data-group').attr('opacity', 0);
102
- return this.gs.all.selectAll('g.data-group').each(function(d, i){
103
- var x$;
104
- x$ = d3.select(this).selectAll('circle.node').data(d);
105
- x$.exit().attr('class', '').transition('exit').duration(500).attr('opacity', 0).remove();
106
- x$.enter().append('circle').attr('class', 'node').attr('opacity', 0);
107
- return x$;
108
- });
109
- },
110
- resize: function(){
111
- var size, ref$;
112
- size = (ref$ = Math.min(this.box.width, this.box.height) / 2) > 10 ? ref$ : 10;
113
- this.scale = {
114
- r: d3.scaleLinear().domain([0, this.radiusRange[1]]).range([0, size]),
115
- a: d3.scalePoint().domain(this.orders).range([0, 2 * Math.PI]),
116
- c: d3.interpolateTurbo
117
- };
118
- if (this.cfg != null && this.cfg.palette) {
119
- this.scale.c = d3.interpolateDiscrete(this.cfg.palette.colors.map(function(it){
120
- return ldColor.web(it.value || it);
121
- }));
122
- }
123
- return this.aTicks = d3.range(this.data.length);
124
- },
125
- render: function(){
126
- var scale, names, line, orders;
127
- scale = this.scale, names = this.names, line = this.line, orders = this.orders, orders = this.orders;
128
- this.gs.all.attr('transform', "translate(" + this.box.width / 2 + "," + this.box.height / 2 + ")");
129
- this.gs.all.selectAll('path.data').each(function(d, i){
130
- var color;
131
- color = scale.c(i / (names.length - 1));
132
- return d3.select(this).attr('fill', color).attr('fill-opacity', 0.2).attr('stroke', color).attr('stroke-width', 1).transition('morph').duration(350).attr('d', function(d, i){
133
- return line(d, i) + "Z";
134
- });
135
- }).transition('opacity').duration(350).attr('opacity', 1);
136
- return this.gs.all.selectAll('g.data-group').each(function(d, i){
137
- var color;
138
- color = scale.c(i / (names.length - 1));
139
- return d3.select(this).selectAll('circle.node').attr('fill', '#fff').attr('stroke', color).attr('stroke-width', 1).transition('morph').duration(350).attr('cx', function(d, i){
140
- return scale.r(d) * Math.cos(scale.a(orders[i]));
141
- }).attr('cy', function(d, i){
142
- return scale.r(d) * -Math.sin(scale.a(orders[i]));
143
- }).attr('r', 3).attr('opacity', 1);
144
- }).transition('opacity').duration(350).attr('opacity', 1);
145
- }
146
- };
147
- };
148
- return blockFactory;
149
- });</script></div>
@@ -1,251 +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">(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>
@@ -1,103 +0,0 @@
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>
@@ -1,73 +0,0 @@
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>