@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,149 +1,144 @@
1
- <div><script type="@plotdb/block">(function(it){
2
- return it();
3
- })(function(){
4
- var blockFactory, mod;
5
- blockFactory = {
6
- pkg: {
7
- name: 'radar',
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: 'radar',
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].map(function(idx){
35
- return {
36
- val: [0, 1, 2].map(function(){
37
- return 0.5 + 0.5 * Math.random();
38
- }),
39
- cat: idx
40
- };
41
- }),
42
- binding: {
43
- radius: {
44
- key: 'val'
45
- },
46
- order: {
47
- key: 'cat'
48
- }
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].map(function(idx){
32
+ return {
33
+ val: [0, 1, 2].map(function(){
34
+ return 0.5 + 0.5 * Math.random();
35
+ }),
36
+ cat: idx
37
+ };
38
+ }),
39
+ binding: {
40
+ radius: {
41
+ key: 'val'
42
+ },
43
+ order: {
44
+ key: 'cat'
49
45
  }
50
- };
51
- },
52
- config: {},
53
- dimension: {
54
- radius: {
55
- type: 'R',
56
- name: "radius of point on radar line"
57
- },
58
- order: {
59
- type: 'R',
60
- name: "order of data point"
61
46
  }
47
+ };
48
+ },
49
+ config: {},
50
+ dimension: {
51
+ radius: {
52
+ type: 'R',
53
+ name: "radius of point on radar line"
62
54
  },
63
- init: function(){
64
- var svg, gs, this$ = this;
65
- svg = d3.select(this.svg);
66
- this.gs = gs = {};
67
- gs.all = svg.append('g');
68
- return this.line = d3.line().x(function(d, i){
69
- return this$.scale.r(d) * Math.cos(this$.scale.a(this$.orders[i]));
70
- }).y(function(d, i){
71
- return this$.scale.r(d) * -Math.sin(this$.scale.a(this$.orders[i]));
72
- });
73
- },
74
- parse: function(){
75
- this.orders = Array.from(new Set(this.data.map(function(it){
76
- return it.order;
77
- })));
78
- this.parsed = d3.transpose(this.data.map(function(it){
79
- return it.radius;
55
+ order: {
56
+ type: 'R',
57
+ name: "order of data point"
58
+ }
59
+ },
60
+ init: function(){
61
+ var svg, gs, this$ = this;
62
+ svg = d3.select(this.svg);
63
+ this.gs = gs = {};
64
+ gs.all = svg.append('g');
65
+ return this.line = d3.line().x(function(d, i){
66
+ return this$.scale.r(d) * Math.cos(this$.scale.a(this$.orders[i]));
67
+ }).y(function(d, i){
68
+ return this$.scale.r(d) * -Math.sin(this$.scale.a(this$.orders[i]));
69
+ });
70
+ },
71
+ parse: function(){
72
+ this.orders = Array.from(new Set(this.data.map(function(it){
73
+ return it.order;
74
+ })));
75
+ this.parsed = d3.transpose(this.data.map(function(it){
76
+ return it.radius;
77
+ }));
78
+ this.parsed.map(function(d, i){
79
+ return d.idx = i;
80
+ });
81
+ this.names = ['1', '2', '3'];
82
+ this.radiusRange = d3.extent(this.parsed.map(function(d){
83
+ return d3.extent(d);
84
+ }).reduce(function(a, b){
85
+ return a.concat(b);
86
+ }, []));
87
+ if (this.radiusRange[0] === this.radiusRange[1]) {
88
+ return this.radiusRange[1]++;
89
+ }
90
+ },
91
+ bind: function(){
92
+ var x$, y$;
93
+ x$ = this.gs.all.selectAll('path.data').data(this.parsed);
94
+ x$.exit().attr('class', "").transition('exit').duration(500).attr('opacity', 0).remove();
95
+ x$.enter().append('path').attr('class', 'data').attr('opacity', 0);
96
+ y$ = this.gs.all.selectAll('g.data-group').data(this.parsed);
97
+ y$.exit().attr('class', "").transition('exit').duration(500).attr('opacity', 0).remove();
98
+ y$.enter().append('g').attr('class', 'data-group').attr('opacity', 0);
99
+ return this.gs.all.selectAll('g.data-group').each(function(d, i){
100
+ var x$;
101
+ x$ = d3.select(this).selectAll('circle.node').data(d);
102
+ x$.exit().attr('class', '').transition('exit').duration(500).attr('opacity', 0).remove();
103
+ x$.enter().append('circle').attr('class', 'node').attr('opacity', 0);
104
+ return x$;
105
+ });
106
+ },
107
+ resize: function(){
108
+ var size, ref$;
109
+ size = (ref$ = Math.min(this.box.width, this.box.height) / 2) > 10 ? ref$ : 10;
110
+ this.scale = {
111
+ r: d3.scaleLinear().domain([0, this.radiusRange[1]]).range([0, size]),
112
+ a: d3.scalePoint().domain(this.orders).range([0, 2 * Math.PI]),
113
+ c: d3.interpolateTurbo
114
+ };
115
+ if (this.cfg != null && this.cfg.palette) {
116
+ this.scale.c = d3.interpolateDiscrete(this.cfg.palette.colors.map(function(it){
117
+ return ldColor.web(it.value || it);
80
118
  }));
81
- this.parsed.map(function(d, i){
82
- return d.idx = i;
83
- });
84
- this.names = ['1', '2', '3'];
85
- this.radiusRange = d3.extent(this.parsed.map(function(d){
86
- return d3.extent(d);
87
- }).reduce(function(a, b){
88
- return a.concat(b);
89
- }, []));
90
- if (this.radiusRange[0] === this.radiusRange[1]) {
91
- return this.radiusRange[1]++;
92
- }
93
- },
94
- bind: function(){
95
- var x$, y$;
96
- x$ = this.gs.all.selectAll('path.data').data(this.parsed);
97
- x$.exit().attr('class', "").transition('exit').duration(500).attr('opacity', 0).remove();
98
- x$.enter().append('path').attr('class', 'data').attr('opacity', 0);
99
- y$ = this.gs.all.selectAll('g.data-group').data(this.parsed);
100
- y$.exit().attr('class', "").transition('exit').duration(500).attr('opacity', 0).remove();
101
- y$.enter().append('g').attr('class', 'data-group').attr('opacity', 0);
102
- return this.gs.all.selectAll('g.data-group').each(function(d, i){
103
- var x$;
104
- x$ = d3.select(this).selectAll('circle.node').data(d);
105
- x$.exit().attr('class', '').transition('exit').duration(500).attr('opacity', 0).remove();
106
- x$.enter().append('circle').attr('class', 'node').attr('opacity', 0);
107
- return x$;
108
- });
109
- },
110
- resize: function(){
111
- var size, ref$;
112
- size = (ref$ = Math.min(this.box.width, this.box.height) / 2) > 10 ? ref$ : 10;
113
- this.scale = {
114
- r: d3.scaleLinear().domain([0, this.radiusRange[1]]).range([0, size]),
115
- a: d3.scalePoint().domain(this.orders).range([0, 2 * Math.PI]),
116
- c: d3.interpolateTurbo
117
- };
118
- if (this.cfg != null && this.cfg.palette) {
119
- this.scale.c = d3.interpolateDiscrete(this.cfg.palette.colors.map(function(it){
120
- return ldColor.web(it.value || it);
121
- }));
122
- }
123
- return this.aTicks = d3.range(this.data.length);
124
- },
125
- render: function(){
126
- var scale, names, line, orders;
127
- scale = this.scale, names = this.names, line = this.line, orders = this.orders, orders = this.orders;
128
- this.gs.all.attr('transform', "translate(" + this.box.width / 2 + "," + this.box.height / 2 + ")");
129
- this.gs.all.selectAll('path.data').each(function(d, i){
130
- var color;
131
- color = scale.c(i / (names.length - 1));
132
- return d3.select(this).attr('fill', color).attr('fill-opacity', 0.2).attr('stroke', color).attr('stroke-width', 1).transition('morph').duration(350).attr('d', function(d, i){
133
- return line(d, i) + "Z";
134
- });
135
- }).transition('opacity').duration(350).attr('opacity', 1);
136
- return this.gs.all.selectAll('g.data-group').each(function(d, i){
137
- var color;
138
- color = scale.c(i / (names.length - 1));
139
- return d3.select(this).selectAll('circle.node').attr('fill', '#fff').attr('stroke', color).attr('stroke-width', 1).transition('morph').duration(350).attr('cx', function(d, i){
140
- return scale.r(d) * Math.cos(scale.a(orders[i]));
141
- }).attr('cy', function(d, i){
142
- return scale.r(d) * -Math.sin(scale.a(orders[i]));
143
- }).attr('r', 3).attr('opacity', 1);
144
- }).transition('opacity').duration(350).attr('opacity', 1);
145
119
  }
146
- };
120
+ return this.aTicks = d3.range(this.data.length);
121
+ },
122
+ render: function(){
123
+ var scale, names, line, orders;
124
+ scale = this.scale, names = this.names, line = this.line, orders = this.orders, orders = this.orders;
125
+ this.gs.all.attr('transform', "translate(" + this.box.width / 2 + "," + this.box.height / 2 + ")");
126
+ this.gs.all.selectAll('path.data').each(function(d, i){
127
+ var color;
128
+ color = scale.c(i / (names.length - 1));
129
+ return d3.select(this).attr('fill', color).attr('fill-opacity', 0.2).attr('stroke', color).attr('stroke-width', 1).transition('morph').duration(350).attr('d', function(d, i){
130
+ return line(d, i) + "Z";
131
+ });
132
+ }).transition('opacity').duration(350).attr('opacity', 1);
133
+ return this.gs.all.selectAll('g.data-group').each(function(d, i){
134
+ var color;
135
+ color = scale.c(i / (names.length - 1));
136
+ return d3.select(this).selectAll('circle.node').attr('fill', '#fff').attr('stroke', color).attr('stroke-width', 1).transition('morph').duration(350).attr('cx', function(d, i){
137
+ return scale.r(d) * Math.cos(scale.a(orders[i]));
138
+ }).attr('cy', function(d, i){
139
+ return scale.r(d) * -Math.sin(scale.a(orders[i]));
140
+ }).attr('r', 3).attr('opacity', 1);
141
+ }).transition('opacity').duration(350).attr('opacity', 1);
142
+ }
147
143
  };
148
- return blockFactory;
149
- });</script></div>
144
+ };</script></div>