@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.
- package/CHANGELOG.md +11 -1
- package/build +11 -5
- package/dist/index.css +8 -0
- package/dist/index.js +607 -0
- package/dist/index.min.css +1 -0
- package/dist/index.min.js +1 -0
- package/package.json +12 -9
- package/src/{chart.ls → index.ls} +0 -0
- package/src/{chart.styl → index.styl} +0 -0
- package/web/src/pug/base.pug +1 -0
- package/web/src/pug/block/axis/0.0.1/index.ls +1 -7
- package/web/src/pug/block/axis-bubble/0.0.1/index.ls +1 -5
- package/web/src/pug/block/bar/0.0.1/index.ls +1 -5
- package/web/src/pug/block/bar-list/0.0.1/index.ls +1 -5
- package/web/src/pug/block/bar-race/0.0.1/index.ls +1 -5
- package/web/src/pug/block/base/0.0.1/index.ls +63 -64
- package/web/src/pug/block/blank/0.0.1/index.ls +1 -5
- package/web/src/pug/block/bubble/0.0.1/index.ls +4 -6
- package/web/src/pug/block/bubble/0.0.1/index.pug +14 -0
- package/web/src/pug/block/curve-bar/0.0.1/index.ls +1 -5
- package/web/src/pug/block/dumbbell/0.0.1/index.ls +1 -5
- package/web/src/pug/block/empty/0.0.1/index.ls +25 -24
- package/web/src/pug/block/gauge/0.0.1/index.ls +1 -5
- package/web/src/pug/block/line/0.0.1/index.ls +1 -6
- package/web/src/pug/block/number/0.0.1/index.ls +1 -5
- package/web/src/pug/block/percent-list/0.0.1/index.ls +1 -7
- package/web/src/pug/block/pie/0.0.1/index.ls +1 -5
- package/web/src/pug/block/pie-bubble/0.0.1/index.ls +1 -5
- package/web/src/pug/block/radar/0.0.1/index.ls +1 -5
- package/web/src/pug/block/scatter/0.0.1/index.ls +1 -5
- package/web/src/pug/block/sheet/0.0.1/index.ls +1 -5
- package/web/src/pug/block/table/0.0.1/index.ls +1 -5
- package/web/src/pug/block/taiwancounty/0.0.1/index.ls +1 -5
- package/web/src/pug/block/taiwantown/0.0.1/index.ls +1 -5
- package/web/src/pug/block/taiwanvillage/0.0.1/index.ls +1 -5
- package/web/src/pug/block/treemap/0.0.1/index.ls +1 -5
- package/web/src/pug/block/voronoi-treemap/0.0.1/index.ls +1 -5
- package/web/src/pug/block/wordcloud/0.0.1/index.ls +1 -5
- package/web/src/pug/block/worldmap/0.0.1/index.ls +1 -5
- package/web/src/styl/index.styl +6 -0
- package/web/static/block/axis/0.0.1/index.html +68 -73
- package/web/static/block/axis-bubble/0.0.1/index.html +205 -210
- package/web/static/block/bar/0.0.1/index.html +484 -489
- package/web/static/block/bar-list/0.0.1/index.html +188 -193
- package/web/static/block/bar-race/0.0.1/index.html +155 -160
- package/web/static/block/base/0.0.1/index.html +2 -2
- package/web/static/block/blank/0.0.1/index.html +35 -40
- package/web/static/block/bubble/0.0.1/index.html +377 -357
- package/web/static/block/curve-bar/0.0.1/index.html +126 -131
- package/web/static/block/dumbbell/0.0.1/index.html +160 -165
- package/web/static/block/empty/0.0.1/index.html +2 -2
- package/web/static/block/gauge/0.0.1/index.html +116 -121
- package/web/static/block/line/0.0.1/index.html +502 -507
- package/web/static/block/number/0.0.1/index.html +123 -128
- package/web/static/block/percent-list/0.0.1/index.html +263 -268
- package/web/static/block/pie/0.0.1/index.html +241 -246
- package/web/static/block/pie-bubble/0.0.1/index.html +295 -300
- package/web/static/block/radar/0.0.1/index.html +137 -142
- package/web/static/block/scatter/0.0.1/index.html +207 -212
- package/web/static/block/sheet/0.0.1/index.html +93 -98
- package/web/static/block/table/0.0.1/index.html +64 -70
- package/web/static/block/taiwancounty/0.0.1/index.html +180 -185
- package/web/static/block/taiwantown/0.0.1/index.html +104 -109
- package/web/static/block/taiwanvillage/0.0.1/index.html +114 -119
- package/web/static/block/treemap/0.0.1/index.html +296 -301
- package/web/static/block/voronoi-treemap/0.0.1/index.html +311 -316
- package/web/static/block/wordcloud/0.0.1/index.html +82 -87
- package/web/static/block/worldmap/0.0.1/index.html +186 -191
- package/web/static/css/index.css +6 -0
- package/web/static/css/index.min.css +1 -0
- 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">
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
name:
|
|
21
|
-
version:
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
-
|
|
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];
|