@plotdb/chart 0.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 (177) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +50 -0
  3. package/build +39 -0
  4. package/dist/chart.css +8 -0
  5. package/dist/chart.js +603 -0
  6. package/dist/chart.min.css +1 -0
  7. package/dist/chart.min.js +1 -0
  8. package/dist/data/index.js +73 -0
  9. package/dist/utils/axis.js +357 -0
  10. package/dist/utils/axis.min.js +1 -0
  11. package/dist/utils/config.js +33 -0
  12. package/dist/utils/config.min.js +1 -0
  13. package/dist/utils/data.js +238 -0
  14. package/dist/utils/data.min.js +1 -0
  15. package/dist/utils/format.js +70 -0
  16. package/dist/utils/format.min.js +1 -0
  17. package/dist/utils/legend.css +40 -0
  18. package/dist/utils/legend.js +263 -0
  19. package/dist/utils/legend.min.css +1 -0
  20. package/dist/utils/legend.min.js +1 -0
  21. package/dist/utils/tint.js +138 -0
  22. package/dist/utils/tint.min.js +1 -0
  23. package/dist/utils/tip.js +148 -0
  24. package/dist/utils/tip.min.js +1 -0
  25. package/doc/charts.md +58 -0
  26. package/doc/config.md +44 -0
  27. package/doc/draft/chart.md +146 -0
  28. package/doc/draft/data.md +8 -0
  29. package/doc/draft/definition.md +0 -0
  30. package/doc/draft/events.md +0 -0
  31. package/doc/draft/filter.md +0 -0
  32. package/doc/draft/lifecycle.md +89 -0
  33. package/doc/spec.md +89 -0
  34. package/doc/todo.md +27 -0
  35. package/doc/utils/tip.md +84 -0
  36. package/package.json +83 -0
  37. package/src/chart.ls +320 -0
  38. package/src/chart.styl +6 -0
  39. package/src/data/en-US/category +20 -0
  40. package/src/data/en-US/fruit +39 -0
  41. package/src/data/en-US/movie +125 -0
  42. package/src/data/en-US/name +58 -0
  43. package/src/data/index.ls +34 -0
  44. package/src/data/zh-TW/category +20 -0
  45. package/src/data/zh-TW/fruits +38 -0
  46. package/src/data/zh-TW/movie +125 -0
  47. package/src/data/zh-TW/names +105 -0
  48. package/src/utils/axis.ls +229 -0
  49. package/src/utils/config.ls +11 -0
  50. package/src/utils/data.ls +104 -0
  51. package/src/utils/format.ls +30 -0
  52. package/src/utils/legend.ls +134 -0
  53. package/src/utils/legend.styl +37 -0
  54. package/src/utils/tint.ls +66 -0
  55. package/src/utils/tip.ls +97 -0
  56. package/web/src/pug/base.pug +19 -0
  57. package/web/src/pug/block/axis/0.0.1/index.ls +38 -0
  58. package/web/src/pug/block/axis/0.0.1/index.pug +1 -0
  59. package/web/src/pug/block/axis-bubble/0.0.1/index.ls +141 -0
  60. package/web/src/pug/block/axis-bubble/0.0.1/index.pug +1 -0
  61. package/web/src/pug/block/bar/0.0.1/index.ls +274 -0
  62. package/web/src/pug/block/bar/0.0.1/index.pug +35 -0
  63. package/web/src/pug/block/bar-list/0.0.1/index.ls +85 -0
  64. package/web/src/pug/block/bar-list/0.0.1/index.pug +30 -0
  65. package/web/src/pug/block/bar-race/0.0.1/index.ls +83 -0
  66. package/web/src/pug/block/bar-race/0.0.1/index.pug +21 -0
  67. package/web/src/pug/block/base/0.0.1/index.ls +67 -0
  68. package/web/src/pug/block/base/0.0.1/index.pug +5 -0
  69. package/web/src/pug/block/blank/0.0.1/index.ls +25 -0
  70. package/web/src/pug/block/blank/0.0.1/index.pug +1 -0
  71. package/web/src/pug/block/bubble/0.0.1/index.ls +220 -0
  72. package/web/src/pug/block/bubble/0.0.1/index.pug +28 -0
  73. package/web/src/pug/block/curve-bar/0.0.1/index.ls +89 -0
  74. package/web/src/pug/block/curve-bar/0.0.1/index.pug +16 -0
  75. package/web/src/pug/block/curve-bar/0.0.1/sample.js +338 -0
  76. package/web/src/pug/block/dumbbell/0.0.1/index.ls +90 -0
  77. package/web/src/pug/block/dumbbell/0.0.1/index.pug +1 -0
  78. package/web/src/pug/block/empty/0.0.1/index.ls +27 -0
  79. package/web/src/pug/block/empty/0.0.1/index.pug +2 -0
  80. package/web/src/pug/block/gauge/0.0.1/index.ls +100 -0
  81. package/web/src/pug/block/gauge/0.0.1/index.pug +31 -0
  82. package/web/src/pug/block/gauge/0.0.1/sample.js +338 -0
  83. package/web/src/pug/block/line/0.0.1/index.ls +265 -0
  84. package/web/src/pug/block/line/0.0.1/index.pug +33 -0
  85. package/web/src/pug/block/number/0.0.1/index.ls +69 -0
  86. package/web/src/pug/block/number/0.0.1/index.pug +20 -0
  87. package/web/src/pug/block/percent-list/0.0.1/index.ls +167 -0
  88. package/web/src/pug/block/percent-list/0.0.1/index.pug +34 -0
  89. package/web/src/pug/block/pie/0.0.1/index.ls +125 -0
  90. package/web/src/pug/block/pie/0.0.1/index.pug +19 -0
  91. package/web/src/pug/block/pie/0.0.1/sample.js +338 -0
  92. package/web/src/pug/block/pie-bubble/0.0.1/index.ls +185 -0
  93. package/web/src/pug/block/pie-bubble/0.0.1/index.pug +40 -0
  94. package/web/src/pug/block/radar/0.0.1/index.ls +113 -0
  95. package/web/src/pug/block/radar/0.0.1/index.pug +1 -0
  96. package/web/src/pug/block/radar/0.0.1/xx +285 -0
  97. package/web/src/pug/block/scatter/0.0.1/index.ls +128 -0
  98. package/web/src/pug/block/scatter/0.0.1/index.pug +30 -0
  99. package/web/src/pug/block/sheet/0.0.1/index.ls +38 -0
  100. package/web/src/pug/block/sheet/0.0.1/index.pug +5 -0
  101. package/web/src/pug/block/table/0.0.1/index.ls +40 -0
  102. package/web/src/pug/block/table/0.0.1/index.pug +3 -0
  103. package/web/src/pug/block/taiwantown/0.0.1/index.ls +48 -0
  104. package/web/src/pug/block/taiwantown/0.0.1/index.pug +52 -0
  105. package/web/src/pug/block/taiwanvillage/0.0.1/index.ls +53 -0
  106. package/web/src/pug/block/taiwanvillage/0.0.1/index.pug +52 -0
  107. package/web/src/pug/block/treemap/0.0.1/index.ls +172 -0
  108. package/web/src/pug/block/treemap/0.0.1/index.pug +42 -0
  109. package/web/src/pug/block/voronoi-treemap/0.0.1/index.ls +174 -0
  110. package/web/src/pug/block/voronoi-treemap/0.0.1/index.pug +17 -0
  111. package/web/src/pug/block/voronoi-treemap/0.0.1/sample.js +241 -0
  112. package/web/src/pug/block/wordcloud/0.0.1/index.ls +61 -0
  113. package/web/src/pug/block/wordcloud/0.0.1/index.pug +1 -0
  114. package/web/src/pug/block/worldmap/0.0.1/index.ls +83 -0
  115. package/web/src/pug/block/worldmap/0.0.1/index.pug +12 -0
  116. package/web/src/pug/index.ls +72 -0
  117. package/web/src/pug/index.pug +52 -0
  118. package/web/src/styl/index.styl +0 -0
  119. package/web/static/assets/block/cache.js +4 -0
  120. package/web/static/assets/custom-lib/d3/d3-array.v2.min.js +2 -0
  121. package/web/static/assets/custom-lib/d3/d3-axis.v2.min.js +2 -0
  122. package/web/static/assets/custom-lib/d3/d3-brush.v2.min.js +2 -0
  123. package/web/static/assets/custom-lib/d3/d3-color.v2.min.js +2 -0
  124. package/web/static/assets/custom-lib/d3/d3-dispatch.v2.min.js +2 -0
  125. package/web/static/assets/custom-lib/d3/d3-drag.v2.min.js +2 -0
  126. package/web/static/assets/custom-lib/d3/d3-ease.v2.min.js +2 -0
  127. package/web/static/assets/custom-lib/d3/d3-force-boundary.v0.0.1.min.js +2 -0
  128. package/web/static/assets/custom-lib/d3/d3-force.v2.min.js +2 -0
  129. package/web/static/assets/custom-lib/d3/d3-format.v2.min.js +2 -0
  130. package/web/static/assets/custom-lib/d3/d3-hierarchy.v2.min.js +2 -0
  131. package/web/static/assets/custom-lib/d3/d3-interpolate.v2.min.js +2 -0
  132. package/web/static/assets/custom-lib/d3/d3-path.v2.min.js +2 -0
  133. package/web/static/assets/custom-lib/d3/d3-quadtree.v2.min.js +2 -0
  134. package/web/static/assets/custom-lib/d3/d3-random.v2.min.js +2 -0
  135. package/web/static/assets/custom-lib/d3/d3-scale-chromatic.v1.min.js +2 -0
  136. package/web/static/assets/custom-lib/d3/d3-selection.v2.min.js +2 -0
  137. package/web/static/assets/custom-lib/d3/d3-shape.v2.min.js +2 -0
  138. package/web/static/assets/custom-lib/d3/d3-timer.v2.min.js +2 -0
  139. package/web/static/assets/custom-lib/d3/d3-transition.v2.min.js +2 -0
  140. package/web/static/assets/custom-lib/d3/d3.v4.js +17178 -0
  141. package/web/static/assets/custom-lib/d3/d3.v4.min.js +2 -0
  142. package/web/static/assets/data/countrycode.json +1 -0
  143. package/web/static/assets/data/world-110m.json +1 -0
  144. package/web/static/assets/data/zh-to-alpha2.json +1 -0
  145. package/web/static/assets/img/fluid.svg +16 -0
  146. package/web/static/block/axis/0.0.1/index.html +79 -0
  147. package/web/static/block/axis-bubble/0.0.1/index.html +222 -0
  148. package/web/static/block/bar/0.0.1/index.html +581 -0
  149. package/web/static/block/bar-list/0.0.1/index.html +231 -0
  150. package/web/static/block/bar-race/0.0.1/index.html +184 -0
  151. package/web/static/block/base/0.0.1/index.html +197 -0
  152. package/web/static/block/blank/0.0.1/index.html +42 -0
  153. package/web/static/block/bubble/0.0.1/index.html +402 -0
  154. package/web/static/block/bubble/0.0.1/test.html +0 -0
  155. package/web/static/block/curve-bar/0.0.1/index.html +148 -0
  156. package/web/static/block/dumbbell/0.0.1/index.html +178 -0
  157. package/web/static/block/empty/0.0.1/index.html +76 -0
  158. package/web/static/block/gauge/0.0.1/index.html +150 -0
  159. package/web/static/block/line/0.0.1/index.html +540 -0
  160. package/web/static/block/number/0.0.1/index.html +152 -0
  161. package/web/static/block/percent-list/0.0.1/index.html +316 -0
  162. package/web/static/block/pie/0.0.1/index.html +281 -0
  163. package/web/static/block/pie-bubble/0.0.1/index.html +358 -0
  164. package/web/static/block/radar/0.0.1/index.html +149 -0
  165. package/web/static/block/scatter/0.0.1/index.html +251 -0
  166. package/web/static/block/sheet/0.0.1/index.html +103 -0
  167. package/web/static/block/table/0.0.1/index.html +73 -0
  168. package/web/static/block/taiwantown/0.0.1/index.html +210 -0
  169. package/web/static/block/taiwanvillage/0.0.1/index.html +220 -0
  170. package/web/static/block/treemap/0.0.1/index.html +360 -0
  171. package/web/static/block/voronoi-treemap/0.0.1/index.html +350 -0
  172. package/web/static/block/wordcloud/0.0.1/index.html +92 -0
  173. package/web/static/block/worldmap/0.0.1/index.html +207 -0
  174. package/web/static/css/index.css +0 -0
  175. package/web/static/css/index.min.css +0 -0
  176. package/web/static/favicon.ico +0 -0
  177. package/web/static/index.html +153 -0
