@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
@@ -11,140 +11,135 @@
11
11
  .pdl-layout > [data-type=layout] .pdl-cell[data-name=number] {
12
12
  font-weight: bold;
13
13
  }
14
- </style><script type="@plotdb/block">(function(it){
15
- return it();
16
- })(function(){
17
- var blockFactory, mod;
18
- blockFactory = {
19
- pkg: {
20
- name: 'number',
21
- version: '0.0.1',
22
- extend: {
23
- name: "base",
24
- version: "0.0.1"
25
- },
26
- dependencies: []
14
+ </style><script type="@plotdb/block">var mod;
15
+ module.exports = {
16
+ pkg: {
17
+ name: 'number',
18
+ version: '0.0.1',
19
+ extend: {
20
+ name: "base",
21
+ version: "0.0.1"
27
22
  },
28
- init: function(arg$){
29
- var root, context, pubsub;
30
- root = arg$.root, context = arg$.context, pubsub = arg$.pubsub;
31
- return pubsub.fire('init', {
32
- mod: mod({
33
- context: context
34
- })
35
- }).then(function(it){
36
- return it[0];
37
- });
38
- }
39
- };
40
- mod = function(arg$){
41
- var context, d3, ldcolor, repeatString$, infinite;
42
- context = arg$.context;
43
- d3 = context.d3, ldcolor = context.ldcolor, repeatString$ = context.repeatString$, infinite = context.infinite;
44
- return {
45
- sample: function(){
46
- return {
47
- raw: [{
48
- val: 12777216,
49
- name: "票房",
50
- unit: "新臺幣"
51
- }],
52
- binding: {
53
- name: {
54
- key: 'name'
55
- },
56
- value: {
57
- key: 'val',
58
- unit: '百萬元新臺幣'
59
- }
23
+ dependencies: []
24
+ },
25
+ init: function(arg$){
26
+ var root, context, pubsub;
27
+ root = arg$.root, context = arg$.context, pubsub = arg$.pubsub;
28
+ return pubsub.fire('init', {
29
+ mod: mod({
30
+ context: context
31
+ })
32
+ }).then(function(it){
33
+ return it[0];
34
+ });
35
+ }
36
+ };
37
+ mod = function(arg$){
38
+ var context, d3, ldcolor, repeatString$, infinite;
39
+ context = arg$.context;
40
+ d3 = context.d3, ldcolor = context.ldcolor, repeatString$ = context.repeatString$, infinite = context.infinite;
41
+ return {
42
+ sample: function(){
43
+ return {
44
+ raw: [{
45
+ val: 12777216,
46
+ name: "票房",
47
+ unit: "新臺幣"
48
+ }],
49
+ binding: {
50
+ name: {
51
+ key: 'name'
52
+ },
53
+ value: {
54
+ key: 'val',
55
+ unit: '百萬元新臺幣'
60
56
  }
61
- };
62
- },
63
- config: {
64
- enlarge: {
65
- type: 'boolean',
66
- 'default': false
67
- }
68
- },
69
- dimension: {
70
- value: {
71
- type: 'R',
72
- name: "value"
73
- },
74
- name: {
75
- type: 'N',
76
- name: "name"
77
57
  }
58
+ };
59
+ },
60
+ config: {
61
+ enlarge: {
62
+ type: 'boolean',
63
+ 'default': false
64
+ }
65
+ },
66
+ dimension: {
67
+ value: {
68
+ type: 'R',
69
+ name: "value"
78
70
  },
79
- init: function(){
80
- var this$ = this;
81
- this.n = Object.fromEntries(['number', 'unit'].map(function(it){
82
- return [it, this$.layout.getNode(it)];
83
- }));
84
- this.g = Object.fromEntries(['number', 'unit'].map(function(it){
85
- return [it, d3.select(this$.layout.getGroup(it))];
86
- }));
87
- this.g.number.append('text');
88
- this.g.unit.append('text');
89
- return this.v = {
90
- number: 0,
91
- unit: '',
92
- run: 0
93
- };
94
- },
95
- resize: function(){
96
- var ref$, w, h, x$, y$, r, this$ = this;
97
- ref$ = [this.box.width, this.box.height], w = ref$[0], h = ref$[1];
98
- this.sizeRate = {
99
- number: this.cfg.numberSizeRate || 3,
100
- unit: this.cfg.unitSizeRate || 1
101
- };
102
- import$(this.v, {
103
- number: (this.data[0] || {
104
- value: 0
105
- }).value,
106
- unit: this.binding.value.unit || (this.data[0] || {
107
- unit: ''
108
- }).unit || ''
109
- });
110
- x$ = this.n.number;
111
- x$.style.fontSize = this.sizeRate.number + "em";
112
- x$.textContent = this.v.number;
113
- y$ = this.n.unit;
114
- y$.style.fontSize = '1em';
115
- y$.textContent = this.v.unit;
116
- this.r = r = Object.fromEntries(['number', 'unit'].map(function(it){
117
- return [it, w / (this$.n[it].getBoundingClientRect().width || 1)];
118
- }));
119
- (!this.cfg.enlarge
120
- ? ['number', 'unit']
121
- : ['unit']).map(function(it){
122
- var ref$;
123
- return this$.r[it] = (ref$ = r[it]) < 1 ? ref$ : 1;
124
- });
125
- this.n.number.style.fontSize = this.sizeRate.number * r.number + "em";
126
- this.n.unit.style.fontSize = this.sizeRate.unit * r.unit + "em";
127
- return this.layout.update(false);
128
- },
129
- tick: function(){
130
- var this$ = this;
131
- return this.g.number.select('text').text(function(){
132
- this$.v.run = (this$.v.number - this$.v.run) * 0.1 + this$.v.run;
133
- if (this$.v.run === this$.v.number) {
134
- this$.stop();
135
- }
136
- return Math.round(this$.v.run);
137
- });
138
- },
139
- render: function(){
140
- this.g.number.select('text').attr('x', this.n.number.getBoundingClientRect().width / 2).attr('font-size', this.sizeRate.number * this.r.number + "em").attr('font-weight', 'bold').attr('dominant-baseline', 'hanging').attr('text-anchor', 'middle').text(this.v.run);
141
- this.g.unit.select('text').attr('font-size', this.sizeRate.unit * this.r.unit + "em").attr('dominant-baseline', 'hanging').text(this.v.unit);
142
- return this.start();
71
+ name: {
72
+ type: 'N',
73
+ name: "name"
143
74
  }
144
- };
75
+ },
76
+ init: function(){
77
+ var this$ = this;
78
+ this.n = Object.fromEntries(['number', 'unit'].map(function(it){
79
+ return [it, this$.layout.getNode(it)];
80
+ }));
81
+ this.g = Object.fromEntries(['number', 'unit'].map(function(it){
82
+ return [it, d3.select(this$.layout.getGroup(it))];
83
+ }));
84
+ this.g.number.append('text');
85
+ this.g.unit.append('text');
86
+ return this.v = {
87
+ number: 0,
88
+ unit: '',
89
+ run: 0
90
+ };
91
+ },
92
+ resize: function(){
93
+ var ref$, w, h, x$, y$, r, this$ = this;
94
+ ref$ = [this.box.width, this.box.height], w = ref$[0], h = ref$[1];
95
+ this.sizeRate = {
96
+ number: this.cfg.numberSizeRate || 3,
97
+ unit: this.cfg.unitSizeRate || 1
98
+ };
99
+ import$(this.v, {
100
+ number: (this.data[0] || {
101
+ value: 0
102
+ }).value,
103
+ unit: this.binding.value.unit || (this.data[0] || {
104
+ unit: ''
105
+ }).unit || ''
106
+ });
107
+ x$ = this.n.number;
108
+ x$.style.fontSize = this.sizeRate.number + "em";
109
+ x$.textContent = this.v.number;
110
+ y$ = this.n.unit;
111
+ y$.style.fontSize = '1em';
112
+ y$.textContent = this.v.unit;
113
+ this.r = r = Object.fromEntries(['number', 'unit'].map(function(it){
114
+ return [it, w / (this$.n[it].getBoundingClientRect().width || 1)];
115
+ }));
116
+ (!this.cfg.enlarge
117
+ ? ['number', 'unit']
118
+ : ['unit']).map(function(it){
119
+ var ref$;
120
+ return this$.r[it] = (ref$ = r[it]) < 1 ? ref$ : 1;
121
+ });
122
+ this.n.number.style.fontSize = this.sizeRate.number * r.number + "em";
123
+ this.n.unit.style.fontSize = this.sizeRate.unit * r.unit + "em";
124
+ return this.layout.update(false);
125
+ },
126
+ tick: function(){
127
+ var this$ = this;
128
+ return this.g.number.select('text').text(function(){
129
+ this$.v.run = (this$.v.number - this$.v.run) * 0.1 + this$.v.run;
130
+ if (this$.v.run === this$.v.number) {
131
+ this$.stop();
132
+ }
133
+ return Math.round(this$.v.run);
134
+ });
135
+ },
136
+ render: function(){
137
+ this.g.number.select('text').attr('x', this.n.number.getBoundingClientRect().width / 2).attr('font-size', this.sizeRate.number * this.r.number + "em").attr('font-weight', 'bold').attr('dominant-baseline', 'hanging').attr('text-anchor', 'middle').text(this.v.run);
138
+ this.g.unit.select('text').attr('font-size', this.sizeRate.unit * this.r.unit + "em").attr('dominant-baseline', 'hanging').text(this.v.unit);
139
+ return this.start();
140
+ }
145
141
  };
146
- return blockFactory;
147
- });
142
+ };
148
143
  function import$(obj, src){
149
144
  var own = {}.hasOwnProperty;
150
145
  for (var key in src) if (own.call(src, key)) obj[key] = src[key];