@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,581 +0,0 @@
1
- <div><div plug="layout"><div class="pdl-layout"><div data-type="layout"><div class="pdl-cell" data-name="yaxis">&nbsp;</div><div class="pdl-cell" data-name="view"></div><div class="pdl-cell"></div><div class="pdl-cell" data-name="xaxis">&nbsp;</div><div class="pdl-cell" data-name="legend">&nbsp;</div></div><div data-type="render"></div></div></div><style type="text/css">[data-name=xaxis] {
2
- font-size: 0.8em;
3
- }
4
- [data-name=yaxis] {
5
- font-size: 0.8em;
6
- }
7
- .pdl-layout > div[data-type=layout] {
8
- display: grid;
9
- grid-template-columns: fit-content(2em) 1fr fit-content(10em);
10
- grid-template-rows: 1fr fit-content(1em);
11
- /* 0.5em for axis label at the boundary */
12
- padding: 0 0.5em;
13
- }
14
- .pdl-layout > div[data-type=layout] > .pdl-cell[data-name=legend] {
15
- grid-column: 3;
16
- grid-row: 1/span 2;
17
- padding-left: 1em;
18
- }
19
- .pdl-layout.legend-below > div[data-type=layout] {
20
- grid-template-columns: 2em 1fr;
21
- grid-template-rows: 1fr fit-content(2em) fit-content(3em);
22
- }
23
- .pdl-layout.legend-below > div[data-type=layout] .pdl-cell[data-name=legend] {
24
- padding-top: 1em;
25
- grid-column: 1/span 2;
26
- grid-row: 3;
27
- }
28
- </style><script type="@plotdb/block">(function(it){
29
- return it();
30
- })(function(){
31
- var blockFactory, mod;
32
- blockFactory = {
33
- pkg: {
34
- name: 'bar',
35
- version: '0.0.1',
36
- extend: {
37
- name: "base",
38
- version: "0.0.1"
39
- },
40
- dependencies: [],
41
- i18n: {
42
- "zh-TW": {
43
- "size": "長度"
44
- }
45
- }
46
- },
47
- init: function(arg$){
48
- var root, context, t, pubsub;
49
- root = arg$.root, context = arg$.context, t = arg$.t, pubsub = arg$.pubsub;
50
- return pubsub.fire('init', {
51
- mod: mod({
52
- context: context,
53
- t: t
54
- })
55
- });
56
- }
57
- };
58
- mod = function(arg$){
59
- var context, t, chart, d3, debounce, ref$;
60
- context = arg$.context, t = arg$.t;
61
- chart = context.chart, d3 = context.d3, debounce = context.debounce;
62
- return {
63
- sample: function(){
64
- return {
65
- raw: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(function(val){
66
- var ret, i$, i;
67
- ret = {
68
- name: val
69
- };
70
- for (i$ = 1; i$ <= 4; ++i$) {
71
- i = i$;
72
- ret["val" + i] = Math.random();
73
- }
74
- return ret;
75
- }),
76
- binding: {
77
- size: [1, 2, 3, 4].map(function(it){
78
- return {
79
- key: "val" + it,
80
- unit: "amount"
81
- };
82
- }),
83
- name: {
84
- key: "name"
85
- }
86
- }
87
- };
88
- },
89
- config: (ref$ = import$({}, chart.utils.config.preset['default']), ref$.sort = {
90
- enabled: {
91
- type: 'boolean'
92
- },
93
- dir: {
94
- type: 'choice',
95
- values: ['asc', 'desc', 'none']
96
- }
97
- }, ref$.type = {
98
- type: 'choice',
99
- values: ['bar', 'column'],
100
- 'default': 'column'
101
- }, ref$),
102
- dimension: {
103
- size: {
104
- type: 'R',
105
- multiple: true,
106
- name: "size"
107
- },
108
- name: {
109
- type: 'NO',
110
- name: "name"
111
- }
112
- },
113
- init: function(){
114
- var tint, brush, scale, this$ = this;
115
- this.tint = tint = new chart.utils.tint();
116
- [['multiple', 'stack'], ['percent', false], ['dancing', true]].map(function(arg$){
117
- var k, v;
118
- k = arg$[0], v = arg$[1];
119
- if (!(this$.cfg[k] != null)) {
120
- return this$.cfg[k] = v;
121
- }
122
- });
123
- this.svg.addEventListener('click', function(){
124
- if (!this$.cfg.dancing || this$.cfg.percent) {
125
- return;
126
- }
127
- this$.alignIdx = ((this$.alignIdx || 0) + 1) % (this$.binding.size.length + 1);
128
- this$.resize();
129
- return this$.render();
130
- });
131
- this.brush = d3.brushX();
132
- this.g = Object.fromEntries(['view', 'xaxis', 'yaxis', 'legend'].map(function(it){
133
- return [it, d3.select(this$.layout.getGroup(it))];
134
- }));
135
- this.range = "null";
136
- brush = debounce(150, function(e){
137
- var ref$, range, _range, domain, bandwidth;
138
- if (((ref$ = this$.cfg).brush || (ref$.brush = {})).enabled != null && !this$.cfg.brush.enabled) {
139
- return;
140
- }
141
- range = e.selection;
142
- if ((_range = JSON.stringify(range)) === this$.range) {
143
- return;
144
- } else {
145
- this$.range = _range;
146
- }
147
- if (!range) {
148
- return this$.filter({
149
- name: undefined
150
- }, true);
151
- } else {
152
- domain = this$.scale.x.domain();
153
- bandwidth = this$.scale.x.bandwidth();
154
- range = range.map(function(it){
155
- var ref$, ref1$, ref2$;
156
- return (ref$ = (ref2$ = Math.floor(it / bandwidth)) > 0 ? ref2$ : 0) < (ref1$ = domain.length - 1) ? ref$ : ref1$;
157
- });
158
- range = (function(){
159
- var i$, to$, results$ = [];
160
- for (i$ = range[0], to$ = range[1]; i$ <= to$; ++i$) {
161
- results$.push(i$);
162
- }
163
- return results$;
164
- }()).map(function(it){
165
- return domain[it];
166
- });
167
- return this$.filter({
168
- name: {
169
- type: 'index',
170
- value: range
171
- }
172
- }, true);
173
- }
174
- });
175
- this.brush.on('end', brush);
176
- this.brush.on('brush', brush);
177
- this.scale = scale = {};
178
- this.yaxis = new chart.utils.axis({
179
- layout: this.layout,
180
- name: 'yaxis',
181
- direction: 'left'
182
- });
183
- this.xaxis = new chart.utils.axis({
184
- layout: this.layout,
185
- name: 'xaxis',
186
- direction: 'bottom'
187
- });
188
- return this.legend = new chart.utils.legend({
189
- layout: this.layout,
190
- name: 'legend',
191
- root: this.root,
192
- shape: function(d){
193
- return d3.select(this).attr('fill', tint.get(d.key));
194
- }
195
- });
196
- },
197
- destroy: function(){
198
- if (this.tip) {
199
- return this.tip.destroy();
200
- }
201
- },
202
- filter: function(filters, internal){
203
- var this$ = this;
204
- internal == null && (internal = false);
205
- this.render();
206
- if (internal) {
207
- return;
208
- }
209
- return this.brush.move(this.g.view, filters.name ? filters.name.map(function(it){
210
- return this$.scale.x(it);
211
- }) : null);
212
- },
213
- parse: function(){
214
- this.data.map(function(d){
215
- return d.size = d.size.map(function(it){
216
- if (isNaN(it)) {
217
- return 0;
218
- } else {
219
- return it;
220
- }
221
- });
222
- });
223
- return this.alignIdx = undefined;
224
- },
225
- resize: function(){
226
- var alignIdx, ref$, ref1$, delta, max, i, box, maxTick, yticks, v, xticks, i$, w, h, r, this$ = this;
227
- this.type = this.cfg.type || 'column';
228
- this.legend.config(this.cfg.legend);
229
- this.legend.update();
230
- this.layout.update(false);
231
- this.maxPerGroup = this.binding.size.map(function(d, i){
232
- return Math.max.apply(Math, this$.data.map(function(it){
233
- return it.size[i];
234
- }));
235
- });
236
- if (this.cfg.alignIdx && !this.alignIdx) {
237
- this.alignIdx = this.cfg.alignIdx;
238
- }
239
- alignIdx = (ref$ = this.cfg.percent
240
- ? 0
241
- : this.alignIdx || 0) < (ref1$ = this.binding.size.length) ? ref$ : ref1$;
242
- this.baseOffset = this.data.map(function(d){
243
- return (function(){
244
- var i$, to$, results$ = [];
245
- for (i$ = 0, to$ = alignIdx; i$ < to$; ++i$) {
246
- results$.push(i$);
247
- }
248
- return results$;
249
- }()).reduce(function(a, b){
250
- return a + d.size[b];
251
- }, 0) || 0;
252
- });
253
- this.delta = delta = Math.max.apply(Math, this.baseOffset);
254
- if (this.cfg.multiple === 'stack') {
255
- if (this.cfg.percent) {
256
- max = 1;
257
- } else {
258
- max = Math.max.apply(Math, this.data.map(function(d){
259
- return (function(){
260
- var i$, to$, results$ = [];
261
- for (i$ = alignIdx, to$ = d.size.length; i$ < to$; ++i$) {
262
- results$.push(i$);
263
- }
264
- return results$;
265
- }()).reduce(function(a, b){
266
- return a + d.size[b];
267
- }, 0);
268
- })) + (delta || 0);
269
- }
270
- } else if (this.cfg.multiple === 'group') {
271
- max = Math.max.apply(Math, this.data.map(function(d){
272
- return Math.max.apply(Math, d.size);
273
- }));
274
- } else if (this.cfg.multiple === 'split') {
275
- max = this.maxPerGroup.reduce(function(a, b){
276
- return a + b;
277
- }, 0);
278
- }
279
- this.order = this.data.map(function(d, i){
280
- return {
281
- key: d._idx,
282
- idx: i,
283
- name: d.name
284
- };
285
- });
286
- this.data.map(function(d, i){
287
- return d.sum = d.size.reduce(function(a, b){
288
- return a + b;
289
- }, 0);
290
- });
291
- if (((ref$ = this.cfg).sort || (ref$.sort = {})).enabled) {
292
- this.order.sort(function(a, b){
293
- return (this$.cfg.sort.dir === 'asc'
294
- ? 1
295
- : -1) * (this$.data[a.idx].sum - this$.data[b.idx].sum);
296
- });
297
- }
298
- console.log(this.cfg);
299
- if (this.cfg.palette) {
300
- this.tint.set(this.cfg.palette.colors.map(function(it){
301
- return it.value || it;
302
- }));
303
- }
304
- this.legend.data((function(){
305
- var i$, results$ = [];
306
- for (i$ = this.binding.size.length - 1; i$ >= 0; --i$) {
307
- i = i$;
308
- results$.push({
309
- key: i,
310
- text: this.binding.size[i].name || this.binding.size[i].key
311
- });
312
- }
313
- return results$;
314
- }.call(this)));
315
- this.layout.update(false);
316
- box = this.layout.getBox('view');
317
- if (this.type === 'column') {
318
- ref$ = this.scale;
319
- ref$.y = d3.scaleLinear().domain([0, max]).range([box.height, 0]);
320
- ref$.x = d3.scaleBand().domain(this.order.map(function(it){
321
- return it.name || it.key;
322
- })).range([0, box.width]);
323
- maxTick = (ref$ = Math.ceil(this.layout.getBox('yaxis').height / 40)) > 2 ? ref$ : 2;
324
- yticks = this.cfg.bump
325
- ? (function(){
326
- var i$, to$, ref$, results$ = [];
327
- for (i$ = 1, to$ = (ref$ = this.parsed.length || 1) > 1 ? ref$ : 1; i$ <= to$; ++i$) {
328
- results$.push(i$);
329
- }
330
- return results$;
331
- }.call(this))
332
- : this.scale.y.ticks((ref$ = ((ref1$ = this.cfg).yaxis || (ref1$.yaxis = {})).tickCount || 4) < maxTick ? ref$ : maxTick);
333
- this.yaxis.config(this.cfg.yaxis);
334
- v = this.binding.size[0] || {};
335
- if (this.binding.size.length > 1) {
336
- this.yaxis.caption(v.unit ? v.unit + "" : '');
337
- } else {
338
- this.yaxis.caption((v.name || v.key || '') + (v.unit ? "(" + v.unit + ")" : ''));
339
- }
340
- this.yaxis.ticks(yticks);
341
- this.yaxis.scale(this.scale.y);
342
- this.xaxis.config((ref$ = this.cfg).xaxis || (ref$.xaxis = {}));
343
- this.xaxis.ticks(this.data.map(function(it){
344
- return it.name;
345
- }));
346
- this.xaxis.scale(this.scale.x);
347
- this.xaxis.caption((this.binding.name.name || this.binding.name.key) + (this.binding.name.unit ? "(" + this.binding.name.unit + ")" : ''));
348
- } else {
349
- ref$ = this.scale;
350
- ref$.x = d3.scaleLinear().domain([0, max]).range([box.width, 0]);
351
- ref$.y = d3.scaleBand().domain(this.order.map(function(it){
352
- return it.name || it.key;
353
- })).range([0, box.height]);
354
- maxTick = (ref$ = Math.ceil(this.layout.getBox('xaxis').width / 80)) > 2 ? ref$ : 2;
355
- xticks = this.cfg.bump
356
- ? (function(){
357
- var i$, to$, ref$, results$ = [];
358
- for (i$ = 1, to$ = (ref$ = this.parsed.length || 1) > 1 ? ref$ : 1; i$ <= to$; ++i$) {
359
- results$.push(i$);
360
- }
361
- return results$;
362
- }.call(this))
363
- : this.scale.x.ticks((ref$ = ((ref1$ = this.cfg).xaxis || (ref1$.xaxis = {})).tickCount || 4) < maxTick ? ref$ : maxTick);
364
- this.xaxis.config(this.cfg.xaxis);
365
- v = this.binding.size[0] || {};
366
- if (this.binding.size.length > 1) {
367
- this.xaxis.caption(v.unit ? v.unit + "" : '');
368
- } else {
369
- this.xaxis.caption((v.name || v.key || '') + (v.unit ? "(" + v.unit + ")" : ''));
370
- }
371
- this.xaxis.ticks(xticks);
372
- this.xaxis.scale(this.scale.x);
373
- this.yaxis.config((ref$ = this.cfg).yaxis || (ref$.yaxis = {}));
374
- this.yaxis.ticks(this.data.map(function(it){
375
- return it.name;
376
- }));
377
- this.yaxis.scale(this.scale.y);
378
- this.yaxis.caption((this.binding.name.name || this.binding.name.key) + (this.binding.name.unit ? "(" + this.binding.name.unit + ")" : ''));
379
- }
380
- for (i$ = 0; i$ < 2; ++i$) {
381
- i = i$;
382
- this.layout.update(false);
383
- box = this.layout.getBox('view');
384
- ref$ = [box.width, box.height], w = ref$[0], h = ref$[1];
385
- this.tint.set(this.cfg.palette);
386
- r = this.cfg.dotSize || 3;
387
- this.scale.x.range([0, w - r]);
388
- this.scale.y.range([h, r]);
389
- this.xaxis.render();
390
- this.yaxis.render();
391
- }
392
- box = this.layout.getBox('view');
393
- return this.brush.extent([[0, 1], [box.width, box.height - 1]]);
394
- },
395
- render: function(){
396
- var binding, scale, range, delta, baseOffset, maxPerGroup, cfg, tint, data, type, x$, ref$, this$ = this;
397
- binding = this.binding, scale = this.scale, range = this.range, delta = this.delta, baseOffset = this.baseOffset, maxPerGroup = this.maxPerGroup, cfg = this.cfg, tint = this.tint, data = this.data, type = this.type;
398
- x$ = this.g.view.selectAll('g.bar').data(this.data);
399
- x$.exit().remove();
400
- x$.enter().append('g').attr('class', 'bar');
401
- this.g.view.selectAll('g.bar').attr('transform', function(d, i){
402
- if (this$.type === 'column') {
403
- return "translate(" + scale.x(d.name) + ",0)";
404
- } else {
405
- return "translate(0," + scale.y(d.name) + ")";
406
- }
407
- }).each(function(item, j){
408
- var ref$, bars, offset, sum, i$, to$, idx, size, key, x$, y$, tran;
409
- ref$ = [[], 0], bars = ref$[0], offset = ref$[1];
410
- offset = delta - baseOffset[j];
411
- sum = 1;
412
- if (cfg.percent === true) {
413
- sum = (ref$ = item.size.reduce(function(a, b){
414
- return a + b;
415
- }, 0)) > 1 ? ref$ : 1;
416
- }
417
- for (i$ = 0, to$ = item.size.length; i$ < to$; ++i$) {
418
- idx = i$;
419
- size = item.size[idx];
420
- key = idx;
421
- bars.push({
422
- size: size / sum,
423
- offset: offset / sum,
424
- key: key,
425
- group: item.name,
426
- name: binding.size[key].name || binding.size[key].key,
427
- unit: binding.size[key].unit || ''
428
- });
429
- if (cfg.multiple === 'split') {
430
- offset += maxPerGroup[idx];
431
- } else if (cfg.multiple === 'stack') {
432
- offset += size;
433
- }
434
- }
435
- x$ = d3.select(this).selectAll('rect').data(bars, function(d, i){
436
- return d.key;
437
- });
438
- x$.exit().remove();
439
- y$ = x$.enter().append('rect');
440
- if (type === 'column') {
441
- y$.attr('width', function(d, i){
442
- var ref$;
443
- return (ref$ = scale.x.bandwidth() - 2) > 1 ? ref$ : 1;
444
- });
445
- }
446
- if (type === 'column') {
447
- y$.attr('y', function(d, i){
448
- return scale.y(0);
449
- });
450
- }
451
- if (type !== 'column') {
452
- y$.attr('height', function(d, i){
453
- var ref$;
454
- return (ref$ = scale.y.bandwidth() - 2) > 1 ? ref$ : 1;
455
- });
456
- }
457
- if (type !== 'column') {
458
- y$.attr('x', function(d, i){
459
- return scale.x(0);
460
- });
461
- }
462
- tran = d3.select(this).selectAll('rect').transition().duration(350).call(function(sel){
463
- var x$;
464
- if (cfg.multiple !== 'group') {
465
- return;
466
- }
467
- x$ = sel;
468
- if (type === 'column') {
469
- x$.attr('x', function(d, i){
470
- return 1 + i * (scale.x.bandwidth() - 2) / bars.length;
471
- });
472
- }
473
- if (type === 'column') {
474
- x$.attr('width', function(d, i){
475
- return (scale.x.bandwidth() - 2) / bars.length;
476
- });
477
- }
478
- if (type === 'column') {
479
- x$.attr('y', function(d, i){
480
- return Math.round(Math.min(scale.y(0), scale.y(d.size)));
481
- });
482
- }
483
- if (type !== 'column') {
484
- x$.attr('y', function(d, i){
485
- return 1 + i * (scale.y.bandwidth() - 2) / bars.length;
486
- });
487
- }
488
- if (type !== 'column') {
489
- x$.attr('height', function(d, i){
490
- return (scale.y.bandwidth() - 2) / bars.length;
491
- });
492
- }
493
- if (type !== 'column') {
494
- x$.attr('x', function(d, i){
495
- return Math.round(Math.min(scale.x(0), scale.x(d.size)));
496
- });
497
- }
498
- return x$;
499
- }).call(function(sel){
500
- var x$;
501
- if (cfg.multiple !== 'stack') {
502
- return;
503
- }
504
- x$ = sel;
505
- if (type === 'column') {
506
- x$.attr('x', 1);
507
- }
508
- if (type === 'column') {
509
- x$.attr('width', function(d, i){
510
- return scale.x.bandwidth() - 2;
511
- });
512
- }
513
- if (type === 'column') {
514
- x$.attr('y', function(d, i){
515
- return Math.round(Math.min(scale.y(d.offset), scale.y(d.offset + d.size)));
516
- });
517
- }
518
- if (type !== 'column') {
519
- x$.attr('y', 1);
520
- }
521
- if (type !== 'column') {
522
- x$.attr('height', function(d, i){
523
- return scale.y.bandwidth() - 2;
524
- });
525
- }
526
- if (type !== 'column') {
527
- x$.attr('x', function(d, i){
528
- return Math.round(Math.min(scale.x(d.offset), scale.x(d.offset + d.size)));
529
- });
530
- }
531
- return x$;
532
- });
533
- if (type === 'column') {
534
- tran.attr('height', function(d, i){
535
- return Math.round(Math.abs(scale.y(0) - scale.y(d.size)));
536
- });
537
- } else {
538
- tran.attr('width', function(d, i){
539
- return Math.round(Math.abs(scale.x(0) - scale.x(d.size)));
540
- });
541
- }
542
- return tran.attr('fill', function(d, i){
543
- return tint.get(i, cfg.colorVariant ? j / data.length - 0.5 : 0);
544
- }).attr('fill-opacity', function(d, i){
545
- var filter, range;
546
- if (!(binding.name && (filter = binding.name.filter))) {
547
- return 1;
548
- }
549
- if (!(range = filter.value)) {
550
- return 1;
551
- }
552
- if (in$(item.name, range)) {
553
- return 1;
554
- } else {
555
- return 0.2;
556
- }
557
- });
558
- });
559
- if (!(((ref$ = this.cfg).brush || (ref$.brush = {})).enabled != null && !this.cfg.brush.enabled)) {
560
- this.g.view.call(this.brush);
561
- }
562
- this.g.view.selectAll('rect.selection').attr('shape-rendering', 'auto');
563
- this.legend.render();
564
- this.yaxis.render();
565
- return this.xaxis.render();
566
- },
567
- tick: function(){}
568
- };
569
- };
570
- return blockFactory;
571
- });
572
- function import$(obj, src){
573
- var own = {}.hasOwnProperty;
574
- for (var key in src) if (own.call(src, key)) obj[key] = src[key];
575
- return obj;
576
- }
577
- function in$(x, xs){
578
- var i = -1, l = xs.length >>> 0;
579
- while (++i < l) if (x === xs[i]) return true;
580
- return false;
581
- }</script></div>