@@ -0,0 +1,178 @@
1
+ <div><script type="@plotdb/block">(function(it){
2
+ return it();
3
+ })(function(){
4
+ var blockFactory, mod;
5
+ blockFactory = {
6
+ pkg: {
7
+ name: 'dumbbell',
8
+ version: '0.0.1',
9
+ extend: {
10
+ name: "base",
11
+ version: "0.0.1"
12
+ },
13
+ dependencies: []
14
+ },
15
+ init: function(arg$){
16
+ var root, context, pubsub;
17
+ root = arg$.root, context = arg$.context, pubsub = arg$.pubsub;
18
+ return pubsub.fire('init', {
19
+ mod: mod({
20
+ context: context
21
+ })
22
+ });
23
+ }
24
+ };
25
+ mod = function(arg$){
26
+ var context, d3, ldcolor, debounce, infinite;
27
+ context = arg$.context;
28
+ d3 = context.d3, ldcolor = context.ldcolor, debounce = context.debounce, infinite = context.infinite;
29
+ return {
30
+ sample: function(){
31
+ return {
32
+ raw: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(function(val){
33
+ return {
34
+ val1: Math.random() * 0.5 + 0.4,
35
+ val2: Math.random() * 0.5 + 0.4,
36
+ val3: Math.random() * 0.6 + 0.1,
37
+ val4: Math.random() * 0.6 + 0.1,
38
+ name: val
39
+ };
40
+ }),
41
+ binding: {
42
+ name: {
43
+ key: 'name'
44
+ },
45
+ y1: [
46
+ {
47
+ key: 'val1'
48
+ }, {
49
+ key: 'val2'
50
+ }
51
+ ],
52
+ y2: [
53
+ {
54
+ key: 'val3'
55
+ }, {
56
+ key: 'val4'
57
+ }
58
+ ]
59
+ }
60
+ };
61
+ },
62
+ config: {},
63
+ dimension: {
64
+ y1: {
65
+ type: 'R',
66
+ multiple: true,
67
+ name: "y pos"
68
+ },
69
+ y2: {
70
+ type: 'R',
71
+ multiple: true,
72
+ name: "y pos"
73
+ },
74
+ name: {
75
+ type: 'N',
76
+ name: "dumbbell name"
77
+ }
78
+ },
79
+ init: function(){
80
+ return this.infcolor = new infinite();
81
+ },
82
+ parse: function(){
83
+ var this$ = this;
84
+ this.parsed = [];
85
+ this.parsed = this.data.map(function(d, i){
86
+ var dumbbell;
87
+ dumbbell = d.y1.map(function(e, j){
88
+ return {
89
+ y1: d.y1[j] || 0,
90
+ y2: d.y2[j] || 0,
91
+ name: [this$.binding.y1[j].key, this$.binding.y2[j].key]
92
+ };
93
+ });
94
+ return {
95
+ name: d.name,
96
+ dumbbell: dumbbell
97
+ };
98
+ });
99
+ return this.names = this.data.map(function(it){
100
+ return it.name;
101
+ });
102
+ },
103
+ resize: function(){
104
+ var ref$, w, h;
105
+ ref$ = [this.box.width, this.box.height], w = ref$[0], h = ref$[1];
106
+ this.extent = {
107
+ y: [
108
+ d3.min(this.data.map(function(d, i){
109
+ return d3.min([d3.min(d.y1), d3.min(d.y2)]);
110
+ })), d3.max(this.data.map(function(d, i){
111
+ return d3.max([d3.max(d.y1), d3.max(d.y2)]);
112
+ }))
113
+ ]
114
+ };
115
+ this.scale = {
116
+ x: d3.scaleBand().domain(this.names).range([0, w]).paddingInner(0.3),
117
+ y: d3.scaleLinear().domain([0, this.extent.y[1]]).range([0, h]),
118
+ c: d3.scaleOrdinal(d3.schemeCategory10)
119
+ };
120
+ if (this.cfg != null && this.cfg.palette) {
121
+ this.scale.c = d3.scaleOrdinal(this.cfg.palette.colors.map(function(it){
122
+ return ldcolor.web(it.value || it);
123
+ }));
124
+ }
125
+ if (this.cfg != null && this.cfg.palette) {
126
+ return this.infcolor.setColors(this.cfg.palette.colors.map(function(it){
127
+ return ldcolor.web(it.value || it);
128
+ }));
129
+ }
130
+ },
131
+ render: function(){
132
+ var scale, infcolor, svg, x$;
133
+ scale = this.scale, infcolor = this.infcolor;
134
+ svg = d3.select(this.svg);
135
+ x$ = svg.selectAll('g.data').data(this.parsed);
136
+ x$.exit().remove();
137
+ x$.enter().append('g').attr('class', 'data');
138
+ return svg.selectAll('g.data').each(function(e, j){
139
+ var bw, n, x$;
140
+ bw = scale.x.bandwidth();
141
+ n = d3.select(this);
142
+ x$ = n.selectAll('g.dumbbell').data(e.dumbbell);
143
+ x$.exit().remove();
144
+ x$.enter().append('g').attr('class', 'dumbbell');
145
+ return n.selectAll('g.dumbbell').each(function(f, k){
146
+ var m, x$, y$;
147
+ m = d3.select(this);
148
+ x$ = m.selectAll('circle').data([1, 2]);
149
+ x$.exit().remove();
150
+ x$.enter().append('circle');
151
+ y$ = m.selectAll('line').data([0]);
152
+ y$.exit().remove();
153
+ y$.enter().append('line');
154
+ m.selectAll('circle').attr('cx', function(d, i){
155
+ return scale.x(e.name) + bw * i;
156
+ }).attr('cy', function(d, i){
157
+ return scale.y(f["y" + d]);
158
+ }).attr('r', 2).attr('fill', function(){
159
+ return infcolor.get(f.name[0]);
160
+ });
161
+ return m.selectAll('line').attr('x1', function(d, i){
162
+ return scale.x(e.name);
163
+ }).attr('x2', function(d, i){
164
+ return scale.x(e.name) + bw;
165
+ }).attr('y1', function(d, i){
166
+ return scale.y(f.y1);
167
+ }).attr('y2', function(d, i){
168
+ return scale.y(f.y2);
169
+ }).attr('stroke', function(){
170
+ return infcolor.get(f.name[0]);
171
+ }).attr('stroke-width', 1);
172
+ });
173
+ });
174
+ }
175
+ };
176
+ };
177
+ return blockFactory;
178
+ });</script></div>
@@ -0,0 +1,76 @@
1
+ <div style="width:100%;height:100%"><script type="@plotdb/block">({
2
+ pkg: {
3
+ name: 'empty',
4
+ version: '0.0.1',
5
+ dependencies: [
6
+ {
7
+ url: "/assets/lib/@loadingio/debounce.js/main/debounce.min.js"
8
+ }, {
9
+ url: "/assets/lib/wrap-svg-text/main/index.min.js",
10
+ async: false
11
+ }, {
12
+ url: "/assets/lib/@plotdb/layout/main/index.min.js",
13
+ async: false
14
+ }, {
15
+ url: "/assets/lib/@plotdb/layout/main/index.min.css",
16
+ type: 'css'
17
+ }, {
18
+ url: "/assets/lib/ldcolor/main/ldcolor.min.js",
19
+ async: false
20
+ }, {
21
+ url: "/assets/lib/@plotdb/chart/main/chart.js",
22
+ async: false
23
+ }, {
24
+ url: "/assets/lib/@plotdb/chart/main/chart.min.css",
25
+ type: 'css'
26
+ }, {
27
+ url: "/assets/lib/@plotdb/chart/main/utils/legend.js",
28
+ async: false
29
+ }, {
30
+ url: "/assets/lib/@plotdb/chart/main/utils/legend.css",
31
+ type: 'css'
32
+ }, {
33
+ url: "/assets/lib/@plotdb/chart/main/utils/tint.js",
34
+ async: false
35
+ }, {
36
+ url: "/assets/lib/@plotdb/chart/main/utils/data.js",
37
+ async: false
38
+ }
39
+ ]
40
+ },
41
+ init: function(arg$){
42
+ var root, context, pubsub, data, chart, this$ = this;
43
+ root = arg$.root, context = arg$.context, pubsub = arg$.pubsub, data = arg$.data;
44
+ chart = context.chart;
45
+ pubsub.on('init', function(opt){
46
+ var c;
47
+ opt == null && (opt = {});
48
+ opt = import$({
49
+ root: root,
50
+ delayRender: true
51
+ }, opt);
52
+ this$.chart = c = new chart(import$((opt.prepareSvg = false, opt.layout = false, opt), data));
53
+ return c.init().then(function(){
54
+ return c;
55
+ });
56
+ });
57
+ return this;
58
+ },
59
+ 'interface': function(){
60
+ return this.chart;
61
+ },
62
+ mod: function(root){
63
+ return {
64
+ config: {},
65
+ dimension: {},
66
+ init: function(){},
67
+ resize: function(){},
68
+ render: function(){}
69
+ };
70
+ }
71
+ });
72
+ function import$(obj, src){
73
+ var own = {}.hasOwnProperty;
74
+ for (var key in src) if (own.call(src, key)) obj[key] = src[key];
75
+ return obj;
76
+ }</script></div>
@@ -0,0 +1,150 @@
1
+ <div><div plug="layout"><div class="pdl-layout"><div data-type="layout"><div class="pdl-cell" data-name="view"></div><div class="text"><div class="pdl-cell" data-name="number">0000</div><div class="pdl-cell" data-name="unit">0000</div></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
+ }
6
+ .pdl-layout > div[data-type=layout] .text {
7
+ margin-left: 0.5em;
8
+ height: 100%;
9
+ display: flex;
10
+ flex-direction: column;
11
+ justify-content: center;
12
+ align-items: start;
13
+ }
14
+ .pdl-layout > div[data-type=layout] [data-name=view] {
15
+ height: 100%;
16
+ }
17
+ .pdl-layout > div[data-type=layout] [data-name=number] {
18
+ font-size: 24px;
19
+ line-height: 1em;
20
+ }
21
+ .pdl-layout > div[data-type=layout] [data-name=unit] {
22
+ line-height: 1em;
23
+ }
24
+ </style><script type="@plotdb/block">(function(it){
25
+ return it();
26
+ })(function(){
27
+ var blockFactory, mod;
28
+ blockFactory = {
29
+ pkg: {
30
+ name: 'gauge',
31
+ version: '0.0.1',
32
+ extend: {
33
+ name: "base",
34
+ version: "0.0.1"
35
+ },
36
+ dependencies: []
37
+ },
38
+ init: function(arg$){
39
+ var root, context, pubsub;
40
+ root = arg$.root, context = arg$.context, pubsub = arg$.pubsub;
41
+ return pubsub.fire('init', {
42
+ mod: mod({
43
+ context: context
44
+ })
45
+ });
46
+ }
47
+ };
48
+ mod = function(arg$){
49
+ var context, d3, chart;
50
+ context = arg$.context;
51
+ d3 = context.d3, chart = context.chart;
52
+ return {
53
+ sample: function(){
54
+ return {
55
+ raw: [{
56
+ value: Math.random(),
57
+ max: 1
58
+ }],
59
+ binding: {
60
+ value: {
61
+ key: 'value'
62
+ },
63
+ max: {
64
+ key: 'max'
65
+ }
66
+ }
67
+ };
68
+ },
69
+ config: {},
70
+ dimension: {
71
+ value: {
72
+ type: 'R',
73
+ name: "value"
74
+ },
75
+ max: {
76
+ type: 'R',
77
+ name: "max"
78
+ }
79
+ },
80
+ init: function(){
81
+ var tint;
82
+ this.tint = tint = new chart.utils.tint();
83
+ this.arc = d3.arc();
84
+ return this.g = {
85
+ view: d3.select(this.layout.getGroup('view')),
86
+ number: d3.select(this.layout.getGroup('number')),
87
+ unit: d3.select(this.layout.getGroup('unit'))
88
+ };
89
+ },
90
+ parse: function(){
91
+ var x$, y$, z$, z1$, z2$;
92
+ x$ = this.g.view.selectAll('path.wedge').data([0, 1]);
93
+ x$.exit().remove();
94
+ x$.enter().append('path').attr('class', 'wedge');
95
+ y$ = this.g.view.selectAll('path.pin').data([0]);
96
+ y$.exit().remove();
97
+ y$.enter().append('path').attr('class', 'pin');
98
+ z$ = this.g.view.selectAll('citcle').data([0]);
99
+ z$.exit().remove();
100
+ z$.enter().append('circle');
101
+ z1$ = this.g.number.selectAll('text').data([0]);
102
+ z1$.exit().remove();
103
+ z1$.enter().append('text');
104
+ z2$ = this.g.unit.selectAll('text').data([0]);
105
+ z2$.exit().remove();
106
+ z2$.enter().append('text');
107
+ return z2$;
108
+ },
109
+ resize: function(){
110
+ var n, b, x$;
111
+ n = this.layout.getNode('view');
112
+ b = this.layout.getBox('view');
113
+ x$ = n.style;
114
+ x$.width = b.height + "px";
115
+ return this.layout.update(false);
116
+ },
117
+ render: function(){
118
+ var d, percent, ref$, ref1$, angle, start, end, box, size, offset, this$ = this;
119
+ if (this.cfg != null && this.cfg.palette) {
120
+ this.tint.set(this.cfg.palette.colors.map(function(it){
121
+ return it.value || it;
122
+ }));
123
+ }
124
+ d = this.data[0] || {};
125
+ percent = (ref$ = (ref1$ = (d.value || 0) / (d.max || 1)) < 1 ? ref1$ : 1) > 0 ? ref$ : 0;
126
+ angle = percent * (Math.PI * 6 / 4) + Math.PI / 4;
127
+ start = Math.PI / 4;
128
+ end = Math.PI * 7 / 4;
129
+ box = this.layout.getBox('view');
130
+ size = Math.min(box.width, box.height) / 2;
131
+ this.arc.innerRadius(size * 0.5).outerRadius(size);
132
+ offset = size * (1 - 1 / Math.sqrt(2)) / 2;
133
+ this.g.view.selectAll('path.wedge').attr('transform', "translate(" + box.width / 2 + "," + (offset + box.height / 2) + ") rotate(180)").attr('d', function(d, i){
134
+ this$.arc.startAngle(i === 0 ? start : angle).endAngle(i === 0 ? angle : end);
135
+ return this$.arc();
136
+ }).attr('fill', function(d, i){
137
+ return this$.tint.get(d);
138
+ });
139
+ this.g.view.selectAll('path.pin').attr('transform', "translate(" + box.width / 2 + " " + (offset + box.height / 2) + ") rotate(" + (45 + 270 * percent) + ")").attr('d', "M0 " + size * 0.4 + "L0 " + size).attr('fill', 'none').attr('stroke', '#000').attr('stroke-width', 2);
140
+ this.g.number.selectAll('text').text(function(){
141
+ return 3000;
142
+ }).attr('font-size', 24).attr('dominant-baseline', 'hanging');
143
+ return this.g.unit.selectAll('text').text(function(){
144
+ return "新臺幣";
145
+ }).attr('dominant-baseline', 'hanging');
146
+ }
147
+ };
148
+ };
149
+ return blockFactory;
150
+ });</script></div>