@plotdb/chart 0.0.3 → 1.0.1

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 (71) hide show
  1. package/CHANGELOG.md +11 -1
  2. package/build +11 -5
  3. package/dist/index.css +8 -0
  4. package/dist/index.js +607 -0
  5. package/dist/index.min.css +1 -0
  6. package/dist/index.min.js +1 -0
  7. package/package.json +12 -9
  8. package/src/{chart.ls → index.ls} +0 -0
  9. package/src/{chart.styl → index.styl} +0 -0
  10. package/web/src/pug/base.pug +1 -0
  11. package/web/src/pug/block/axis/0.0.1/index.ls +1 -7
  12. package/web/src/pug/block/axis-bubble/0.0.1/index.ls +1 -5
  13. package/web/src/pug/block/bar/0.0.1/index.ls +1 -5
  14. package/web/src/pug/block/bar-list/0.0.1/index.ls +1 -5
  15. package/web/src/pug/block/bar-race/0.0.1/index.ls +1 -5
  16. package/web/src/pug/block/base/0.0.1/index.ls +63 -64
  17. package/web/src/pug/block/blank/0.0.1/index.ls +1 -5
  18. package/web/src/pug/block/bubble/0.0.1/index.ls +4 -6
  19. package/web/src/pug/block/bubble/0.0.1/index.pug +14 -0
  20. package/web/src/pug/block/curve-bar/0.0.1/index.ls +1 -5
  21. package/web/src/pug/block/dumbbell/0.0.1/index.ls +1 -5
  22. package/web/src/pug/block/empty/0.0.1/index.ls +25 -24
  23. package/web/src/pug/block/gauge/0.0.1/index.ls +1 -5
  24. package/web/src/pug/block/line/0.0.1/index.ls +1 -6
  25. package/web/src/pug/block/number/0.0.1/index.ls +1 -5
  26. package/web/src/pug/block/percent-list/0.0.1/index.ls +1 -7
  27. package/web/src/pug/block/pie/0.0.1/index.ls +1 -5
  28. package/web/src/pug/block/pie-bubble/0.0.1/index.ls +1 -5
  29. package/web/src/pug/block/radar/0.0.1/index.ls +1 -5
  30. package/web/src/pug/block/scatter/0.0.1/index.ls +1 -5
  31. package/web/src/pug/block/sheet/0.0.1/index.ls +1 -5
  32. package/web/src/pug/block/table/0.0.1/index.ls +1 -5
  33. package/web/src/pug/block/taiwancounty/0.0.1/index.ls +1 -5
  34. package/web/src/pug/block/taiwantown/0.0.1/index.ls +1 -5
  35. package/web/src/pug/block/taiwanvillage/0.0.1/index.ls +1 -5
  36. package/web/src/pug/block/treemap/0.0.1/index.ls +1 -5
  37. package/web/src/pug/block/voronoi-treemap/0.0.1/index.ls +1 -5
  38. package/web/src/pug/block/wordcloud/0.0.1/index.ls +1 -5
  39. package/web/src/pug/block/worldmap/0.0.1/index.ls +1 -5
  40. package/web/src/styl/index.styl +6 -0
  41. package/web/static/block/axis/0.0.1/index.html +68 -73
  42. package/web/static/block/axis-bubble/0.0.1/index.html +205 -210
  43. package/web/static/block/bar/0.0.1/index.html +484 -489
  44. package/web/static/block/bar-list/0.0.1/index.html +188 -193
  45. package/web/static/block/bar-race/0.0.1/index.html +155 -160
  46. package/web/static/block/base/0.0.1/index.html +2 -2
  47. package/web/static/block/blank/0.0.1/index.html +35 -40
  48. package/web/static/block/bubble/0.0.1/index.html +377 -357
  49. package/web/static/block/curve-bar/0.0.1/index.html +126 -131
  50. package/web/static/block/dumbbell/0.0.1/index.html +160 -165
  51. package/web/static/block/empty/0.0.1/index.html +2 -2
  52. package/web/static/block/gauge/0.0.1/index.html +116 -121
  53. package/web/static/block/line/0.0.1/index.html +502 -507
  54. package/web/static/block/number/0.0.1/index.html +123 -128
  55. package/web/static/block/percent-list/0.0.1/index.html +263 -268
  56. package/web/static/block/pie/0.0.1/index.html +241 -246
  57. package/web/static/block/pie-bubble/0.0.1/index.html +295 -300
  58. package/web/static/block/radar/0.0.1/index.html +137 -142
  59. package/web/static/block/scatter/0.0.1/index.html +207 -212
  60. package/web/static/block/sheet/0.0.1/index.html +93 -98
  61. package/web/static/block/table/0.0.1/index.html +64 -70
  62. package/web/static/block/taiwancounty/0.0.1/index.html +180 -185
  63. package/web/static/block/taiwantown/0.0.1/index.html +104 -109
  64. package/web/static/block/taiwanvillage/0.0.1/index.html +114 -119
  65. package/web/static/block/treemap/0.0.1/index.html +296 -301
  66. package/web/static/block/voronoi-treemap/0.0.1/index.html +311 -316
  67. package/web/static/block/wordcloud/0.0.1/index.html +82 -87
  68. package/web/static/block/worldmap/0.0.1/index.html +186 -191
  69. package/web/static/css/index.css +6 -0
  70. package/web/static/css/index.min.css +1 -0
  71. package/web/static/index.html +1 -1
