@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,571 +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"></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(7em);
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
- padding-left: 1em;
16
- grid-column: 3;
17
- grid-row: 1/span 2;
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: 'line',
35
- version: '0.0.1',
36
- extend: {
37
- name: "base",
38
- version: "0.0.1"
39
- },
40
- dependencies: [],
41
- i18n: {
42
- "zh-TW": {
43
- "y axis": "Y軸",
44
- "x axis": "X軸",
45
- "rank": "順位"
46
- }
47
- }
48
- },
49
- init: function(arg$){
50
- var root, context, pubsub, t;
51
- root = arg$.root, context = arg$.context, pubsub = arg$.pubsub, t = arg$.t;
52
- return pubsub.fire('init', {
53
- mod: mod({
54
- context: context,
55
- t: t
56
- })
57
- });
58
- }
59
- };
60
- mod = function(arg$){
61
- var context, t, d3, chart, axis, format, sampleCount;
62
- context = arg$.context, t = arg$.t;
63
- d3 = context.d3, chart = context.chart, axis = context.axis, format = context.format;
64
- sampleCount = 4;
65
- return {
66
- sample: function(){
67
- return {
68
- 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].map(function(val){
69
- var ret;
70
- ret = {};
71
- (function(){
72
- var i$, to$, results$ = [];
73
- for (i$ = 1, to$ = sampleCount; i$ <= to$; ++i$) {
74
- results$.push(i$);
75
- }
76
- return results$;
77
- }()).map(function(i){
78
- var ref$;
79
- return ret["val" + i] = (ref$ = i * Math.random() * (10 - Math.abs(10 - val)) + val) > 0 ? ref$ : 0;
80
- });
81
- ret.order = val;
82
- return ret;
83
- }),
84
- binding: {
85
- value: (function(){
86
- var i$, to$, results$ = [];
87
- for (i$ = 1, to$ = sampleCount; i$ <= to$; ++i$) {
88
- results$.push(i$);
89
- }
90
- return results$;
91
- }()).map(function(it){
92
- return {
93
- key: "val" + it
94
- };
95
- }),
96
- order: {
97
- key: 'order'
98
- }
99
- }
100
- };
101
- },
102
- config: {
103
- mode: {
104
- type: 'choice',
105
- values: ['line', 'area', 'streamgraph', 'bump'],
106
- 'default': 'line'
107
- },
108
- stack: {
109
- type: 'boolean'
110
- },
111
- line: {
112
- type: 'choice',
113
- values: ['curve', 'linear'],
114
- 'default': 'linear'
115
- },
116
- showDot: {
117
- type: 'boolean',
118
- 'default': true
119
- }
120
- },
121
- dimension: {
122
- value: {
123
- type: 'R',
124
- name: "y axis",
125
- multiple: true
126
- },
127
- order: {
128
- type: 'ON',
129
- name: "x axis"
130
- }
131
- },
132
- init: function(){
133
- var svg, tint, this$ = this;
134
- svg = d3.select(this.svg);
135
- ['view', 'yaxis', 'xaxis', 'legend'].map(function(it){
136
- return (this$.g || (this$.g = {}))[it] = d3.select(this$.layout.getGroup(it));
137
- });
138
- this.tint = tint = new chart.utils.tint();
139
- this.line = d3.line().defined(function(it){
140
- return !isNaN(it.y1);
141
- }).x(function(it){
142
- return this$.scale.x(it.x);
143
- }).y(function(it){
144
- return this$.scale.y(it.y1);
145
- });
146
- this.area = d3.area().defined(function(it){
147
- return !isNaN(it.y1) && !isNaN(it.y0);
148
- }).x(function(it){
149
- return this$.scale.x(it.x);
150
- }).y0(function(it){
151
- return this$.scale.y(it.y0);
152
- }).y1(function(it){
153
- return this$.scale.y(it.y1);
154
- });
155
- this.xaxis = new chart.utils.axis({
156
- layout: this.layout,
157
- name: 'xaxis',
158
- direction: 'bottom'
159
- });
160
- this.yaxis = new chart.utils.axis({
161
- layout: this.layout,
162
- name: 'yaxis',
163
- direction: 'left'
164
- });
165
- this.tip = new chart.utils.tip({
166
- root: this.root,
167
- range: function(){
168
- return this$.layout.getNode('view').getBoundingClientRect();
169
- }
170
- });
171
- this._evthdr = {};
172
- this.root.addEventListener('mouseout', this._evthdr.out = function(evt){
173
- return this$.tip.hide().now();
174
- });
175
- this.root.addEventListener('mousemove', this._evthdr.move = function(evt){
176
- var x, y, min, i$, to$, i, series, j$, to1$, j, p, dx, dy, d, bind, pt, data, box;
177
- x = evt.clientX - this$.layout.getNode('view').getBoundingClientRect().x;
178
- y = evt.clientY - this$.layout.getNode('view').getBoundingClientRect().y;
179
- min = {
180
- d: -1,
181
- p: null,
182
- series: null
183
- };
184
- for (i$ = 0, to$ = this$.parsed.length; i$ < to$; ++i$) {
185
- i = i$;
186
- series = this$.parsed[i];
187
- for (j$ = 0, to1$ = series.pts.length; j$ < to1$; ++j$) {
188
- j = j$;
189
- p = series.pts[j];
190
- if (isNaN(p.y1) || isNaN(p.x)) {
191
- continue;
192
- }
193
- dx = Math.abs(this$.scale.x(p.x) - x);
194
- dy = Math.abs(this$.scale.y(p.y1) - y);
195
- d = Math.pow(dx, 2) + Math.pow(dy, 2);
196
- if (min.d < 0 || min.d > d) {
197
- min.d = d;
198
- min.p = p;
199
- min.series = series;
200
- }
201
- }
202
- }
203
- if (!(min.p && min.d && min.series)) {
204
- return;
205
- }
206
- bind = min.series.bind;
207
- pt = min.p;
208
- data = {
209
- name: (bind ? bind.name || bind.key || '' : void 8) + " /\n" + (pt.data.orderText || pt.data.order || pt.x) + (this$.binding.order.unit || ''),
210
- value: isNaN(pt.v)
211
- ? '-'
212
- : pt.v.toFixed(2) + "" + (bind ? bind.unit || '' : '')
213
- };
214
- box = {
215
- x: this$.scale.x(pt.x),
216
- y: this$.scale.y(pt.y)
217
- };
218
- return this$.tip.render({
219
- data: data,
220
- evt: evt,
221
- box: box
222
- });
223
- });
224
- this.legend = new chart.utils.legend({
225
- layout: this.layout,
226
- root: this.root,
227
- name: 'legend',
228
- shape: function(d){
229
- return d3.select(this).attr('fill', tint.get(d.text));
230
- },
231
- direction: 'vertical',
232
- cfg: {
233
- selectable: true
234
- }
235
- });
236
- this.legend.on('select', function(){
237
- this$.bind();
238
- this$.resize();
239
- return this$.render();
240
- });
241
- return this.scale = {
242
- x: d3.scaleLinear(),
243
- y: d3.scaleLinear()
244
- };
245
- },
246
- destroy: function(){
247
- this.root.removeEventListener('mouseout', this._evthdr.out);
248
- this.root.removeEventListener('mousemove', this._evthdr.move);
249
- return this.tip.destroy();
250
- },
251
- parse: function(){
252
- this.data.map(function(d, i){
253
- d.orderText = '' + (!(d.order != null)
254
- ? i
255
- : d.order);
256
- return d._order = !(d.order != null) || isNaN(+d.order)
257
- ? i
258
- : +d.order;
259
- });
260
- this.data.sort(function(a, b){
261
- if (a._order > b._order) {
262
- return 1;
263
- } else if (a._order === b._order) {
264
- return 0;
265
- } else {
266
- return -1;
267
- }
268
- });
269
- return this.legend.data(this.binding.value.map(function(it){
270
- return {
271
- key: it.key,
272
- text: it.key
273
- };
274
- }));
275
- },
276
- bind: function(){
277
- var binds, dd, sums, ref$, smin, smax, line0, i$, to$, i, p, b, line1, this$ = this, results$ = [];
278
- binds = this.binding.value;
279
- binds = this.binding.value.map(function(b, i){
280
- return {
281
- b: b,
282
- i: i
283
- };
284
- }).filter(function(d, i){
285
- return this$.legend.isSelected(d.b.key);
286
- });
287
- if (this.cfg.mode === 'bump') {
288
- this.parsed = [];
289
- dd = this.data.map(function(d){
290
- var ret, v;
291
- ret = import$({}, d);
292
- v = ret.value.map(function(d, i){
293
- return {
294
- i: i,
295
- v: this$.legend.isSelected(this$.binding.value[i].key) ? d : NaN
296
- };
297
- });
298
- v.sort(function(a, b){
299
- if (isNaN(a.v) && isNaN(b.v)) {
300
- return 0;
301
- } else if (isNaN(b.v)) {
302
- return -1;
303
- } else if (isNaN(a.v)) {
304
- return 1;
305
- }
306
- return b.v - a.v;
307
- });
308
- v.map(function(d, i){
309
- return d.r = i + 1;
310
- });
311
- v.sort(function(a, b){
312
- return a.i - b.i;
313
- });
314
- ret.value = v.map(function(it){
315
- if (isNaN(it.v)) {
316
- return NaN;
317
- } else {
318
- return it.r;
319
- }
320
- });
321
- ret.originalValue = v.map(function(it){
322
- return it.v;
323
- });
324
- return ret;
325
- });
326
- }
327
- dd = dd || this.data;
328
- if (this.cfg.mode === 'streamgraph') {
329
- sums = dd.map(function(d){
330
- var sum, i$, to$, i;
331
- sum = 0;
332
- for (i$ = 0, to$ = d.value.length; i$ < to$; ++i$) {
333
- i = i$;
334
- sum += d.value[i];
335
- }
336
- return sum;
337
- });
338
- ref$ = [Math.min.apply(Math, sums), Math.max.apply(Math, sums)], smin = ref$[0], smax = ref$[1];
339
- } else {
340
- ref$ = [
341
- dd.map(function(){
342
- return 0;
343
- }), 0, 0
344
- ], sums = ref$[0], smin = ref$[1], smax = ref$[2];
345
- }
346
- this.parsed = [];
347
- line0 = dd.map(function(){
348
- return 0;
349
- });
350
- for (i$ = 0, to$ = binds.length; i$ < to$; ++i$) {
351
- i = i$;
352
- ref$ = [i > 0 ? binds[i - 1] : null, binds[i]], p = ref$[0], b = ref$[1];
353
- line1 = dd.map(fn$);
354
- this.parsed.push({
355
- pts: (dd || this.data).map(fn1$),
356
- bind: b.b,
357
- color: b.b.name || b.b.key
358
- });
359
- if ((this.cfg.stack && this.cfg.mode !== 'bump') || ((ref$ = this.cfg.mode) === 'streamgraph' || ref$ === 'area')) {
360
- results$.push(line0 = line1);
361
- }
362
- }
363
- return results$;
364
- function fn$(d, j){
365
- return d.value[b.i] + line0[j];
366
- }
367
- function fn1$(d, j){
368
- return {
369
- data: d,
370
- y0: line0[j] - sums[j] / 2 + (smax - smin) / 2,
371
- y1: line1[j] - sums[j] / 2 + (smax - smin) / 2,
372
- x: d._order,
373
- v: d.originalValue
374
- ? d.originalValue[i]
375
- : d.value[i]
376
- };
377
- }
378
- },
379
- resize: function(){
380
- var ref$, miny, maxy, i$, to$, i, j$, to1$, j, p, w, h, maxTick, yticks, ref1$, yfmt, units, v, box, r, results$ = [];
381
- this.line.curve(this.cfg.line === 'curve'
382
- ? d3.curveCatmullRom
383
- : d3.curveLinear);
384
- this.area.curve(this.cfg.line === 'curve'
385
- ? d3.curveCatmullRom
386
- : d3.curveLinear);
387
- this.tip.toggle(((ref$ = this.cfg).tip || (ref$.tip = {})).enabled != null ? this.cfg.tip.enabled : true);
388
- ref$ = [0, 0], miny = ref$[0], maxy = ref$[1];
389
- for (i$ = 0, to$ = this.parsed.length; i$ < to$; ++i$) {
390
- i = i$;
391
- for (j$ = 0, to1$ = this.parsed[i].pts.length; j$ < to1$; ++j$) {
392
- j = j$;
393
- p = this.parsed[i].pts[j];
394
- if (!isNaN(p.y0) && miny > p.y0) {
395
- miny = p.y0;
396
- }
397
- if (!isNaN(p.y1) && miny > p.y1) {
398
- miny = p.y1;
399
- }
400
- if (!isNaN(p.y0) && maxy < p.y0) {
401
- maxy = p.y0;
402
- }
403
- if (!isNaN(p.y1) && maxy < p.y1) {
404
- maxy = p.y1;
405
- }
406
- }
407
- }
408
- this.extent = {
409
- x: d3.extent(this.data, function(it){
410
- return it._order;
411
- }),
412
- y: [this.cfg.mode === 'bump' ? miny > 1 ? miny : 1 : miny, maxy === miny ? miny + 1 : maxy]
413
- };
414
- this.scale.x.domain(this.extent.x);
415
- this.scale.y.domain(this.cfg.mode === 'bump'
416
- ? [this.extent.y[1], this.extent.y[0]]
417
- : this.extent.y);
418
- ref$ = [this.box.width, this.box.height], w = ref$[0], h = ref$[1];
419
- maxTick = (ref$ = Math.ceil(this.layout.getBox('yaxis').height / 40)) > 2 ? ref$ : 2;
420
- yticks = this.cfg.mode === 'bump'
421
- ? (function(){
422
- var i$, to$, ref$, results$ = [];
423
- for (i$ = 1, to$ = (ref$ = this.parsed.length || 1) > 1 ? ref$ : 1; i$ <= to$; ++i$) {
424
- results$.push(i$);
425
- }
426
- return results$;
427
- }.call(this))
428
- : this.scale.y.ticks((ref$ = ((ref1$ = this.cfg).yaxis || (ref1$.yaxis = {})).tickCount || 4) < maxTick ? ref$ : maxTick);
429
- yfmt = chart.utils.format.auto(yticks);
430
- this.legend.config(this.cfg.legend);
431
- this.legend.update();
432
- this.yaxis.config(this.cfg.yaxis);
433
- this.yaxis.ticks(yticks);
434
- this.yaxis.scale(this.scale.y);
435
- if (this.cfg.mode === 'bump') {
436
- this.yaxis.caption(t('rank'));
437
- } else {
438
- if (this.parsed.length > 1) {
439
- units = Array.from(new Set(this.parsed.map(function(it){
440
- return it.bind.unit;
441
- }))).filter(function(it){
442
- return it;
443
- });
444
- if (units.length > 1) {
445
- this.yaxis.caption('');
446
- } else {
447
- this.yaxis.caption(units[0] || '');
448
- }
449
- } else {
450
- v = (this.parsed[0] || {}).bind || {};
451
- this.yaxis.caption((v.name || v.key || '') + (v.unit ? "(" + v.unit + ")" : ''));
452
- }
453
- }
454
- this.xaxis.config(this.cfg.xaxis);
455
- this.xaxis.ticks(this.data.map(function(it){
456
- return {
457
- v: it._order,
458
- t: it.orderText
459
- };
460
- }));
461
- this.xaxis.scale(this.scale.x);
462
- this.xaxis.caption((this.binding.order.name || this.binding.order.key) + (this.binding.order.unit ? "(" + this.binding.order.unit + ")" : ''));
463
- for (i$ = 0; i$ < 2; ++i$) {
464
- i = i$;
465
- this.layout.update(false);
466
- box = this.layout.getBox('view');
467
- ref$ = [box.width, box.height], w = ref$[0], h = ref$[1];
468
- this.tint.set(this.cfg.palette);
469
- r = this.cfg.dotSize || 3;
470
- this.scale.x.range([0, w - r]);
471
- this.scale.y.range([h, r]);
472
- this.xaxis.render();
473
- results$.push(this.yaxis.render());
474
- }
475
- return results$;
476
- },
477
- render: function(){
478
- var scale, tint, extent, r, vbox, lbox, x$, y$, this$ = this;
479
- scale = this.scale, tint = this.tint, extent = this.extent;
480
- r = this.cfg.dotSize || 3;
481
- vbox = this.layout.getBox('view');
482
- lbox = this.layout.getBox('yaxis');
483
- x$ = this.g.view.selectAll('path.data').data(this.parsed, function(it){
484
- return it.bind.key;
485
- });
486
- x$.exit().remove();
487
- x$.enter().append('path').attr('class', 'data').attr('fill', 'none').attr('d', function(d, i){
488
- var ref$;
489
- if ((ref$ = this$.cfg.mode) === 'streamgraph' || ref$ === 'area') {
490
- return this$.area(d.pts);
491
- } else {
492
- return this$.line(d.pts);
493
- }
494
- }).attr('stroke', function(d, i){
495
- return this$.tint.get(d.color);
496
- }).attr('stroke-width', 1);
497
- this.g.view.selectAll('path.data').transition().duration(150).style('opacity', function(d, i){
498
- if (this$.legend.isSelected(d.bind.key)) {
499
- return 1;
500
- } else {
501
- return 0.3;
502
- }
503
- }).attr('d', function(d, i){
504
- var ref$;
505
- if ((ref$ = this$.cfg.mode) === 'streamgraph' || ref$ === 'area') {
506
- return this$.area(d.pts);
507
- } else {
508
- return this$.line(d.pts);
509
- }
510
- }).attr('stroke', function(d, i){
511
- return this$.tint.get(d.color);
512
- }).attr('fill', function(d, i){
513
- var ref$;
514
- if ((ref$ = this$.cfg.mode) === 'streamgraph' || ref$ === 'area') {
515
- return this$.tint.get(d.color);
516
- } else {
517
- return 'none';
518
- }
519
- }).attr('fill-opacity', function(){
520
- return '0.5';
521
- });
522
- y$ = this.g.view.selectAll('g.dot').data(this.cfg.showDot
523
- ? this.parsed
524
- : [], function(it){
525
- return it.bind.key;
526
- });
527
- y$.exit().remove();
528
- y$.enter().append('g').attr('class', 'dot');
529
- this.g.view.selectAll('g.dot').style('opacity', function(d, i){
530
- if (this$.legend.isSelected(d.bind.key)) {
531
- return 1;
532
- } else {
533
- return 0.3;
534
- }
535
- }).each(function(d, i){
536
- var x$;
537
- x$ = d3.select(this).selectAll('circle.dot').data(d.pts);
538
- x$.exit().remove();
539
- x$.enter().append('circle').attr('class', 'dot').attr('r', r).attr('fill', '#fff').attr('stroke', tint.get(d.bind.name || d.bind.key));
540
- d3.select(this).selectAll('circle.dot').filter(function(d, i){
541
- return isNaN(d.y1);
542
- }).attr('cx', function(d, i){
543
- if (isNaN(scale.x(d.x))) {
544
- return scale.x(extent.x[0]);
545
- } else {
546
- return scale.x(d.x);
547
- }
548
- }).attr('cy', function(d, i){
549
- return scale.y(extent.y[0]);
550
- }).transition(150).attr('opacity', 0);
551
- return d3.select(this).selectAll('circle.dot').filter(function(d, i){
552
- return !isNaN(d.y1);
553
- }).attr('cx', function(d, i){
554
- return scale.x(d.x);
555
- }).attr('cy', function(d, i){
556
- return scale.y(d.y1);
557
- }).attr('r', r).attr('fill', tint.get(d.color)).attr('stroke', tint.get(d.color)).transition(150).attr('opacity', 1);
558
- });
559
- this.legend.render();
560
- this.xaxis.render();
561
- return this.yaxis.render();
562
- }
563
- };
564
- };
565
- return blockFactory;
566
- });
567
- function import$(obj, src){
568
- var own = {}.hasOwnProperty;
569
- for (var key in src) if (own.call(src, key)) obj[key] = src[key];
570
- return obj;
571
- }</script></div>