@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,73 +1,67 @@
1
- <div style="height:100%"><plug name="layout"></plug><script type="@plotdb/block">(function(it){
2
- return it();
3
- })(function(){
4
- var blockFactory;
5
- blockFactory = {
6
- pkg: {
7
- name: 'table',
8
- version: '0.0.1',
9
- extend: {
10
- name: "empty",
11
- version: "0.0.1"
12
- },
13
- dependencies: [
14
- {
15
- url: "/assets/lib/gridjs/main/gridjs.production.min.js"
16
- }, {
17
- url: "/assets/lib/gridjs/main/theme/mermaid.min.css"
18
- }
19
- ]
1
+ <div style="height:100%"><plug name="layout"></plug><script type="@plotdb/block">module.exports = {
2
+ pkg: {
3
+ name: 'table',
4
+ version: '0.0.1',
5
+ extend: {
6
+ name: "empty",
7
+ version: "0.0.1"
20
8
  },
21
- init: function(arg$){
22
- var root, context, pubsub, gridjs;
23
- root = arg$.root, context = arg$.context, pubsub = arg$.pubsub;
24
- gridjs = context.gridjs;
25
- return pubsub.fire('init', {
26
- layout: false,
27
- prepareSvg: false,
28
- mod: {
29
- init: function(){
30
- var grid;
31
- this.grid = grid = new gridjs.Grid({
32
- columns: [' ', ' ', ' ', ' ', ' '],
33
- height: this.root.getBoundingClientRect().height + "px",
34
- fixedHeader: true,
35
- sort: true,
36
- search: false,
37
- resizable: true,
38
- data: [].concat([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(function(){
39
- return [];
40
- }))
41
- });
42
- return grid.render(this.root);
43
- },
44
- parse: function(){
45
- var head, res$, k, raw;
46
- res$ = [];
47
- for (k in this.raw[0] || {}) {
48
- res$.push(k);
49
- }
50
- head = res$;
51
- head.length;
52
- raw = this.raw;
53
- console.log(raw);
54
- return;
55
- return this.grid.updateConfig({
56
- columns: raw[0],
57
- data: raw.slice(1).concat((function(){
58
- var i$, to$, ref$, results$ = [];
59
- for (i$ = 0, to$ = (ref$ = 20 - raw.length) > 0 ? ref$ : 0; i$ <= to$; ++i$) {
60
- results$.push(i$);
61
- }
62
- return results$;
63
- }()).map(function(){
64
- return [];
65
- }))
66
- }).forceRender();
9
+ dependencies: [
10
+ {
11
+ url: "/assets/lib/gridjs/main/gridjs.production.min.js"
12
+ }, {
13
+ url: "/assets/lib/gridjs/main/theme/mermaid.min.css"
14
+ }
15
+ ]
16
+ },
17
+ init: function(arg$){
18
+ var root, context, pubsub, gridjs;
19
+ root = arg$.root, context = arg$.context, pubsub = arg$.pubsub;
20
+ gridjs = context.gridjs;
21
+ return pubsub.fire('init', {
22
+ layout: false,
23
+ prepareSvg: false,
24
+ mod: {
25
+ init: function(){
26
+ var grid;
27
+ this.grid = grid = new gridjs.Grid({
28
+ columns: [' ', ' ', ' ', ' ', ' '],
29
+ height: this.root.getBoundingClientRect().height + "px",
30
+ fixedHeader: true,
31
+ sort: true,
32
+ search: false,
33
+ resizable: true,
34
+ data: [].concat([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(function(){
35
+ return [];
36
+ }))
37
+ });
38
+ return grid.render(this.root);
39
+ },
40
+ parse: function(){
41
+ var head, res$, k, raw;
42
+ res$ = [];
43
+ for (k in this.raw[0] || {}) {
44
+ res$.push(k);
67
45
  }
46
+ head = res$;
47
+ head.length;
48
+ raw = this.raw;
49
+ console.log(raw);
50
+ return;
51
+ return this.grid.updateConfig({
52
+ columns: raw[0],
53
+ data: raw.slice(1).concat((function(){
54
+ var i$, to$, ref$, results$ = [];
55
+ for (i$ = 0, to$ = (ref$ = 20 - raw.length) > 0 ? ref$ : 0; i$ <= to$; ++i$) {
56
+ results$.push(i$);
57
+ }
58
+ return results$;
59
+ }()).map(function(){
60
+ return [];
61
+ }))
62
+ }).forceRender();
68
63
  }
69
- });
70
- }
71
- };
72
- return blockFactory;
73
- });</script></div>
64
+ }
65
+ });
66
+ }
67
+ };</script></div>
@@ -2,201 +2,196 @@
2
2
  display: grid;
3
3
  grid-template-columns: 1fr fit-content(5em);
4
4
  }
5
- </style><script type="@plotdb/block">(function(it){
6
- return it();
7
- })(function(){
8
- var blockFactory, mod;
9
- blockFactory = {
10
- pkg: {
11
- name: 'taiwancounty',
12
- version: '0.0.1',
13
- extend: {
14
- name: "base",
15
- version: "0.0.1"
16
- },
17
- dependencies: [
18
- {
19
- url: "https://d3js.org/topojson.v2.min.js",
20
- async: false
21
- }, {
22
- url: "https://d3js.org/d3-geo.v2.min.js",
23
- async: false
24
- }, {
25
- name: "pdmaptw",
26
- version: "local",
27
- path: "index.min.js",
28
- async: false
29
- }, {
30
- name: "pdmaptw",
31
- version: "local",
32
- path: "county.map.js"
33
- }
34
- ]
5
+ </style><script type="@plotdb/block">var mod;
6
+ module.exports = {
7
+ pkg: {
8
+ name: 'taiwancounty',
9
+ version: '0.0.1',
10
+ extend: {
11
+ name: "base",
12
+ version: "0.0.1"
35
13
  },
36
- init: function(arg$){
37
- var root, context, pubsub;
38
- root = arg$.root, context = arg$.context, pubsub = arg$.pubsub;
39
- return pubsub.fire('init', {
40
- mod: mod({
41
- context: context
42
- })
43
- }).then(function(it){
44
- return it[0];
45
- });
46
- }
47
- };
48
- mod = function(arg$){
49
- var context, chart, d3, ldcolor, pdmaptw, topojson;
50
- context = arg$.context;
51
- chart = context.chart, d3 = context.d3, ldcolor = context.ldcolor, pdmaptw = context.pdmaptw, topojson = context.topojson;
52
- return {
53
- sample: function(){
54
- return pdmaptw.get('county').then(function(arg$){
55
- var meta, topo;
56
- meta = arg$.meta, topo = arg$.topo;
57
- return {
58
- raw: meta.name.map(function(it){
59
- return {
60
- val: Math.random(),
61
- name: pdmaptw.normalize(it)
62
- };
63
- }),
64
- binding: {
65
- color: {
66
- key: 'val'
67
- },
68
- name: {
69
- key: 'name'
70
- }
71
- }
72
- };
73
- });
74
- },
75
- config: {
76
- palette: {
77
- type: 'palette'
78
- }
79
- },
80
- dimension: {
81
- name: {
82
- type: 'N',
83
- name: "國家"
84
- },
85
- color: {
86
- type: 'R',
87
- name: "顏色"
88
- }
89
- },
90
- init: function(){
91
- var scale, this$ = this;
92
- this.g = this.layout.getGroup('view');
93
- this.obj = new pdmaptw({
94
- root: this.g,
95
- type: 'county'
96
- });
97
- this.scale = scale = {
98
- color: d3.interpolateTurbo
99
- };
100
- this.legend = new chart.utils.legend({
101
- root: this.root,
102
- name: 'legend',
103
- layout: this.layout,
104
- shape: function(d){
105
- return d3.select(this).attr('fill', scale.color(d.key));
106
- }
107
- });
108
- this.tip = new chart.utils.tip({
109
- root: this.root,
110
- accessor: function(arg$){
111
- var evt, data;
112
- evt = arg$.evt;
113
- if (!(evt.target && (data = d3.select(evt.target).datum()))) {
114
- return null;
115
- }
14
+ dependencies: [
15
+ {
16
+ url: "https://d3js.org/topojson.v2.min.js",
17
+ async: false
18
+ }, {
19
+ url: "https://d3js.org/d3-geo.v2.min.js",
20
+ async: false
21
+ }, {
22
+ name: "pdmaptw",
23
+ version: "local",
24
+ path: "index.min.js",
25
+ async: false
26
+ }, {
27
+ name: "pdmaptw",
28
+ version: "local",
29
+ path: "county.map.js"
30
+ }
31
+ ]
32
+ },
33
+ init: function(arg$){
34
+ var root, context, pubsub;
35
+ root = arg$.root, context = arg$.context, pubsub = arg$.pubsub;
36
+ return pubsub.fire('init', {
37
+ mod: mod({
38
+ context: context
39
+ })
40
+ }).then(function(it){
41
+ return it[0];
42
+ });
43
+ }
44
+ };
45
+ mod = function(arg$){
46
+ var context, chart, d3, ldcolor, pdmaptw, topojson;
47
+ context = arg$.context;
48
+ chart = context.chart, d3 = context.d3, ldcolor = context.ldcolor, pdmaptw = context.pdmaptw, topojson = context.topojson;
49
+ return {
50
+ sample: function(){
51
+ return pdmaptw.get('county').then(function(arg$){
52
+ var meta, topo;
53
+ meta = arg$.meta, topo = arg$.topo;
54
+ return {
55
+ raw: meta.name.map(function(it){
116
56
  return {
117
- name: data.data.name,
118
- value: data.data.color
57
+ val: Math.random(),
58
+ name: pdmaptw.normalize(it)
119
59
  };
120
- },
121
- range: function(){
122
- return this$.layout.getNode('view').getBoundingClientRect();
60
+ }),
61
+ binding: {
62
+ color: {
63
+ key: 'val'
64
+ },
65
+ name: {
66
+ key: 'name'
67
+ }
123
68
  }
124
- });
125
- return this.obj.init().then(function(){
126
- return this$.obj.fit({
127
- node: this$.g,
128
- box: this$.layout.getNode('view').getBoundingClientRect()
129
- });
130
- });
131
- },
132
- parse: function(){
133
- var this$ = this;
134
- this.extent = {
135
- c: [undefined, undefined]
136
69
  };
137
- return d3.select(this.svg).selectAll('path').each(function(d, i){
138
- d.data = this$.data.filter(function(it){
139
- return it.name === d.properties.name;
140
- })[0] || {};
141
- if (!(this$.extent.c[0] != null) || d.data.color < this$.extent.c[0]) {
142
- this$.extent.c[0] = d.data.color;
143
- }
144
- if (!(this$.extent.c[1] != null) || d.data.color > this$.extent.c[1]) {
145
- return this$.extent.c[1] = d.data.color;
146
- }
147
- });
70
+ });
71
+ },
72
+ config: {
73
+ palette: {
74
+ type: 'palette'
75
+ }
76
+ },
77
+ dimension: {
78
+ name: {
79
+ type: 'N',
80
+ name: "國家"
148
81
  },
149
- resize: function(){
150
- var ref$, pal, len, this$ = this;
151
- this.tip.toggle(((ref$ = this.cfg).tip || (ref$.tip = {})).enabled != null ? this.cfg.tip.enabled : true);
152
- this.obj.fit(this.layout.getBox('view'));
153
- pal = this.cfg.palette
154
- ? this.cfg.palette.colors
155
- : ['#f00', '#999', '#00f'];
156
- len = pal.length;
157
- this.ticks = d3.quantize(function(it){
158
- return (1 - it) * (this$.extent.c[1] - this$.extent.c[0]) + this$.extent.c[0];
159
- }, len).map(function(it){
160
- var that;
82
+ color: {
83
+ type: 'R',
84
+ name: "顏色"
85
+ }
86
+ },
87
+ init: function(){
88
+ var scale, this$ = this;
89
+ this.g = this.layout.getGroup('view');
90
+ this.obj = new pdmaptw({
91
+ root: this.g,
92
+ type: 'county'
93
+ });
94
+ this.scale = scale = {
95
+ color: d3.interpolateTurbo
96
+ };
97
+ this.legend = new chart.utils.legend({
98
+ root: this.root,
99
+ name: 'legend',
100
+ layout: this.layout,
101
+ shape: function(d){
102
+ return d3.select(this).attr('fill', scale.color(d.key));
103
+ }
104
+ });
105
+ this.tip = new chart.utils.tip({
106
+ root: this.root,
107
+ accessor: function(arg$){
108
+ var evt, data;
109
+ evt = arg$.evt;
110
+ if (!(evt.target && (data = d3.select(evt.target).datum()))) {
111
+ return null;
112
+ }
161
113
  return {
162
- key: it,
163
- text: d3.format(this$.cfg.legendFormat || '.2f')(it) + ((that = this$.binding.color.unit) ? that : '')
114
+ name: data.data.name,
115
+ value: data.data.color
164
116
  };
165
- });
166
- this.ticks.sort(function(a, b){
167
- return a.key - b.key;
168
- });
169
- if (this.cfg.palette) {
170
- this.scale.color = d3.scaleLinear().domain(this.ticks.map(function(it){
171
- return it.key;
172
- })).range(pal.map(function(it){
173
- return ldcolor.web(it.value || it);
174
- }));
117
+ },
118
+ range: function(){
119
+ return this$.layout.getNode('view').getBoundingClientRect();
175
120
  }
176
- this.legend.data(this.ticks);
177
- return this.obj.fit({
178
- node: this.g,
179
- box: this.layout.getBox('view')
121
+ });
122
+ return this.obj.init().then(function(){
123
+ return this$.obj.fit({
124
+ node: this$.g,
125
+ box: this$.layout.getNode('view').getBoundingClientRect()
180
126
  });
181
- },
182
- render: function(){
183
- var this$ = this;
184
- d3.select(this.svg).selectAll('path').transition().duration(350).attr('fill', function(d, i){
185
- return this$.scale.color(d.data.color);
186
- }).attr('fill-opacity', function(d, i){
187
- if (this$.cfg.dimEmpty) {
188
- if (d.data.color != null) {
189
- return 1;
190
- } else {
191
- return 0.2;
192
- }
193
- } else {
127
+ });
128
+ },
129
+ parse: function(){
130
+ var this$ = this;
131
+ this.extent = {
132
+ c: [undefined, undefined]
133
+ };
134
+ return d3.select(this.svg).selectAll('path').each(function(d, i){
135
+ d.data = this$.data.filter(function(it){
136
+ return it.name === d.properties.name;
137
+ })[0] || {};
138
+ if (!(this$.extent.c[0] != null) || d.data.color < this$.extent.c[0]) {
139
+ this$.extent.c[0] = d.data.color;
140
+ }
141
+ if (!(this$.extent.c[1] != null) || d.data.color > this$.extent.c[1]) {
142
+ return this$.extent.c[1] = d.data.color;
143
+ }
144
+ });
145
+ },
146
+ resize: function(){
147
+ var ref$, pal, len, this$ = this;
148
+ this.tip.toggle(((ref$ = this.cfg).tip || (ref$.tip = {})).enabled != null ? this.cfg.tip.enabled : true);
149
+ this.obj.fit(this.layout.getBox('view'));
150
+ pal = this.cfg.palette
151
+ ? this.cfg.palette.colors
152
+ : ['#f00', '#999', '#00f'];
153
+ len = pal.length;
154
+ this.ticks = d3.quantize(function(it){
155
+ return (1 - it) * (this$.extent.c[1] - this$.extent.c[0]) + this$.extent.c[0];
156
+ }, len).map(function(it){
157
+ var that;
158
+ return {
159
+ key: it,
160
+ text: d3.format(this$.cfg.legendFormat || '.2f')(it) + ((that = this$.binding.color.unit) ? that : '')
161
+ };
162
+ });
163
+ this.ticks.sort(function(a, b){
164
+ return a.key - b.key;
165
+ });
166
+ if (this.cfg.palette) {
167
+ this.scale.color = d3.scaleLinear().domain(this.ticks.map(function(it){
168
+ return it.key;
169
+ })).range(pal.map(function(it){
170
+ return ldcolor.web(it.value || it);
171
+ }));
172
+ }
173
+ this.legend.data(this.ticks);
174
+ return this.obj.fit({
175
+ node: this.g,
176
+ box: this.layout.getBox('view')
177
+ });
178
+ },
179
+ render: function(){
180
+ var this$ = this;
181
+ d3.select(this.svg).selectAll('path').transition().duration(350).attr('fill', function(d, i){
182
+ return this$.scale.color(d.data.color);
183
+ }).attr('fill-opacity', function(d, i){
184
+ if (this$.cfg.dimEmpty) {
185
+ if (d.data.color != null) {
194
186
  return 1;
187
+ } else {
188
+ return 0.2;
195
189
  }
196
- });
197
- return this.legend.render();
198
- }
199
- };
190
+ } else {
191
+ return 1;
192
+ }
193
+ });
194
+ return this.legend.render();
195
+ }
200
196
  };
201
- return blockFactory;
202
- });</script></div>
197
+ };</script></div>