@@ -1,6 +1,4 @@
1
- <-(->it!) _
2
-
3
- block-factory =
1
+ module.exports =
4
2
  pkg:
5
3
  name: 'voronoi-treemap', version: '0.0.1'
6
4
  extend: {name: "base", version: "0.0.1"}
@@ -170,5 +168,3 @@ mod = ({context}) ->
170
168
  if @count < 100 =>
171
169
  @treemap.compute!
172
170
  @render true
173
-
174
- return block-factory
@@ -1,6 +1,4 @@
1
- <- (->it!) _
2
-
3
- block-factory =
1
+ module.exports =
4
2
  pkg:
5
3
  name: 'wordcloud', version: '0.0.1'
6
4
  extend: {name: "base", version: "0.0.1"}
@@ -57,5 +55,3 @@ mod = ({context, root}) ->
57
55
  .attr \fill, -> color vscale it.value
58
56
  .text -> it.text
59
57
  tick: ->
60
-
61
- return block-factory
@@ -1,6 +1,4 @@
1
- <-(->it!) _
2
-
3
- block-factory =
1
+ module.exports =
4
2
  pkg:
5
3
  name: 'worldmap', version: '0.0.1'
6
4
  extend: {name: "base", version: "0.0.1"}
@@ -77,5 +75,3 @@ mod = ({context}) ->
77
75
  .transition!duration 350
78
76
  .attr \fill, (d,i) ~> @scale.color d.properties.value
79
77
  .attr \fill-opacity, (d,i) ~> if @cfg.dim-empty => (if d.properties.value => 1 else 0.2) else 1
