@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,152 +0,0 @@
1
- <div><div plug="layout"><div class="pdl-layout"><div data-type="layout"><div class="pdl-cell" data-name="number"></div><div class="pdl-cell" data-name="unit"></div></div><div data-type="render"></div></div></div><style type="text/css">.pdl-layout > [data-type=layout] {
2
- flex-direction: column;
3
- display: flex;
4
- align-items: center;
5
- justify-content: center;
6
- }
7
- .pdl-layout > [data-type=layout] .pdl-cell {
8
- line-height: 1em;
9
- white-space: nowrap;
10
- }
11
- .pdl-layout > [data-type=layout] .pdl-cell[data-name=number] {
12
- font-weight: bold;
13
- }
14
- </style><script type="@plotdb/block">(function(it){
15
- return it();
16
- })(function(){
17
- var blockFactory, mod;
18
- blockFactory = {
19
- pkg: {
20
- name: 'number',
21
- version: '0.0.1',
22
- extend: {
23
- name: "base",
24
- version: "0.0.1"
25
- },
26
- dependencies: []
27
- },
28
- init: function(arg$){
29
- var root, context, pubsub;
30
- root = arg$.root, context = arg$.context, pubsub = arg$.pubsub;
31
- return pubsub.fire('init', {
32
- mod: mod({
33
- context: context
34
- })
35
- }).then(function(it){
36
- return it[0];
37
- });
38
- }
39
- };
40
- mod = function(arg$){
41
- var context, d3, ldcolor, repeatString$, infinite;
42
- context = arg$.context;
43
- d3 = context.d3, ldcolor = context.ldcolor, repeatString$ = context.repeatString$, infinite = context.infinite;
44
- return {
45
- sample: function(){
46
- return {
47
- raw: [{
48
- val: 12777216,
49
- name: "票房",
50
- unit: "新臺幣"
51
- }],
52
- binding: {
53
- name: {
54
- key: 'name'
55
- },
56
- value: {
57
- key: 'val',
58
- unit: '百萬元新臺幣'
59
- }
60
- }
61
- };
62
- },
63
- config: {
64
- enlarge: {
65
- type: 'boolean',
66
- 'default': false
67
- }
68
- },
69
- dimension: {
70
- value: {
71
- type: 'R',
72
- name: "value"
73
- },
74
- name: {
75
- type: 'N',
76
- name: "name"
77
- }
78
- },
79
- init: function(){
80
- var this$ = this;
81
- this.n = Object.fromEntries(['number', 'unit'].map(function(it){
82
- return [it, this$.layout.getNode(it)];
83
- }));
84
- this.g = Object.fromEntries(['number', 'unit'].map(function(it){
85
- return [it, d3.select(this$.layout.getGroup(it))];
86
- }));
87
- this.g.number.append('text');
88
- this.g.unit.append('text');
89
- return this.v = {
90
- number: 0,
91
- unit: '',
92
- run: 0
93
- };
94
- },
95
- resize: function(){
96
- var ref$, w, h, x$, y$, r, this$ = this;
97
- ref$ = [this.box.width, this.box.height], w = ref$[0], h = ref$[1];
98
- this.sizeRate = {
99
- number: this.cfg.numberSizeRate || 3,
100
- unit: this.cfg.unitSizeRate || 1
101
- };
102
- import$(this.v, {
103
- number: (this.data[0] || {
104
- value: 0
105
- }).value,
106
- unit: this.binding.value.unit || (this.data[0] || {
107
- unit: ''
108
- }).unit || ''
109
- });
110
- x$ = this.n.number;
111
- x$.style.fontSize = this.sizeRate.number + "em";
112
- x$.textContent = this.v.number;
113
- y$ = this.n.unit;
114
- y$.style.fontSize = '1em';
115
- y$.textContent = this.v.unit;
116
- this.r = r = Object.fromEntries(['number', 'unit'].map(function(it){
117
- return [it, w / (this$.n[it].getBoundingClientRect().width || 1)];
118
- }));
119
- (!this.cfg.enlarge
120
- ? ['number', 'unit']
121
- : ['unit']).map(function(it){
122
- var ref$;
123
- return this$.r[it] = (ref$ = r[it]) < 1 ? ref$ : 1;
124
- });
125
- this.n.number.style.fontSize = this.sizeRate.number * r.number + "em";
126
- this.n.unit.style.fontSize = this.sizeRate.unit * r.unit + "em";
127
- return this.layout.update(false);
128
- },
129
- tick: function(){
130
- var this$ = this;
131
- return this.g.number.select('text').text(function(){
132
- this$.v.run = (this$.v.number - this$.v.run) * 0.1 + this$.v.run;
133
- if (this$.v.run === this$.v.number) {
134
- this$.stop();
135
- }
136
- return Math.round(this$.v.run);
137
- });
138
- },
139
- render: function(){
140
- this.g.number.select('text').attr('x', this.n.number.getBoundingClientRect().width / 2).attr('font-size', this.sizeRate.number * this.r.number + "em").attr('font-weight', 'bold').attr('dominant-baseline', 'hanging').attr('text-anchor', 'middle').text(this.v.run);
141
- this.g.unit.select('text').attr('font-size', this.sizeRate.unit * this.r.unit + "em").attr('dominant-baseline', 'hanging').text(this.v.unit);
142
- return this.start();
143
- }
144
- };
145
- };
146
- return blockFactory;
147
- });
148
- function import$(obj, src){
149
- var own = {}.hasOwnProperty;
150
- for (var key in src) if (own.call(src, key)) obj[key] = src[key];
151
- return obj;
152
- }</script></div>
@@ -1,316 +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="link"></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: flex;
3
- justify-content: center;
4
- align-items: center;
5
- padding: 0.5em;
6
- }
7
- .pdl-layout > div[data-type=layout] > [data-name=view] {
8
- height: 100%;
9
- min-width: 2.5em;
10
- margin-right: 0.5em;
11
- flex: 1 0 2.5em;
12
- }
13
- .pdl-layout > div[data-type=layout] > [data-name=link] {
14
- height: 100%;
15
- width: 2.5em;
16
- margin-right: 0.5em;
17
- flex: 0 0 auto;
18
- }
19
- .pdl-layout > div[data-type=layout] > [data-name=legend] {
20
- flex: 1 0 auto;
21
- width: fit-content;
22
- max-width: 60%;
23
- height: 100%;
24
- display: flex;
25
- flex-direction: column;
26
- justify-content: start;
27
- align-items: start;
28
- }
29
- </style><script type="@plotdb/block">(function(it){
30
- return it();
31
- })(function(){
32
- var blockFactory, mod;
33
- blockFactory = {
34
- pkg: {
35
- name: 'percent-list',
36
- version: '0.0.1',
37
- extend: {
38
- name: "base",
39
- version: "0.0.1"
40
- },
41
- dependencies: [],
42
- i18n: {
43
- "zh-TW": {
44
- "other": "其它"
45
- }
46
- }
47
- },
48
- init: function(arg$){
49
- var root, context, pubsub, t;
50
- root = arg$.root, context = arg$.context, pubsub = arg$.pubsub, t = arg$.t;
51
- return pubsub.fire('init', {
52
- mod: mod({
53
- context: context,
54
- t: t
55
- })
56
- });
57
- }
58
- };
59
- mod = function(arg$){
60
- var context, t, chart, d3, wrapSvgText, debounce;
61
- context = arg$.context, t = arg$.t;
62
- chart = context.chart, d3 = context.d3, wrapSvgText = context.wrapSvgText, debounce = context.debounce;
63
- return {
64
- sample: function(){
65
- return {
66
- raw: ["Bachchan Pandey", "The Good Maharaja", "Ramprasad Ki Tehrvi", "Madam Chief Minister", "Satya Sai Baba", "Lahore Confidential", "Sandeep Aur Pinky Faraar", "Silence... Can You Hear It?", "Hum Bhi Akele Tum Bhi Akele", "Radhe", "Shaadisthan", "Chandigarh Kare Aashiqui", "Gangubai Kathiawadi", "Attack", "The Battle of Bhima Koregaon", "Tadap", "Looop Lapeta"].map(function(val){
67
- return {
68
- val: Math.random(),
69
- name: val
70
- };
71
- }),
72
- binding: {
73
- name: {
74
- key: 'name'
75
- },
76
- value: {
77
- key: 'val'
78
- }
79
- }
80
- };
81
- },
82
- config: {},
83
- dimension: {
84
- value: {
85
- type: 'R',
86
- name: "value",
87
- priority: 20
88
- },
89
- name: {
90
- type: 'N',
91
- name: "name",
92
- priority: 10
93
- }
94
- },
95
- init: function(){
96
- var tint, this$ = this;
97
- this.g = {
98
- view: d3.select(this.layout.getGroup('view')),
99
- link: d3.select(this.layout.getGroup('link')),
100
- legend: d3.select(this.layout.getGroup('legend'))
101
- };
102
- this.tint = tint = new chart.utils.tint();
103
- this.scale = {
104
- y: d3.scaleLinear()
105
- };
106
- this.layout.getGroup('view').addEventListener('mousemove', function(evt){
107
- var n;
108
- if (!((n = evt.target) && n.nodeName.toLowerCase() === 'rect')) {
109
- return;
110
- }
111
- this$.idx = Array.from(n.parentNode.childNodes).indexOf(n);
112
- return this$.renderDebounced();
113
- });
114
- return this.renderDebounced = debounce(350, function(){
115
- return this$.render();
116
- });
117
- },
118
- parse: function(){
119
- var ref$, other, total, sum, i$, to$, idx, offset, i, ret, this$ = this;
120
- ((ref$ = this.cfg).collapse || (ref$.collapse = {})).enabled = false;
121
- this.parsed = this.data.map(function(it){
122
- return import$({}, it);
123
- });
124
- this.parsed.sort(function(a, b){
125
- return b.value - a.value;
126
- });
127
- if (this.cfg.collapse.enabled) {
128
- if (this.cfg.collapse.method === 'count') {
129
- other = this.parsed.splice(this.cfg.collapse.threshold || 7);
130
- if (other.length) {
131
- this.parsed.push({
132
- name: t("other"),
133
- value: other.reduce(function(a, b){
134
- return a + b.value;
135
- }, 0)
136
- });
137
- }
138
- } else {
139
- ref$ = [
140
- this.parsed.reduce(function(a, b){
141
- return a + b.value;
142
- }, 0), 0
143
- ], total = ref$[0], sum = ref$[1];
144
- for (i$ = 0, to$ = this.parsed.length; i$ < to$; ++i$) {
145
- idx = i$;
146
- sum += this.parsed[idx].value;
147
- if (sum / total > (this.cfg.collapse.threshold || 0.75)) {
148
- break;
149
- }
150
- }
151
- other = this.parsed.splice(idx + 1);
152
- if (other.length) {
153
- this.parsed.push({
154
- name: t("other"),
155
- value: other.reduce(function(a, b){
156
- return a + b.value;
157
- }, 0)
158
- });
159
- }
160
- }
161
- }
162
- this.tint.reset();
163
- this.parsed.map(function(it){
164
- return this$.tint.get(it.name || it._idx);
165
- });
166
- offset = 0;
167
- for (i$ = 0, to$ = this.parsed.length; i$ < to$; ++i$) {
168
- i = i$;
169
- ret = this.parsed[i];
170
- ret.offset = offset;
171
- offset += ret.value;
172
- }
173
- return this.total = offset || 1;
174
- },
175
- resize: function(){
176
- var node, box, ref$, w, h, size, this$ = this;
177
- this.layout.update(false);
178
- node = this.layout.getNode('legend');
179
- node.textContent = "";
180
- this.parsed.map(function(it){
181
- var div, p;
182
- div = document.createElement('div');
183
- p = (100 * (it.value / this$.total)).toFixed(1);
184
- div.textContent = it.text = it.name + " / " + p + "%";
185
- return node.appendChild(div);
186
- });
187
- this.nboxes = this.parsed.map(function(d, i){
188
- return this$.layout.getNode('legend').childNodes[i].getBoundingClientRect();
189
- });
190
- this.rbox = this.layout.getNode('legend').getBoundingClientRect();
191
- this.lbox = this.layout.getBox('link');
192
- box = this.layout.getBox('view');
193
- this.layout.update(false);
194
- box = this.layout.getBox('view');
195
- ref$ = [box.width, box.height], w = ref$[0], h = ref$[1];
196
- size = Math.min(w, h);
197
- return this.scale.y.range([0, box.height]).domain([0, this.total]);
198
- },
199
- render: function(){
200
- var total, cfg, layout, tint, scale, nboxes, rbox, lbox, box, offset, ref$, ref1$, ref2$, last, x$, y$, z$, z1$;
201
- total = this.total, cfg = this.cfg, layout = this.layout, tint = this.tint, scale = this.scale, nboxes = this.nboxes, rbox = this.rbox, lbox = this.lbox;
202
- if (this.cfg != null && this.cfg.palette) {
203
- this.tint.set(this.cfg.palette.colors.map(function(it){
204
- return it.value || it;
205
- }));
206
- }
207
- box = this.layout.getBox('view');
208
- offset = 0;
209
- if (this.idx != null && nboxes.length) {
210
- this.idx = (ref$ = (ref1$ = this.idx) < (ref2$ = this.nboxes.length - 1) ? ref1$ : ref2$) > 0 ? ref$ : 0;
211
- offset = nboxes[this.idx].y - rbox.y;
212
- last = nboxes[nboxes.length - 1].y + nboxes[nboxes.length - 1].height - rbox.y;
213
- if (last - offset < rbox.height) {
214
- offset = last - rbox.height;
215
- }
216
- }
217
- x$ = this.g.view.selectAll('rect').data(this.parsed);
218
- x$.exit().remove();
219
- x$.enter().append('rect');
220
- y$ = this.g.view.selectAll('rect');
221
- y$.attr('x', function(){
222
- return 0;
223
- });
224
- y$.attr('y', function(d, i){
225
- return scale.y(d.offset);
226
- });
227
- y$.attr('width', function(){
228
- return box.width;
229
- });
230
- y$.attr('height', function(d, i){
231
- var ref$;
232
- return (ref$ = scale.y(d.offset + d.value) - scale.y(d.offset) - 1) > 1 ? ref$ : 1;
233
- });
234
- y$.attr('fill', function(d, i){
235
- var ret, nbox, y1;
236
- return tint.get(Math.ceil(((d.offset + d.value / 2) / total) * 5));
237
- ret = tint.get(0, (i % 3 - 1) / 5);
238
- if (cfg.collapse.enabled) {
239
- nbox = nboxes[i];
240
- y1 = (nbox.y - rbox.y) + nbox.height / 2;
241
- if (y1 < rbox.height) {
242
- return ret;
243
- }
244
- ret = ldcolor.hcl(ret);
245
- ret.c = ret.c * 0.1;
246
- ret.l = ret.l * 1.1;
247
- }
248
- return ldcolor.web(ret);
249
- });
250
- z$ = this.g.legend.selectAll('g.label').data(this.parsed);
251
- z$.exit().remove();
252
- z$.enter().append('g').attr('class', 'label');
253
- this.g.legend.selectAll('g.label').each(function(d, i){
254
- var n, ret;
255
- if (this._text !== d.text) {
256
- this._text = d.text;
257
- n = layout.getNode('legend').childNodes[i];
258
- ret = wrapSvgText({
259
- node: n,
260
- useRange: true
261
- });
262
- this.textContent = "";
263
- return this.appendChild(ret);
264
- }
265
- }).transition().duration(350).attr('opacity', function(d, i){
266
- var nbox, y;
267
- nbox = nboxes[i];
268
- y = nbox.y - rbox.y - offset;
269
- if (y < 0 || y > rbox.height - nbox.height / 2) {
270
- return 0;
271
- } else {
272
- return 1;
273
- }
274
- }).attr('transform', function(d, i){
275
- var nbox;
276
- nbox = nboxes[i];
277
- return "translate(" + (nbox.x - rbox.x) + ", " + (nbox.y - rbox.y - offset) + ")";
278
- });
279
- z1$ = this.g.link.selectAll('path').data(this.parsed);
280
- z1$.exit().remove();
281
- z1$.enter().append('path').attr('fill', 'none').attr('stroke-width', 1);
282
- return this.g.link.selectAll('path').attr('stroke', function(d, i){
283
- return tint.get(Math.ceil(((d.offset + d.value / 2) / total) * 5));
284
- }).transition().duration(350).attr('d', function(d, i){
285
- var x0, x1, x2, x3, y0, nbox, y1;
286
- x0 = 0;
287
- x1 = lbox.width / 10;
288
- x2 = 9 * lbox.width / 10;
289
- x3 = lbox.width;
290
- y0 = scale.y(d.offset + d.value / 2);
291
- nbox = nboxes[i];
292
- y1 = (nbox.y - rbox.y) + nbox.height / 2 - offset;
293
- if (Math.abs(y1 - y0) < 2) {
294
- y1 = y0;
295
- }
296
- return "M" + x0 + " " + y0 + " L" + x1 + " " + y0 + " L" + x2 + " " + y1 + " L" + x3 + " " + y1;
297
- }).attr('opacity', function(d, i){
298
- var nbox, y0, y1;
299
- nbox = nboxes[i];
300
- y0 = scale.y(d.offset + d.value / 2);
301
- y1 = (nbox.y - rbox.y) + nbox.height / 2 - offset;
302
- if (Math.abs(y1 - y0) < 2) {
303
- y1 = y0;
304
- }
305
- return y1 > rbox.height || y1 < 0 ? 0 : 1;
306
- });
307
- }
308
- };
309
- };
310
- return blockFactory;
311
- });
312
- function import$(obj, src){
313
- var own = {}.hasOwnProperty;
314
- for (var key in src) if (own.call(src, key)) obj[key] = src[key];
315
- return obj;
316
- }</script></div>