@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,353 +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"></div></div><div data-type="render"></div></div><div data-name="tip"><div ld="name"></div><div ld="value1"></div><div ld="value2"></div></div></div><style type="text/css">/*.pdl-cell { width: 100%; height: 100% }*/
2
- .pdl-layout > div[data-type=layout] {
3
- display: grid;
4
- grid-template-columns: 1fr fit-content(10em);
5
- }
6
- .pdl-layout > div[data-type=layout] > .pdl-cell[data-name=view] {
7
- grid-area: 1/1;
8
- }
9
- .pdl-layout > div[data-type=layout] > .pdl-cell[data-name=legend] {
10
- grid-column: 2;
11
- grid-row: 1;
12
- padding: 0 0.5em 0 0.5em;
13
- }
14
- [data-name=tip] {
15
- padding: 0.4em 0.5em;
16
- background: #13171a;
17
- color: #fff;
18
- border-radius: 3px;
19
- box-shadow: 0 2px 4px rgba(0,0,0,0.3);
20
- line-height: 1.2em;
21
- font-size: 0.9em;
22
- max-width: 10em;
23
- word-break: break-all;
24
- }
25
- [data-name=tip] [ld=name] {
26
- font-size: 0.85em;
27
- }
28
- [data-name=tip] [ld=value1],
29
- [data-name=tip] [ld=value2] {
30
- font-weight: bold;
31
- font-size: 1.1em;
32
- line-height: 1.2em;
33
- }
34
- </style><script type="@plotdb/block">var mod;
35
- module.exports = {
36
- pkg: {
37
- name: 'pie-bubble',
38
- version: '0.0.1',
39
- extend: {
40
- name: "base",
41
- version: "0.0.1"
42
- },
43
- dependencies: []
44
- },
45
- init: function(arg$){
46
- var root, context, pubsub;
47
- root = arg$.root, context = arg$.context, pubsub = arg$.pubsub;
48
- return pubsub.fire('init', {
49
- mod: mod({
50
- context: context
51
- })
52
- }).then(function(it){
53
- return it[0];
54
- });
55
- }
56
- };
57
- mod = function(arg$){
58
- var context, d3, forceBoundary, ldcolor, chart, ref$;
59
- context = arg$.context;
60
- d3 = context.d3, forceBoundary = context.forceBoundary, ldcolor = context.ldcolor, chart = context.chart;
61
- return {
62
- sample: function(){
63
- return {
64
- raw: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50].map(function(val){
65
- return {
66
- name: "name" + val,
67
- val1: Math.random() * 100,
68
- val2: Math.random() * 100
69
- };
70
- }),
71
- binding: {
72
- name: {
73
- key: 'name'
74
- },
75
- left: {
76
- key: 'val1'
77
- },
78
- right: {
79
- key: 'val2'
80
- }
81
- }
82
- };
83
- },
84
- config: (ref$ = import$({}, chart.utils.config.preset['default']), ref$.color = {
85
- left: {
86
- type: 'color',
87
- 'default': '#f90'
88
- },
89
- right: {
90
- type: 'color',
91
- 'default': '#09f'
92
- }
93
- }, ref$),
94
- dimension: {
95
- name: {
96
- type: 'N',
97
- name: "name"
98
- },
99
- left: {
100
- type: 'R',
101
- name: "size in left"
102
- },
103
- right: {
104
- type: 'R',
105
- name: "size in right"
106
- }
107
- },
108
- init: function(){
109
- var tint, this$ = this;
110
- this.tint = tint = new chart.utils.tint();
111
- this.valid = [];
112
- this.g = Object.fromEntries(['view', 'legend'].map(function(it){
113
- return [it, d3.select(this$.layout.getGroup(it))];
114
- }));
115
- this.tip = new chart.utils.tip({
116
- root: this.root,
117
- node: this.root.querySelector('[data-name=tip]'),
118
- view: {
119
- name: function(arg$){
120
- var ctx;
121
- ctx = arg$.ctx;
122
- if (ctx) {
123
- return ctx.name;
124
- } else {
125
- return '';
126
- }
127
- },
128
- value1: function(arg$){
129
- var ctx;
130
- ctx = arg$.ctx;
131
- if (ctx) {
132
- return ctx.value1;
133
- } else {
134
- return '';
135
- }
136
- },
137
- value2: function(arg$){
138
- var ctx;
139
- ctx = arg$.ctx;
140
- if (ctx) {
141
- return ctx.value2;
142
- } else {
143
- return '';
144
- }
145
- }
146
- },
147
- accessor: function(arg$){
148
- var evt, data, unit, fmt;
149
- evt = arg$.evt;
150
- if (!(evt.target && (data = d3.select(evt.target).datum()))) {
151
- return null;
152
- }
153
- unit = this$.binding.left.unit || this$.binding.right.unit || '';
154
- fmt = d3.format('.3s');
155
- return {
156
- name: data.name || '',
157
- value1: this$.legendData[0].text + ": " + fmt(data.L) + unit,
158
- value2: this$.legendData[1].text + ": " + fmt(data.R) + unit
159
- };
160
- },
161
- range: function(){
162
- return this$.layout.getNode('view').getBoundingClientRect();
163
- }
164
- });
165
- this.legend = new chart.utils.legend({
166
- layout: this.layout,
167
- name: 'legend',
168
- root: this.root,
169
- shape: function(d){
170
- return d3.select(this).attr('fill', tint.get(d.key));
171
- },
172
- cfg: {
173
- selectable: true
174
- }
175
- });
176
- return this.legend.on('select', function(){
177
- this$.bind();
178
- this$.resize();
179
- return this$.render();
180
- });
181
- },
182
- destroy: function(){
183
- return this.tip.destroy();
184
- },
185
- parse: function(){
186
- var this$ = this;
187
- this.valid = this.data.filter(function(it){
188
- return !isNaN(it.left + it.right);
189
- });
190
- this.legendData = ['left', 'right'].map(function(it){
191
- var v;
192
- v = this$.binding[it] ? this$.binding[it].name || this$.binding[it].key : it;
193
- return {
194
- key: v,
195
- text: v
196
- };
197
- });
198
- return this.legend.data(this.legendData);
199
- },
200
- resize: function(){
201
- var ref$, vbox, rng, this$ = this;
202
- this.sim = null;
203
- this.start();
204
- (ref$ = this.cfg).tip || (ref$.tip = {});
205
- (ref$ = this.cfg).color || (ref$.color = {});
206
- (ref$ = this.cfg).legend || (ref$.legend = {});
207
- this.tip.toggle(((ref$ = this.cfg).tip || (ref$.tip = {})).enabled != null ? this.cfg.tip.enabled : true);
208
- if (this.cfg.color.left === this.cfg.color.right) {
209
- this.cfg.colorRight = '#09f';
210
- }
211
- this.tint.set({
212
- colors: [this.cfg.color.left || this.cfg.palette.colors[0] || '#09f', this.cfg.color.right || this.cfg.palette.colors[1] || '#f90'],
213
- maps: this.legendData.map(function(it){
214
- return it.key;
215
- })
216
- }, true);
217
- this.legend.config((ref$ = this.cfg.legend, ref$.selectable = false, ref$));
218
- this.legend.update();
219
- this.layout.update(false);
220
- this.vbox = vbox = this.layout.getBox('view');
221
- rng = d3.randomUniform.source(d3.randomLcg(this.seed))(0, 1);
222
- this.valid.map(function(obj){
223
- var ref$, L, R, r, sum, rate, x, y;
224
- ref$ = [(ref$ = obj.left) > 0 ? ref$ : 0, (ref$ = obj.right) > 0 ? ref$ : 0], L = ref$[0], R = ref$[1];
225
- r = sum = L + R;
226
- rate = !sum
227
- ? 0.5
228
- : R / sum;
229
- ref$ = [rate * vbox.width, rng() * vbox.height], x = ref$[0], y = ref$[1];
230
- obj.r = r;
231
- obj.sum = sum;
232
- obj.rate = rate;
233
- obj.L = L;
234
- obj.R = R;
235
- obj.cx = x;
236
- if (!(obj.x != null)) {
237
- obj.x = x;
238
- obj.y = y;
239
- }
240
- if (!(obj._x != null)) {
241
- obj._x = x;
242
- obj._y = y;
243
- }
244
- return obj;
245
- });
246
- this.rate = 0.9 * Math.PI / (2 * Math.sqrt(3)) * Math.sqrt(vbox.width * vbox.height / this.valid.map(function(it){
247
- return Math.PI * Math.pow(it.r, 2);
248
- }).reduce(function(a, b){
249
- return a + b;
250
- }, 0));
251
- return this.valid.map(function(d, i){
252
- var ref$;
253
- return d.rr = (ref$ = d.r * this$.rate) > 2 ? ref$ : 2;
254
- });
255
- },
256
- render: function(){
257
- var binding, tint, rate, legendData, x$, y$;
258
- binding = this.binding, tint = this.tint, rate = this.rate, legendData = this.legendData;
259
- x$ = this.g.view.selectAll('g.pie').data(this.valid);
260
- x$.exit().remove();
261
- x$.enter().append('g').attr('class', "pie data").each(function(){
262
- d3.select(this).append('path');
263
- return d3.select(this).append('path');
264
- });
265
- this.g.view.selectAll('g.pie').each(function(d, i){
266
- d3.select(this).attr('transform', "translate(" + d.x + " " + d.y + ")");
267
- return d3.select(this).selectAll('path').attr('fill', function(e, j){
268
- return tint.get(legendData[j].key);
269
- }).attr('d', function(e, j){
270
- var r, rx, ry1, ry2, f;
271
- r = d.rr;
272
- rx = r * Math.cos(d.rate * Math.PI);
273
- ry1 = -r * Math.sin(d.rate * Math.PI);
274
- ry2 = r * Math.sin(d.rate * Math.PI);
275
- f = d.rate > 0.5
276
- ? j
277
- : 1 - j;
278
- return ["M", rx, ry1, "A", r, r, 0, f, j, rx, ry2, "L", 0, 0, "Z"].join(" ");
279
- });
280
- });
281
- y$ = this.g.view.selectAll('g.label').data(this.valid);
282
- y$.exit().remove();
283
- y$.enter().append('g').attr('class', 'label').each(function(d, i){
284
- var this$ = this;
285
- return [0].map(function(){
286
- return d3.select(this$).append('text');
287
- }).map(function(it){
288
- return it.attr('text-anchor', 'middle').attr('dominant-baseline', 'middle').attr('font-size', '.7em').style('pointer-event', 'none');
289
- });
290
- });
291
- this.g.view.selectAll('g.label').attr('transform', function(d, i){
292
- return "translate(" + d.x + "," + d.y + ")";
293
- }).each(function(d, i){
294
- return d3.select(this).selectAll('text').attr('opacity', d.rr * 2 < (d.sum.toFixed(2) + "").length * 7 ? 0 : 1).text(function(e, i){
295
- var ret;
296
- ret = d3.format('.3s')(d.sum);
297
- if (ret) {
298
- ret = ret + "" + (binding.left.unit || binding.right.unir || '');
299
- }
300
- return ret;
301
- });
302
- });
303
- return this.legend.render();
304
- },
305
- tick: function(){
306
- var pad, kickoff, fc, this$ = this;
307
- pad = this.cfg.pad || 5;
308
- if (!this.sim) {
309
- kickoff = true;
310
- this.fc = fc = d3.forceCollide().strength(0.6).iterations(20).radius(function(it){
311
- return it.rr;
312
- });
313
- this.fb = forceBoundary(function(it){
314
- return it.rr + pad;
315
- }, function(it){
316
- return it.rr + pad;
317
- }, function(it){
318
- return this$.vbox.width - it.rr - pad;
319
- }, function(it){
320
- return this$.vbox.height - it.rr - pad;
321
- }).strength(0.8);
322
- this.fy = d3.forceY().strength(0.2);
323
- this.fx = d3.forceX().strength(0.2).x(function(it){
324
- return it.cx;
325
- });
326
- this.sim = d3.forceSimulation().force('b', this.fb).force('collide', fc).force('fx', this.fx).force('fy', this.fy);
327
- this.sim.stop();
328
- this.sim.alpha(0.9);
329
- }
330
- this.fy.y(this.vbox.height / 2);
331
- this.sim.nodes(this.valid);
332
- this.sim.tick(kickoff ? 10 : 1);
333
- if (this.sim.alpha() < 0.01) {
334
- this.stop();
335
- }
336
- this.valid.map(function(it){
337
- it._x = it._x + (it.x - it._x) * 0.1;
338
- return it._y = it._y + (it.y - it._y) * 0.1;
339
- });
340
- this.g.view.selectAll('g.label').attr('transform', function(d, i){
341
- return "translate(" + d._x + "," + d._y + ")";
342
- });
343
- return this.g.view.selectAll('g.pie').attr('transform', function(d, i){
344
- return "translate(" + d._x + "," + d._y + ")";
345
- });
346
- }
347
- };
348
- };
349
- function import$(obj, src){
350
- var own = {}.hasOwnProperty;
351
- for (var key in src) if (own.call(src, key)) obj[key] = src[key];
352
- return obj;
353
- }</script></div>
@@ -1,144 +0,0 @@
1
- <div><script type="@plotdb/block">var mod;
2
- module.exports = {
3
- pkg: {
4
- name: 'radar',
5
- version: '0.0.1',
6
- extend: {
7
- name: "base",
8
- version: "0.0.1"
9
- },
10
- dependencies: []
11
- },
12
- init: function(arg$){
13
- var root, context, pubsub;
14
- root = arg$.root, context = arg$.context, pubsub = arg$.pubsub;
15
- return pubsub.fire('init', {
16
- mod: mod({
17
- context: context
18
- })
19
- }).then(function(it){
20
- return it[0];
21
- });
22
- }
23
- };
24
- mod = function(arg$){
25
- var context, d3, forceBoundary, ldColor, repeatString$;
26
- context = arg$.context;
27
- d3 = context.d3, forceBoundary = context.forceBoundary, ldColor = context.ldColor, repeatString$ = context.repeatString$;
28
- return {
29
- sample: function(){
30
- return {
31
- raw: [0, 1, 2, 3, 4].map(function(idx){
32
- return {
33
- val: [0, 1, 2].map(function(){
34
- return 0.5 + 0.5 * Math.random();
35
- }),
36
- cat: idx
37
- };
38
- }),
39
- binding: {
40
- radius: {
41
- key: 'val'
42
- },
43
- order: {
44
- key: 'cat'
45
- }
46
- }
47
- };
48
- },
49
- config: {},
50
- dimension: {
51
- radius: {
52
- type: 'R',
53
- name: "radius of point on radar line"
54
- },
55
- order: {
56
- type: 'R',
57
- name: "order of data point"
58
- }
59
- },
60
- init: function(){
61
- var svg, gs, this$ = this;
62
- svg = d3.select(this.svg);
63
- this.gs = gs = {};
64
- gs.all = svg.append('g');
65
- return this.line = d3.line().x(function(d, i){
66
- return this$.scale.r(d) * Math.cos(this$.scale.a(this$.orders[i]));
67
- }).y(function(d, i){
68
- return this$.scale.r(d) * -Math.sin(this$.scale.a(this$.orders[i]));
69
- });
70
- },
71
- parse: function(){
72
- this.orders = Array.from(new Set(this.data.map(function(it){
73
- return it.order;
74
- })));
75
- this.parsed = d3.transpose(this.data.map(function(it){
76
- return it.radius;
77
- }));
78
- this.parsed.map(function(d, i){
79
- return d.idx = i;
80
- });
81
- this.names = ['1', '2', '3'];
82
- this.radiusRange = d3.extent(this.parsed.map(function(d){
83
- return d3.extent(d);
84
- }).reduce(function(a, b){
85
- return a.concat(b);
86
- }, []));
87
- if (this.radiusRange[0] === this.radiusRange[1]) {
88
- return this.radiusRange[1]++;
89
- }
90
- },
91
- bind: function(){
92
- var x$, y$;
93
- x$ = this.gs.all.selectAll('path.data').data(this.parsed);
94
- x$.exit().attr('class', "").transition('exit').duration(500).attr('opacity', 0).remove();
95
- x$.enter().append('path').attr('class', 'data').attr('opacity', 0);
96
- y$ = this.gs.all.selectAll('g.data-group').data(this.parsed);
97
- y$.exit().attr('class', "").transition('exit').duration(500).attr('opacity', 0).remove();
98
- y$.enter().append('g').attr('class', 'data-group').attr('opacity', 0);
99
- return this.gs.all.selectAll('g.data-group').each(function(d, i){
100
- var x$;
101
- x$ = d3.select(this).selectAll('circle.node').data(d);
102
- x$.exit().attr('class', '').transition('exit').duration(500).attr('opacity', 0).remove();
103
- x$.enter().append('circle').attr('class', 'node').attr('opacity', 0);
104
- return x$;
105
- });
106
- },
107
- resize: function(){
108
- var size, ref$;
109
- size = (ref$ = Math.min(this.box.width, this.box.height) / 2) > 10 ? ref$ : 10;
110
- this.scale = {
111
- r: d3.scaleLinear().domain([0, this.radiusRange[1]]).range([0, size]),
112
- a: d3.scalePoint().domain(this.orders).range([0, 2 * Math.PI]),
113
- c: d3.interpolateTurbo
114
- };
115
- if (this.cfg != null && this.cfg.palette) {
116
- this.scale.c = d3.interpolateDiscrete(this.cfg.palette.colors.map(function(it){
117
- return ldColor.web(it.value || it);
118
- }));
119
- }
120
- return this.aTicks = d3.range(this.data.length);
121
- },
122
- render: function(){
123
- var scale, names, line, orders;
124
- scale = this.scale, names = this.names, line = this.line, orders = this.orders, orders = this.orders;
125
- this.gs.all.attr('transform', "translate(" + this.box.width / 2 + "," + this.box.height / 2 + ")");
126
- this.gs.all.selectAll('path.data').each(function(d, i){
127
- var color;
128
- color = scale.c(i / (names.length - 1));
129
- 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){
130
- return line(d, i) + "Z";
131
- });
132
- }).transition('opacity').duration(350).attr('opacity', 1);
133
- return this.gs.all.selectAll('g.data-group').each(function(d, i){
134
- var color;
135
- color = scale.c(i / (names.length - 1));
136
- 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){
137
- return scale.r(d) * Math.cos(scale.a(orders[i]));
138
- }).attr('cy', function(d, i){
139
- return scale.r(d) * -Math.sin(scale.a(orders[i]));
140
- }).attr('r', 3).attr('opacity', 1);
141
- }).transition('opacity').duration(350).attr('opacity', 1);
142
- }
143
- };
144
- };</script></div>