80
-
81
- return block-factory
@@ -0,0 +1,6 @@
1
+ @font-face
2
+ font-family: 'ldi'
3
+ font-weight: normal
4
+ font-style: normal
5
+ src: url('/assets/lib/ldiconfont/main/ldif.ttf') format('truetype')
6
+
@@ -1,79 +1,74 @@
1
- <div><script type="@plotdb/block">(function(it){
2
- return it();
3
- })(function(){
4
- var blockFactory, mod;
5
- blockFactory = {
6
- pkg: {
7
- name: 'axis',
8
- version: '0.0.1',
9
- extend: {
10
- name: "base",
11
- version: "0.0.1"
12
- },
13
- dependencies: []
1
+ <div><script type="@plotdb/block">var mod;
2
+ module.exports = {
3
+ pkg: {
4
+ name: 'axis',
5
+ version: '0.0.1',
6
+ extend: {
7
+ name: "base",
8
+ version: "0.0.1"
14
9
  },
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
- }).then(function(it){
23
- return it[0];
24
- });
25
- }
26
- };
27
- mod = function(arg$){
28
- var context, d3, forceBoundary, ldcolor, repeatString$, infinite;
29
- context = arg$.context;
30
- d3 = context.d3, forceBoundary = context.forceBoundary, ldcolor = context.ldcolor, repeatString$ = context.repeatString$, infinite = context.infinite;
31
- return {
32
- sample: function(){
33
- return {
34
- raw: [0, 1, 2, 3, 4, 5, 6, 7].map(function(val){
35
- return {
36
- val: val,
37
- name: val
38
- };
39
- }),
40
- binding: {
41
- name: {
42
- key: 'name'
43
- },
44
- value: {
45
- key: 'val'
46
- }
10
+ dependencies: []
11
+ },
12
+ init: function(arg$){
13
+ var root, context, pubsub;
14
+ root = arg$.root, context = arg$.context, pubsub = arg$.pubsub;
15
+ return pubsub.fire('init', {
16
+ mod: mod({
17
+ context: context
18
+ })
19
+ }).then(function(it){
20
+ return it[0];
21
+ });
22
+ }
23
+ };
24
+ mod = function(arg$){
25
+ var context, d3, forceBoundary, ldcolor, repeatString$, infinite;
26
+ context = arg$.context;
27
+ d3 = context.d3, forceBoundary = context.forceBoundary, ldcolor = context.ldcolor, repeatString$ = context.repeatString$, infinite = context.infinite;
28
+ return {
29
+ sample: function(){
30
+ return {
31
+ raw: [0, 1, 2, 3, 4, 5, 6, 7].map(function(val){
32
+ return {
33
+ val: val,
34
+ name: val
35
+ };
36
+ }),
37
+ binding: {
38
+ name: {
39
+ key: 'name'
40
+ },
41
+ value: {
42
+ key: 'val'
47
43
  }
48
- };
49
- },
50
- config: {},
51
- dimension: {
52
- value: {
53
- type: 'R',
54
- name: "value"
55
- },
56
- name: {
57
- type: 'N',
58
- name: "name"
59
44
  }
45
+ };
46
+ },
47
+ config: {},
48
+ dimension: {
49
+ value: {
50
+ type: 'R',
51
+ name: "value"
60
52
  },
61
- init: function(){
62
- this.ab = d3.axisBottom();
63
- this.scale = {
64
- x: d3.scaleLinear()
65
- };
66
- return this.g = d3.select(this.svg).append('g');
67
- },
68
- parse: function(){},
69
- resize: function(){
70
- this.scale.x.domain([0, 20]).range([20, this.box.width - 20]);
71
- return this.ab.scale(this.scale.x).tickValues([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]);
72
- },
73
- render: function(){
74
- return this.g.call(this.ab);
53
+ name: {
54
+ type: 'N',
55
+ name: "name"
75
56
  }
76
- };
57
+ },
58
+ init: function(){
59
+ this.ab = d3.axisBottom();
60
+ this.scale = {
61
+ x: d3.scaleLinear()
62
+ };
63
+ return this.g = d3.select(this.svg).append('g');
64
+ },
65
+ parse: function(){},
66
+ resize: function(){
67
+ this.scale.x.domain([0, 20]).range([20, this.box.width - 20]);
68
+ return this.ab.scale(this.scale.x).tickValues([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]);
69
+ },
70
+ render: function(){
71
+ return this.g.call(this.ab);
72
+ }
77
73
  };
78
- return blockFactory;
79
- });</script></div>
74
+ };</script></div>
@@ -1,222 +1,217 @@
1
- <div><script type="@plotdb/block">(function(it){
2
- return it();
3
- })(function(){
4
- var blockFactory, mod;
5
- blockFactory = {
6
- pkg: {
7
- name: 'axis-bubble',
8
- version: '0.0.1',
9
- extend: {
10
- name: "base",
11
- version: "0.0.1"
12
- },
13
- dependencies: []
1
+ <div><script type="@plotdb/block">var mod;
2
+ module.exports = {
3
+ pkg: {
4
+ name: 'axis-bubble',
5
+ version: '0.0.1',
6
+ extend: {
7
+ name: "base",
8
+ version: "0.0.1"
14
9
  },
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
- }).then(function(it){
23
- return it[0];
24
- });
25
- }
26
- };
27
- mod = function(arg$){
28
- var context, d3, forceBoundary, ldcolor, repeatString$;
29
- context = arg$.context;
30
- d3 = context.d3, forceBoundary = context.forceBoundary, ldcolor = context.ldcolor, repeatString$ = context.repeatString$;
31
- return {
32
- sample: function(){
33
- return {
34
- raw: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200].map(function(val){
35
- return {
36
- val: Math.random() * 50 + 10,
37
- x: Math.random(),
38
- cat: Math.ceil(5 * Math.random())
39
- };
40
- }),
41
- binding: {
42
- color: {
43
- key: 'cat'
44
- },
45
- radius: {
46
- key: 'val'
47
- },
48
- xpos: {
49
- key: 'x'
50
- }
10
+ dependencies: []
11
+ },
12
+ init: function(arg$){
13
+ var root, context, pubsub;
14
+ root = arg$.root, context = arg$.context, pubsub = arg$.pubsub;
15
+ return pubsub.fire('init', {
16
+ mod: mod({
17
+ context: context
18
+ })
19
+ }).then(function(it){
20
+ return it[0];
21
+ });
22
+ }
23
+ };
24
+ mod = function(arg$){
25
+ var context, d3, forceBoundary, ldcolor, repeatString$;
26
+ context = arg$.context;
27
+ d3 = context.d3, forceBoundary = context.forceBoundary, ldcolor = context.ldcolor, repeatString$ = context.repeatString$;
28
+ return {
29
+ sample: function(){
30
+ return {
31
+ raw: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200].map(function(val){
32
+ return {
33
+ val: Math.random() * 50 + 10,
34
+ x: Math.random(),
35
+ cat: Math.ceil(5 * Math.random())
36
+ };
37
+ }),
38
+ binding: {
39
+ color: {
40
+ key: 'cat'
41
+ },
42
+ radius: {
43
+ key: 'val'
44
+ },
45
+ xpos: {
46
+ key: 'x'
51
47
  }
52
- };
53
- },
54
- config: {},
55
- dimension: {
56
- color: {
57
- type: 'R',
58
- name: "顏色"
59
- },
60
- radius: {
61
- type: 'R',
62
- name: "半徑"
63
- },
64
- xpos: {
65
- type: 'R',
66
- name: "X座標"
67
48
  }
49
+ };
50
+ },
51
+ config: {},
52
+ dimension: {
53
+ color: {
54
+ type: 'R',
55
+ name: "顏色"
68
56
  },
69
- init: function(){
70
- var t, this$ = this;
71
- this.svg.addEventListener('click', function(){
72
- this$.type = !this$.type;
73
- this$.resize();
74
- this$.render();
75
- this$.sim.stop();
76
- return this$.sim.alpha(0.9);
77
- });
78
- this.svg.appendChild(t = document.createElementNS('http://www.w3.org/2000/svg', 'text'));
79
- this.text = d3.select(t);
80
- return this.text.attr('x', 20).attr('y', 20);
81
- },
82
- parse: function(){
83
- this.xextent = d3.extent(this.data.map(function(it){
84
- return it.xpos;
85
- }));
86
- this.rextent = d3.extent(this.data.map(function(it){
87
- return it.radius;
88
- }));
89
- return this.cextent = d3.extent(this.data.map(function(it){
90
- return it.color;
91
- }));
92
- },
93
- resize: function(){
94
- var rng, this$ = this;
95
- rng = d3.randomUniform.source(d3.randomLcg(root.seed))(0, 1);
96
- this.scaleX = d3.scaleLinear().domain(this.xextent).range([0, this.box.width]);
97
- if (this.type) {
98
- this.scaleY = d3.scaleLinear().domain(this.cextent).range([0, this.box.height]);
99
- } else {
100
- this.scaleY = function(){
101
- return this$.box.height / 2;
102
- };
103
- }
104
- this.data.map(function(v){
105
- return v.x = v.x || this$.scaleX(v.xpos), v.y = v.y || this$.box.height / 2, v.ty = this$.scaleY(v.color), v.val = v.radius, v.r = v.radius, v.c = v.color, v;
106
- });
107
- this.area = this.box.width * this.box.height;
108
- return this.rate = 0.5;
57
+ radius: {
58
+ type: 'R',
59
+ name: "半徑"
109
60
  },
110
- render: function(){
111
- var rate, pal, intColor, x$, y$, this$ = this;
112
- rate = this.rate;
113
- this.scale = {
114
- color: d3.interpolateTurbo,
115
- r: d3.scaleLinear().domain(this.rextent).range([0, 1]),
116
- c: d3.scaleLinear().domain(this.cextent).range([0, 1])
117
- };
118
- pal = this.cfg.palette
119
- ? this.cfg.palette.colors.map(function(it){
120
- return ldcolor.web(it.value || it);
121
- })
122
- : ['#f00', '#0f0', '#00f', '#f90', '#9f0', '#0f9'];
123
- intColor = d3.interpolateDiscrete(pal);
124
- this.scale.color = function(it){
125
- return intColor(this$.scale.c(it));
61
+ xpos: {
62
+ type: 'R',
63
+ name: "X座標"
64
+ }
65
+ },
66
+ init: function(){
67
+ var t, this$ = this;
68
+ this.svg.addEventListener('click', function(){
69
+ this$.type = !this$.type;
70
+ this$.resize();
71
+ this$.render();
72
+ this$.sim.stop();
73
+ return this$.sim.alpha(0.9);
74
+ });
75
+ this.svg.appendChild(t = document.createElementNS('http://www.w3.org/2000/svg', 'text'));
76
+ this.text = d3.select(t);
77
+ return this.text.attr('x', 20).attr('y', 20);
78
+ },
79
+ parse: function(){
80
+ this.xextent = d3.extent(this.data.map(function(it){
81
+ return it.xpos;
82
+ }));
83
+ this.rextent = d3.extent(this.data.map(function(it){
84
+ return it.radius;
85
+ }));
86
+ return this.cextent = d3.extent(this.data.map(function(it){
87
+ return it.color;
88
+ }));
89
+ },
90
+ resize: function(){
91
+ var rng, this$ = this;
92
+ rng = d3.randomUniform.source(d3.randomLcg(root.seed))(0, 1);
93
+ this.scaleX = d3.scaleLinear().domain(this.xextent).range([0, this.box.width]);
94
+ if (this.type) {
95
+ this.scaleY = d3.scaleLinear().domain(this.cextent).range([0, this.box.height]);
96
+ } else {
97
+ this.scaleY = function(){
98
+ return this$.box.height / 2;
126
99
  };
127
- x$ = d3.select(this.svg).selectAll('circle.bubble').data(this.data);
128
- x$.exit().remove();
129
- x$.enter().append('circle').attr('class', 'bubble').attr('r', function(d, i){
130
- return 0;
131
- }).attr('fill', function(d, i){
132
- return this$.scale.color(d.c);
133
- });
134
- d3.select(this.svg).selectAll('circle.bubble').attr('cx', function(d, i){
135
- return d.x;
136
- }).attr('cy', function(d, i){
137
- return d.y;
138
- }).attr('fill', function(d, i){
139
- return this$.scale.color(d.c);
140
- }).attr('r', function(d, i){
141
- var ref$;
142
- return ((ref$ = d.r) > 2 ? ref$ : 2) * this$.rate;
143
- });
144
- y$ = d3.select(this.svg).selectAll('g.label').data(this.data);
145
- y$.exit().remove();
146
- y$.enter().append('g').attr('class', 'label').each(function(d, i){
147
- var this$ = this;
148
- return [0].map(function(){
149
- return d3.select(this$).append('text');
150
- }).map(function(it){
151
- return it.attr('dy', '-.28em').attr('text-anchor', 'middle').attr('font-size', '.7em').attr('font-family', 'Rubik').style('pointer-event', 'none');
152
- });
100
+ }
101
+ this.data.map(function(v){
102
+ return v.x = v.x || this$.scaleX(v.xpos), v.y = v.y || this$.box.height / 2, v.ty = this$.scaleY(v.color), v.val = v.radius, v.r = v.radius, v.c = v.color, v;
103
+ });
104
+ this.area = this.box.width * this.box.height;
105
+ return this.rate = 0.5;
106
+ },
107
+ render: function(){
108
+ var rate, pal, intColor, x$, y$, this$ = this;
109
+ rate = this.rate;
110
+ this.scale = {
111
+ color: d3.interpolateTurbo,
112
+ r: d3.scaleLinear().domain(this.rextent).range([0, 1]),
113
+ c: d3.scaleLinear().domain(this.cextent).range([0, 1])
114
+ };
115
+ pal = this.cfg.palette
116
+ ? this.cfg.palette.colors.map(function(it){
117
+ return ldcolor.web(it.value || it);
118
+ })
119
+ : ['#f00', '#0f0', '#00f', '#f90', '#9f0', '#0f9'];
120
+ intColor = d3.interpolateDiscrete(pal);
121
+ this.scale.color = function(it){
122
+ return intColor(this$.scale.c(it));
123
+ };
124
+ x$ = d3.select(this.svg).selectAll('circle.bubble').data(this.data);
125
+ x$.exit().remove();
126
+ x$.enter().append('circle').attr('class', 'bubble').attr('r', function(d, i){
127
+ return 0;
128
+ }).attr('fill', function(d, i){
129
+ return this$.scale.color(d.c);
130
+ });
131
+ d3.select(this.svg).selectAll('circle.bubble').attr('cx', function(d, i){
132
+ return d.x;
133
+ }).attr('cy', function(d, i){
134
+ return d.y;
135
+ }).attr('fill', function(d, i){
136
+ return this$.scale.color(d.c);
137
+ }).attr('r', function(d, i){
138
+ var ref$;
139
+ return ((ref$ = d.r) > 2 ? ref$ : 2) * this$.rate;
140
+ });
141
+ y$ = d3.select(this.svg).selectAll('g.label').data(this.data);
142
+ y$.exit().remove();
143
+ y$.enter().append('g').attr('class', 'label').each(function(d, i){
144
+ var this$ = this;
145
+ return [0].map(function(){
146
+ return d3.select(this$).append('text');
147
+ }).map(function(it){
148
+ return it.attr('dy', '-.28em').attr('text-anchor', 'middle').attr('font-size', '.7em').attr('font-family', 'Rubik').style('pointer-event', 'none');
153
149
  });
154
- return d3.select(this.svg).selectAll('g.label').attr('transform', function(d, i){
155
- return "translate(" + d.x + "," + d.y + ")";
156
- }).each(function(d, i){
157
- return d3.select(this).selectAll('text').attr('opacity', d.r * 2 * rate < (d.val.toFixed(2) + "").length * 7 ? 0 : 1).attr('dy', function(e, i){
158
- return '.38em';
159
- }).text(function(e, i){
160
- if (i === 0) {
161
- if (d.val > 1000000) {
162
- return (d.val / 1000000).toFixed(2) + "M";
163
- } else if (d.val > 1000) {
164
- return (d.val / 1000).toFixed(2) + "K";
165
- } else {
166
- return d.val.toFixed(2);
167
- }
150
+ });
151
+ return d3.select(this.svg).selectAll('g.label').attr('transform', function(d, i){
152
+ return "translate(" + d.x + "," + d.y + ")";
153
+ }).each(function(d, i){
154
+ return d3.select(this).selectAll('text').attr('opacity', d.r * 2 * rate < (d.val.toFixed(2) + "").length * 7 ? 0 : 1).attr('dy', function(e, i){
155
+ return '.38em';
156
+ }).text(function(e, i){
157
+ if (i === 0) {
158
+ if (d.val > 1000000) {
159
+ return (d.val / 1000000).toFixed(2) + "M";
160
+ } else if (d.val > 1000) {
161
+ return (d.val / 1000).toFixed(2) + "K";
168
162
  } else {
169
- return d._idx;
163
+ return d.val.toFixed(2);
170
164
  }
171
- });
172
- });
173
- },
174
- tick: function(){
175
- var kickoff, fc, alpha, this$ = this;
176
- if (!this.sim) {
177
- kickoff = true;
178
- this.fc = fc = d3.forceCollide();
179
- this.sim = d3.forceSimulation().force('center', this.fg = d3.forceCenter(this.box.width / 2, this.box.height / 2)).force('x', this.fx = d3.forceX(this.box.width / 2).strength(0.15)).force('y', this.fy = d3.forceY(this.box.height / 2).strength(0.1)).force('b', this.fb = forceBoundary(function(it){
180
- return it.r;
181
- }, function(it){
182
- return it.r;
183
- }, function(it){
184
- return this$.box.width - it.r;
185
- }, function(it){
186
- return this$.box.height - it.r;
187
- })).force('collide', fc);
188
- this.sim.stop();
189
- this.sim.alpha(0.9);
190
- this.sim.nodes(this.data);
191
- }
192
- this.fc.strength(1.0);
193
- this.fc.radius(function(it){
194
- return this$.rate * it.r + 2;
195
- });
196
- this.fg.x(this.box.width / 2);
197
- this.fg.y(this.box.height / 2);
198
- this.fx.strength(0.15);
199
- this.fy.strength(0.01);
200
- this.sim.tick(kickoff ? 20 : 1);
201
- alpha = this.sim.alpha();
202
- this.text.text(alpha);
203
- if (alpha < 0.001) {
204
- this.stop();
205
- }
206
- this.data.map(function(it){
207
- return it.y = it.y + (it.ty - it.y) * alpha * 0.1;
208
- });
209
- d3.select(this.svg).selectAll('circle.bubble').attr('cx', function(d, i){
210
- return d.x;
211
- }).attr('cy', function(d, i){
212
- return d.y;
213
- });
214
- d3.select(this.svg).selectAll('g.label').attr('transform', function(d, i){
215
- return "translate(" + d.x + "," + d.y + ")";
165
+ } else {
166
+ return d._idx;
167
+ }
216
168
  });
217
- return this.render();
169
+ });
170
+ },
171
+ tick: function(){
172
+ var kickoff, fc, alpha, this$ = this;
173
+ if (!this.sim) {
174
+ kickoff = true;
175
+ this.fc = fc = d3.forceCollide();
176
+ this.sim = d3.forceSimulation().force('center', this.fg = d3.forceCenter(this.box.width / 2, this.box.height / 2)).force('x', this.fx = d3.forceX(this.box.width / 2).strength(0.15)).force('y', this.fy = d3.forceY(this.box.height / 2).strength(0.1)).force('b', this.fb = forceBoundary(function(it){
177
+ return it.r;
178
+ }, function(it){
179
+ return it.r;
180
+ }, function(it){
181
+ return this$.box.width - it.r;
182
+ }, function(it){
183
+ return this$.box.height - it.r;
184
+ })).force('collide', fc);
185
+ this.sim.stop();
186
+ this.sim.alpha(0.9);
187
+ this.sim.nodes(this.data);
218
188
  }
219
- };
189
+ this.fc.strength(1.0);
190
+ this.fc.radius(function(it){
191
+ return this$.rate * it.r + 2;
192
+ });
193
+ this.fg.x(this.box.width / 2);
194
+ this.fg.y(this.box.height / 2);
195
+ this.fx.strength(0.15);
196
+ this.fy.strength(0.01);
197
+ this.sim.tick(kickoff ? 20 : 1);
198
+ alpha = this.sim.alpha();
199
+ this.text.text(alpha);
200
+ if (alpha < 0.001) {
201
+ this.stop();
202
+ }
203
+ this.data.map(function(it){
204
+ return it.y = it.y + (it.ty - it.y) * alpha * 0.1;
205
+ });
206
+ d3.select(this.svg).selectAll('circle.bubble').attr('cx', function(d, i){
207
+ return d.x;
208
+ }).attr('cy', function(d, i){
209
+ return d.y;
210
+ });
211
+ d3.select(this.svg).selectAll('g.label').attr('transform', function(d, i){
212
+ return "translate(" + d.x + "," + d.y + ")";
213
+ });
214
+ return this.render();
215
+ }
220
216
  };
221
- return blockFactory;
222
- });</script></div>
217
+ };</script></div>