@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,174 +11,169 @@
|
|
|
11
11
|
grid-row: 1/span 2;
|
|
12
12
|
padding-left: 1em;
|
|
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: [],
|
|
27
|
-
i18n: {
|
|
28
|
-
"zh-TW": {
|
|
29
|
-
"height": "高度"
|
|
30
|
-
}
|
|
31
|
-
}
|
|
14
|
+
</style><script type="@plotdb/block">var mod;
|
|
15
|
+
module.exports = {
|
|
16
|
+
pkg: {
|
|
17
|
+
name: 'bar-race',
|
|
18
|
+
version: '0.0.1',
|
|
19
|
+
extend: {
|
|
20
|
+
name: "base",
|
|
21
|
+
version: "0.0.1"
|
|
32
22
|
},
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
context: context,
|
|
39
|
-
t: t
|
|
40
|
-
})
|
|
41
|
-
});
|
|
23
|
+
dependencies: [],
|
|
24
|
+
i18n: {
|
|
25
|
+
"zh-TW": {
|
|
26
|
+
"height": "高度"
|
|
27
|
+
}
|
|
42
28
|
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
var context, t,
|
|
46
|
-
context = arg$.context, t = arg$.t;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
29
|
+
},
|
|
30
|
+
init: function(arg$){
|
|
31
|
+
var root, context, t, pubsub;
|
|
32
|
+
root = arg$.root, context = arg$.context, t = arg$.t, pubsub = arg$.pubsub;
|
|
33
|
+
return pubsub.fire('init', {
|
|
34
|
+
mod: mod({
|
|
35
|
+
context: context,
|
|
36
|
+
t: t
|
|
37
|
+
})
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
mod = function(arg$){
|
|
42
|
+
var context, t, chart, d3, debounce;
|
|
43
|
+
context = arg$.context, t = arg$.t;
|
|
44
|
+
chart = context.chart, d3 = context.d3, debounce = context.debounce;
|
|
45
|
+
return {
|
|
46
|
+
sample: function(){
|
|
47
|
+
return {
|
|
48
|
+
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].map(function(val){
|
|
49
|
+
var ref$, n, o, ret;
|
|
50
|
+
ref$ = [val % 10, Math.floor(val / 10)], n = ref$[0], o = ref$[1];
|
|
51
|
+
ret = {
|
|
52
|
+
name: n,
|
|
53
|
+
value: Math.random(),
|
|
54
|
+
order: o
|
|
55
|
+
};
|
|
56
|
+
return ret;
|
|
57
|
+
}),
|
|
58
|
+
binding: {
|
|
59
|
+
order: {
|
|
60
|
+
key: "order"
|
|
61
|
+
},
|
|
62
|
+
value: {
|
|
63
|
+
key: "value"
|
|
64
|
+
},
|
|
65
|
+
name: {
|
|
66
|
+
key: "name"
|
|
71
67
|
}
|
|
72
|
-
};
|
|
73
|
-
},
|
|
74
|
-
config: {},
|
|
75
|
-
dimension: {
|
|
76
|
-
order: {
|
|
77
|
-
type: 'O',
|
|
78
|
-
name: "order",
|
|
79
|
-
priority: 1
|
|
80
|
-
},
|
|
81
|
-
value: {
|
|
82
|
-
type: 'R',
|
|
83
|
-
name: "value",
|
|
84
|
-
priority: 2
|
|
85
|
-
},
|
|
86
|
-
name: {
|
|
87
|
-
type: 'N',
|
|
88
|
-
name: "name"
|
|
89
68
|
}
|
|
69
|
+
};
|
|
70
|
+
},
|
|
71
|
+
config: {},
|
|
72
|
+
dimension: {
|
|
73
|
+
order: {
|
|
74
|
+
type: 'O',
|
|
75
|
+
name: "order",
|
|
76
|
+
priority: 1
|
|
90
77
|
},
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
view: d3.select(this.layout.getGroup('view')),
|
|
96
|
-
axis: d3.select(this.layout.getGroup('axis'))
|
|
97
|
-
};
|
|
98
|
-
this.scale = scale = {};
|
|
99
|
-
this.axisBottom = d3.axisBottom();
|
|
100
|
-
return this.legend = new chart.utils.legend({
|
|
101
|
-
layout: this.layout,
|
|
102
|
-
name: 'legend',
|
|
103
|
-
root: this.root,
|
|
104
|
-
shape: function(d){
|
|
105
|
-
return d3.select(this).attr('fill', tint.get(d.key));
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
},
|
|
109
|
-
parse: function(){
|
|
110
|
-
this.data.map(function(d){
|
|
111
|
-
return d.value = d.value.map(function(it){
|
|
112
|
-
if (isNaN(it)) {
|
|
113
|
-
return 0;
|
|
114
|
-
} else {
|
|
115
|
-
return +it;
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
return this.names = Array.from(new Set(this.data.map(function(it){
|
|
120
|
-
return it.name;
|
|
121
|
-
})));
|
|
78
|
+
value: {
|
|
79
|
+
type: 'R',
|
|
80
|
+
name: "value",
|
|
81
|
+
priority: 2
|
|
122
82
|
},
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
83
|
+
name: {
|
|
84
|
+
type: 'N',
|
|
85
|
+
name: "name"
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
init: function(){
|
|
89
|
+
var tint, scale;
|
|
90
|
+
this.tint = tint = new chart.utils.tint();
|
|
91
|
+
this.g = {
|
|
92
|
+
view: d3.select(this.layout.getGroup('view')),
|
|
93
|
+
axis: d3.select(this.layout.getGroup('axis'))
|
|
94
|
+
};
|
|
95
|
+
this.scale = scale = {};
|
|
96
|
+
this.axisBottom = d3.axisBottom();
|
|
97
|
+
return this.legend = new chart.utils.legend({
|
|
98
|
+
layout: this.layout,
|
|
99
|
+
name: 'legend',
|
|
100
|
+
root: this.root,
|
|
101
|
+
shape: function(d){
|
|
102
|
+
return d3.select(this).attr('fill', tint.get(d.key));
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
},
|
|
106
|
+
parse: function(){
|
|
107
|
+
this.data.map(function(d){
|
|
108
|
+
return d.value = d.value.map(function(it){
|
|
109
|
+
if (isNaN(it)) {
|
|
145
110
|
return 0;
|
|
111
|
+
} else {
|
|
112
|
+
return +it;
|
|
146
113
|
}
|
|
147
114
|
});
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
this.layout.update(false);
|
|
161
|
-
max = Math.max(this.data.map(function(it){
|
|
162
|
-
return it.value;
|
|
115
|
+
});
|
|
116
|
+
return this.names = Array.from(new Set(this.data.map(function(it){
|
|
117
|
+
return it.name;
|
|
118
|
+
})));
|
|
119
|
+
},
|
|
120
|
+
resize: function(){
|
|
121
|
+
var ref$, i, max, box, this$ = this;
|
|
122
|
+
this.layout.getNode('legend').style.width = !(((ref$ = this.cfg).legend || (ref$.legend = {})).enabled != null) || this.cfg.legend.enabled ? '' : '0';
|
|
123
|
+
this.layout.update(false);
|
|
124
|
+
this.maxPerGroup = this.binding.height.map(function(d, i){
|
|
125
|
+
return Math.max.apply(Math, this$.data.map(function(it){
|
|
126
|
+
return it.height[i];
|
|
163
127
|
}));
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
return
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
128
|
+
});
|
|
129
|
+
this.order = this.data.map(function(d, i){
|
|
130
|
+
return {
|
|
131
|
+
key: d._idx,
|
|
132
|
+
idx: i,
|
|
133
|
+
name: d.order
|
|
134
|
+
};
|
|
135
|
+
});
|
|
136
|
+
this.order.sort(function(a, b){
|
|
137
|
+
if (b.name > a.name) {
|
|
138
|
+
return 1;
|
|
139
|
+
} else if (b.name < a.name) {
|
|
140
|
+
return -1;
|
|
141
|
+
} else {
|
|
142
|
+
return 0;
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
this.tint.set(this.cfg.palette);
|
|
146
|
+
this.legend.data((function(){
|
|
147
|
+
var i$, to$, results$ = [];
|
|
148
|
+
for (i$ = 0, to$ = this.names.length; i$ < to$; ++i$) {
|
|
149
|
+
i = i$;
|
|
150
|
+
results$.push({
|
|
151
|
+
key: i,
|
|
152
|
+
text: this.names[i]
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
return results$;
|
|
156
|
+
}.call(this)));
|
|
157
|
+
this.layout.update(false);
|
|
158
|
+
max = Math.max(this.data.map(function(it){
|
|
159
|
+
return it.value;
|
|
160
|
+
}));
|
|
161
|
+
box = this.layout.getBox('view');
|
|
162
|
+
return ref$ = this.scale, ref$.y = d3.scaleLinear().domain([0, max]).range([box.width, 0]), ref$.x = d3.scaleBand().domain(this.order.map(function(it){
|
|
163
|
+
return it.name || it.key;
|
|
164
|
+
})).range([0, box.height]), ref$;
|
|
165
|
+
},
|
|
166
|
+
render: function(){
|
|
167
|
+
var binding, scale, range, delta, cfg, tint, data, x$;
|
|
168
|
+
binding = this.binding, scale = this.scale, range = this.range, delta = this.delta, cfg = this.cfg, tint = this.tint, data = this.data;
|
|
169
|
+
x$ = this.g.view.selectAll('g.bar').data(this.data);
|
|
170
|
+
x$.exit().remove();
|
|
171
|
+
x$.enter().append('g').attr('class', 'bar');
|
|
172
|
+
this.g.view.selectAll('g.bar').attr('transform', function(d, i){
|
|
173
|
+
return "translate(" + scale.x(d.name) + ",0)";
|
|
174
|
+
});
|
|
175
|
+
return this.g.axis.call(this.axisBottom).attr('font-size', '');
|
|
176
|
+
},
|
|
177
|
+
tick: function(){}
|
|
182
178
|
};
|
|
183
|
-
|
|
184
|
-
});</script></div>
|
|
179
|
+
};</script></div>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<div class="base" style="width:100%;height:100%"><plug name="layout"></plug><style type="text/css">*[plug=layout] {
|
|
2
2
|
fill: currentColor;
|
|
3
3
|
}
|
|
4
|
-
</style><script type="@plotdb/block">
|
|
4
|
+
</style><script type="@plotdb/block">module.exports = {
|
|
5
5
|
pkg: {
|
|
6
6
|
name: 'base',
|
|
7
7
|
version: '0.0.1',
|
|
@@ -189,7 +189,7 @@
|
|
|
189
189
|
render: function(){}
|
|
190
190
|
};
|
|
191
191
|
}
|
|
192
|
-
}
|
|
192
|
+
};
|
|
193
193
|
function import$(obj, src){
|
|
194
194
|
var own = {}.hasOwnProperty;
|
|
195
195
|
for (var key in src) if (own.call(src, key)) obj[key] = src[key];
|
|
@@ -1,42 +1,37 @@
|
|
|
1
|
-
<div style="width:100%;height:100%"><script type="@plotdb/block">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
name: '
|
|
8
|
-
version: '0.0.1'
|
|
9
|
-
extend: {
|
|
10
|
-
name: 'base',
|
|
11
|
-
version: '0.0.1'
|
|
12
|
-
},
|
|
13
|
-
dependencies: []
|
|
1
|
+
<div style="width:100%;height:100%"><script type="@plotdb/block">var mod;
|
|
2
|
+
module.exports = {
|
|
3
|
+
pkg: {
|
|
4
|
+
name: 'blank',
|
|
5
|
+
version: '0.0.1',
|
|
6
|
+
extend: {
|
|
7
|
+
name: 'base',
|
|
8
|
+
version: '0.0.1'
|
|
14
9
|
},
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
+
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],
|
|
20
|
+
binding: {}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
mod = function(arg$){
|
|
25
|
+
var context;
|
|
26
|
+
context = arg$.context;
|
|
27
|
+
context;
|
|
28
|
+
return {
|
|
29
|
+
config: {},
|
|
30
|
+
dimension: {},
|
|
31
|
+
init: function(){},
|
|
32
|
+
parse: function(){},
|
|
33
|
+
resize: function(){},
|
|
34
|
+
render: function(){},
|
|
35
|
+
tick: function(){}
|
|
26
36
|
};
|
|
27
|
-
|
|
28
|
-
var context;
|
|
29
|
-
context = arg$.context;
|
|
30
|
-
context;
|
|
31
|
-
return {
|
|
32
|
-
config: {},
|
|
33
|
-
dimension: {},
|
|
34
|
-
init: function(){},
|
|
35
|
-
parse: function(){},
|
|
36
|
-
resize: function(){},
|
|
37
|
-
render: function(){},
|
|
38
|
-
tick: function(){}
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
return blockFactory;
|
|
42
|
-
});</script></div>
|
|
37
|
+
};</script></div>
|