@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
|
@@ -7,142 +7,137 @@
|
|
|
7
7
|
height: 100%;
|
|
8
8
|
margin-right: 1em;
|
|
9
9
|
}
|
|
10
|
-
</style><script type="@plotdb/block">
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
name:
|
|
17
|
-
version:
|
|
18
|
-
extend: {
|
|
19
|
-
name: "base",
|
|
20
|
-
version: "0.0.1"
|
|
21
|
-
},
|
|
22
|
-
dependencies: []
|
|
10
|
+
</style><script type="@plotdb/block">var mod;
|
|
11
|
+
module.exports = {
|
|
12
|
+
pkg: {
|
|
13
|
+
name: 'curve-bar',
|
|
14
|
+
version: '0.0.1',
|
|
15
|
+
extend: {
|
|
16
|
+
name: "base",
|
|
17
|
+
version: "0.0.1"
|
|
23
18
|
},
|
|
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
|
-
|
|
19
|
+
dependencies: []
|
|
20
|
+
},
|
|
21
|
+
init: function(arg$){
|
|
22
|
+
var root, context, pubsub;
|
|
23
|
+
root = arg$.root, context = arg$.context, pubsub = arg$.pubsub;
|
|
24
|
+
return pubsub.fire('init', {
|
|
25
|
+
mod: mod({
|
|
26
|
+
context: context
|
|
27
|
+
})
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
mod = function(arg$){
|
|
32
|
+
var context, d3, legend, chart;
|
|
33
|
+
context = arg$.context;
|
|
34
|
+
d3 = context.d3, legend = context.legend, chart = context.chart;
|
|
35
|
+
return {
|
|
36
|
+
sample: function(){
|
|
37
|
+
return {
|
|
38
|
+
raw: [1, 2, 3, 4, 5].map(function(val){
|
|
39
|
+
return {
|
|
40
|
+
val: Math.random(),
|
|
41
|
+
name: val
|
|
42
|
+
};
|
|
43
|
+
}),
|
|
44
|
+
binding: {
|
|
45
|
+
name: {
|
|
46
|
+
key: 'name'
|
|
47
|
+
},
|
|
48
|
+
value: {
|
|
49
|
+
key: 'val'
|
|
54
50
|
}
|
|
55
|
-
};
|
|
56
|
-
},
|
|
57
|
-
config: {},
|
|
58
|
-
dimension: {
|
|
59
|
-
value: {
|
|
60
|
-
type: 'R',
|
|
61
|
-
name: "value"
|
|
62
|
-
},
|
|
63
|
-
name: {
|
|
64
|
-
type: 'N',
|
|
65
|
-
name: "name"
|
|
66
51
|
}
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
config: {},
|
|
55
|
+
dimension: {
|
|
56
|
+
value: {
|
|
57
|
+
type: 'R',
|
|
58
|
+
name: "value"
|
|
67
59
|
},
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
this.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
60
|
+
name: {
|
|
61
|
+
type: 'N',
|
|
62
|
+
name: "name"
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
init: function(){
|
|
66
|
+
var tint;
|
|
67
|
+
this.gview = d3.select(this.layout.getGroup('view'));
|
|
68
|
+
this.g = this.gview.append('g');
|
|
69
|
+
this.tint = tint = new chart.utils.tint();
|
|
70
|
+
this.arc = d3.arc().innerRadius(0).outerRadius(100).startAngle(0).endAngle(Math.PI / 2);
|
|
71
|
+
return this.legend = new chart.utils.legend({
|
|
72
|
+
root: this.root,
|
|
73
|
+
name: 'legend',
|
|
74
|
+
shape: function(d){
|
|
75
|
+
return d3.select(this).attr('fill', tint.get(d.text));
|
|
76
|
+
},
|
|
77
|
+
layout: this.layout
|
|
78
|
+
});
|
|
79
|
+
},
|
|
80
|
+
parse: function(){
|
|
81
|
+
this.tint.reset();
|
|
82
|
+
this.extent = {
|
|
83
|
+
v: d3.extent(this.data.map(function(it){
|
|
84
|
+
return it.value;
|
|
85
|
+
}))
|
|
86
|
+
};
|
|
87
|
+
this.data.sort(function(a, b){
|
|
88
|
+
return a.value - b.value;
|
|
89
|
+
});
|
|
90
|
+
return this.legend.data(this.data.map(function(it){
|
|
91
|
+
return {
|
|
92
|
+
key: it.name,
|
|
93
|
+
text: it.name
|
|
89
94
|
};
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
}));
|
|
96
|
+
},
|
|
97
|
+
resize: function(){
|
|
98
|
+
var box, ref$, w, h, size;
|
|
99
|
+
box = this.layout.getBox('view');
|
|
100
|
+
this.layout.getNode('view').style.width = box.height + "px";
|
|
101
|
+
this.layout.update(false);
|
|
102
|
+
ref$ = [box.width, box.height], w = ref$[0], h = ref$[1];
|
|
103
|
+
size = Math.min(w, h);
|
|
104
|
+
return this.scale = {
|
|
105
|
+
v: d3.scaleLinear().domain([0, this.extent.v[1]]).range([0, Math.PI * 3 / 2]),
|
|
106
|
+
r: d3.scaleBand().domain(this.data.map(function(d, i){
|
|
107
|
+
return i;
|
|
108
|
+
})).range([24, size / 2])
|
|
109
|
+
};
|
|
110
|
+
},
|
|
111
|
+
render: function(){
|
|
112
|
+
var scale, bw, box, x$, y$, this$ = this;
|
|
113
|
+
scale = this.scale;
|
|
114
|
+
bw = this.scale.r.bandwidth();
|
|
115
|
+
this.arc.cornerRadius(bw / 2);
|
|
116
|
+
if (this.cfg != null && this.cfg.palette) {
|
|
117
|
+
this.tint.set(this.cfg.palette.colors.map(function(it){
|
|
118
|
+
return it.value || it;
|
|
98
119
|
}));
|
|
99
|
-
},
|
|
100
|
-
resize: function(){
|
|
101
|
-
var box, ref$, w, h, size;
|
|
102
|
-
box = this.layout.getBox('view');
|
|
103
|
-
this.layout.getNode('view').style.width = box.height + "px";
|
|
104
|
-
this.layout.update(false);
|
|
105
|
-
ref$ = [box.width, box.height], w = ref$[0], h = ref$[1];
|
|
106
|
-
size = Math.min(w, h);
|
|
107
|
-
return this.scale = {
|
|
108
|
-
v: d3.scaleLinear().domain([0, this.extent.v[1]]).range([0, Math.PI * 3 / 2]),
|
|
109
|
-
r: d3.scaleBand().domain(this.data.map(function(d, i){
|
|
110
|
-
return i;
|
|
111
|
-
})).range([24, size / 2])
|
|
112
|
-
};
|
|
113
|
-
},
|
|
114
|
-
render: function(){
|
|
115
|
-
var scale, bw, box, x$, y$, this$ = this;
|
|
116
|
-
scale = this.scale;
|
|
117
|
-
bw = this.scale.r.bandwidth();
|
|
118
|
-
this.arc.cornerRadius(bw / 2);
|
|
119
|
-
if (this.cfg != null && this.cfg.palette) {
|
|
120
|
-
this.tint.set(this.cfg.palette.colors.map(function(it){
|
|
121
|
-
return it.value || it;
|
|
122
|
-
}));
|
|
123
|
-
}
|
|
124
|
-
this.legend.render();
|
|
125
|
-
box = this.layout.getBox('view');
|
|
126
|
-
this.g.attr('transform', "translate(" + box.width / 2 + "," + box.height / 2 + ")");
|
|
127
|
-
x$ = this.g.selectAll('path.data').data(this.data);
|
|
128
|
-
x$.exit().remove();
|
|
129
|
-
x$.enter().append('path').attr('class', 'data');
|
|
130
|
-
this.g.selectAll('path.data').attr('d', function(d, i){
|
|
131
|
-
this$.arc.startAngle(0).endAngle(scale.v(d.value)).innerRadius(scale.r(i)).outerRadius(scale.r(i) + bw - 2);
|
|
132
|
-
return this$.arc();
|
|
133
|
-
}).attr('fill', function(d, i){
|
|
134
|
-
return this$.tint.get(d.name) || d._idx;
|
|
135
|
-
});
|
|
136
|
-
y$ = this.g.selectAll('text.label').data(this.data);
|
|
137
|
-
y$.exit().remove();
|
|
138
|
-
y$.enter().append('text').attr('class', 'label');
|
|
139
|
-
return this.g.selectAll('text.label').attr('dominant-baseline', 'center').attr('text-anchor', 'end').attr('x', '-.5em').attr('y', function(d, i){
|
|
140
|
-
return -scale.r(i);
|
|
141
|
-
}).attr('dy', -bw * 1 / 4).text(function(d, i){
|
|
142
|
-
return d.name;
|
|
143
|
-
});
|
|
144
120
|
}
|
|
145
|
-
|
|
121
|
+
this.legend.render();
|
|
122
|
+
box = this.layout.getBox('view');
|
|
123
|
+
this.g.attr('transform', "translate(" + box.width / 2 + "," + box.height / 2 + ")");
|
|
124
|
+
x$ = this.g.selectAll('path.data').data(this.data);
|
|
125
|
+
x$.exit().remove();
|
|
126
|
+
x$.enter().append('path').attr('class', 'data');
|
|
127
|
+
this.g.selectAll('path.data').attr('d', function(d, i){
|
|
128
|
+
this$.arc.startAngle(0).endAngle(scale.v(d.value)).innerRadius(scale.r(i)).outerRadius(scale.r(i) + bw - 2);
|
|
129
|
+
return this$.arc();
|
|
130
|
+
}).attr('fill', function(d, i){
|
|
131
|
+
return this$.tint.get(d.name) || d._idx;
|
|
132
|
+
});
|
|
133
|
+
y$ = this.g.selectAll('text.label').data(this.data);
|
|
134
|
+
y$.exit().remove();
|
|
135
|
+
y$.enter().append('text').attr('class', 'label');
|
|
136
|
+
return this.g.selectAll('text.label').attr('dominant-baseline', 'center').attr('text-anchor', 'end').attr('x', '-.5em').attr('y', function(d, i){
|
|
137
|
+
return -scale.r(i);
|
|
138
|
+
}).attr('dy', -bw * 1 / 4).text(function(d, i){
|
|
139
|
+
return d.name;
|
|
140
|
+
});
|
|
141
|
+
}
|
|
146
142
|
};
|
|
147
|
-
|
|
148
|
-
});</script></div>
|
|
143
|
+
};</script></div>
|
|
@@ -1,178 +1,173 @@
|
|
|
1
|
-
<div><script type="@plotdb/block">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
name:
|
|
8
|
-
version:
|
|
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: 'dumbbell',
|
|
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
|
-
|
|
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
|
-
config: {},
|
|
63
|
-
dimension: {
|
|
64
|
-
y1: {
|
|
65
|
-
type: 'R',
|
|
66
|
-
multiple: true,
|
|
67
|
-
name: "y pos"
|
|
68
|
-
},
|
|
69
|
-
y2: {
|
|
70
|
-
type: 'R',
|
|
71
|
-
multiple: true,
|
|
72
|
-
name: "y pos"
|
|
73
|
-
},
|
|
74
|
-
name: {
|
|
75
|
-
type: 'N',
|
|
76
|
-
name: "dumbbell name"
|
|
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
|
+
});
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
mod = function(arg$){
|
|
23
|
+
var context, d3, ldcolor, debounce, infinite;
|
|
24
|
+
context = arg$.context;
|
|
25
|
+
d3 = context.d3, ldcolor = context.ldcolor, debounce = context.debounce, infinite = context.infinite;
|
|
26
|
+
return {
|
|
27
|
+
sample: function(){
|
|
28
|
+
return {
|
|
29
|
+
raw: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(function(val){
|
|
30
|
+
return {
|
|
31
|
+
val1: Math.random() * 0.5 + 0.4,
|
|
32
|
+
val2: Math.random() * 0.5 + 0.4,
|
|
33
|
+
val3: Math.random() * 0.6 + 0.1,
|
|
34
|
+
val4: Math.random() * 0.6 + 0.1,
|
|
35
|
+
name: val
|
|
36
|
+
};
|
|
37
|
+
}),
|
|
38
|
+
binding: {
|
|
39
|
+
name: {
|
|
40
|
+
key: 'name'
|
|
41
|
+
},
|
|
42
|
+
y1: [
|
|
43
|
+
{
|
|
44
|
+
key: 'val1'
|
|
45
|
+
}, {
|
|
46
|
+
key: 'val2'
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
y2: [
|
|
50
|
+
{
|
|
51
|
+
key: 'val3'
|
|
52
|
+
}, {
|
|
53
|
+
key: 'val4'
|
|
54
|
+
}
|
|
55
|
+
]
|
|
77
56
|
}
|
|
57
|
+
};
|
|
58
|
+
},
|
|
59
|
+
config: {},
|
|
60
|
+
dimension: {
|
|
61
|
+
y1: {
|
|
62
|
+
type: 'R',
|
|
63
|
+
multiple: true,
|
|
64
|
+
name: "y pos"
|
|
78
65
|
},
|
|
79
|
-
|
|
80
|
-
|
|
66
|
+
y2: {
|
|
67
|
+
type: 'R',
|
|
68
|
+
multiple: true,
|
|
69
|
+
name: "y pos"
|
|
81
70
|
},
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
71
|
+
name: {
|
|
72
|
+
type: 'N',
|
|
73
|
+
name: "dumbbell name"
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
init: function(){
|
|
77
|
+
return this.infcolor = new infinite();
|
|
78
|
+
},
|
|
79
|
+
parse: function(){
|
|
80
|
+
var this$ = this;
|
|
81
|
+
this.parsed = [];
|
|
82
|
+
this.parsed = this.data.map(function(d, i){
|
|
83
|
+
var dumbbell;
|
|
84
|
+
dumbbell = d.y1.map(function(e, j){
|
|
94
85
|
return {
|
|
95
|
-
|
|
96
|
-
|
|
86
|
+
y1: d.y1[j] || 0,
|
|
87
|
+
y2: d.y2[j] || 0,
|
|
88
|
+
name: [this$.binding.y1[j].key, this$.binding.y2[j].key]
|
|
97
89
|
};
|
|
98
90
|
});
|
|
99
|
-
return
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
},
|
|
103
|
-
resize: function(){
|
|
104
|
-
var ref$, w, h;
|
|
105
|
-
ref$ = [this.box.width, this.box.height], w = ref$[0], h = ref$[1];
|
|
106
|
-
this.extent = {
|
|
107
|
-
y: [
|
|
108
|
-
d3.min(this.data.map(function(d, i){
|
|
109
|
-
return d3.min([d3.min(d.y1), d3.min(d.y2)]);
|
|
110
|
-
})), d3.max(this.data.map(function(d, i){
|
|
111
|
-
return d3.max([d3.max(d.y1), d3.max(d.y2)]);
|
|
112
|
-
}))
|
|
113
|
-
]
|
|
114
|
-
};
|
|
115
|
-
this.scale = {
|
|
116
|
-
x: d3.scaleBand().domain(this.names).range([0, w]).paddingInner(0.3),
|
|
117
|
-
y: d3.scaleLinear().domain([0, this.extent.y[1]]).range([0, h]),
|
|
118
|
-
c: d3.scaleOrdinal(d3.schemeCategory10)
|
|
91
|
+
return {
|
|
92
|
+
name: d.name,
|
|
93
|
+
dumbbell: dumbbell
|
|
119
94
|
};
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
95
|
+
});
|
|
96
|
+
return this.names = this.data.map(function(it){
|
|
97
|
+
return it.name;
|
|
98
|
+
});
|
|
99
|
+
},
|
|
100
|
+
resize: function(){
|
|
101
|
+
var ref$, w, h;
|
|
102
|
+
ref$ = [this.box.width, this.box.height], w = ref$[0], h = ref$[1];
|
|
103
|
+
this.extent = {
|
|
104
|
+
y: [
|
|
105
|
+
d3.min(this.data.map(function(d, i){
|
|
106
|
+
return d3.min([d3.min(d.y1), d3.min(d.y2)]);
|
|
107
|
+
})), d3.max(this.data.map(function(d, i){
|
|
108
|
+
return d3.max([d3.max(d.y1), d3.max(d.y2)]);
|
|
109
|
+
}))
|
|
110
|
+
]
|
|
111
|
+
};
|
|
112
|
+
this.scale = {
|
|
113
|
+
x: d3.scaleBand().domain(this.names).range([0, w]).paddingInner(0.3),
|
|
114
|
+
y: d3.scaleLinear().domain([0, this.extent.y[1]]).range([0, h]),
|
|
115
|
+
c: d3.scaleOrdinal(d3.schemeCategory10)
|
|
116
|
+
};
|
|
117
|
+
if (this.cfg != null && this.cfg.palette) {
|
|
118
|
+
this.scale.c = d3.scaleOrdinal(this.cfg.palette.colors.map(function(it){
|
|
119
|
+
return ldcolor.web(it.value || it);
|
|
120
|
+
}));
|
|
121
|
+
}
|
|
122
|
+
if (this.cfg != null && this.cfg.palette) {
|
|
123
|
+
return this.infcolor.setColors(this.cfg.palette.colors.map(function(it){
|
|
124
|
+
return ldcolor.web(it.value || it);
|
|
125
|
+
}));
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
render: function(){
|
|
129
|
+
var scale, infcolor, svg, x$;
|
|
130
|
+
scale = this.scale, infcolor = this.infcolor;
|
|
131
|
+
svg = d3.select(this.svg);
|
|
132
|
+
x$ = svg.selectAll('g.data').data(this.parsed);
|
|
133
|
+
x$.exit().remove();
|
|
134
|
+
x$.enter().append('g').attr('class', 'data');
|
|
135
|
+
return svg.selectAll('g.data').each(function(e, j){
|
|
136
|
+
var bw, n, x$;
|
|
137
|
+
bw = scale.x.bandwidth();
|
|
138
|
+
n = d3.select(this);
|
|
139
|
+
x$ = n.selectAll('g.dumbbell').data(e.dumbbell);
|
|
136
140
|
x$.exit().remove();
|
|
137
|
-
x$.enter().append('g').attr('class', '
|
|
138
|
-
return
|
|
139
|
-
var
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
x$ = n.selectAll('g.dumbbell').data(e.dumbbell);
|
|
141
|
+
x$.enter().append('g').attr('class', 'dumbbell');
|
|
142
|
+
return n.selectAll('g.dumbbell').each(function(f, k){
|
|
143
|
+
var m, x$, y$;
|
|
144
|
+
m = d3.select(this);
|
|
145
|
+
x$ = m.selectAll('circle').data([1, 2]);
|
|
143
146
|
x$.exit().remove();
|
|
144
|
-
x$.enter().append('
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
x
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
m.selectAll('circle').attr('cx', function(d, i){
|
|
155
|
-
return scale.x(e.name) + bw * i;
|
|
156
|
-
}).attr('cy', function(d, i){
|
|
157
|
-
return scale.y(f["y" + d]);
|
|
158
|
-
}).attr('r', 2).attr('fill', function(){
|
|
159
|
-
return infcolor.get(f.name[0]);
|
|
160
|
-
});
|
|
161
|
-
return m.selectAll('line').attr('x1', function(d, i){
|
|
162
|
-
return scale.x(e.name);
|
|
163
|
-
}).attr('x2', function(d, i){
|
|
164
|
-
return scale.x(e.name) + bw;
|
|
165
|
-
}).attr('y1', function(d, i){
|
|
166
|
-
return scale.y(f.y1);
|
|
167
|
-
}).attr('y2', function(d, i){
|
|
168
|
-
return scale.y(f.y2);
|
|
169
|
-
}).attr('stroke', function(){
|
|
170
|
-
return infcolor.get(f.name[0]);
|
|
171
|
-
}).attr('stroke-width', 1);
|
|
147
|
+
x$.enter().append('circle');
|
|
148
|
+
y$ = m.selectAll('line').data([0]);
|
|
149
|
+
y$.exit().remove();
|
|
150
|
+
y$.enter().append('line');
|
|
151
|
+
m.selectAll('circle').attr('cx', function(d, i){
|
|
152
|
+
return scale.x(e.name) + bw * i;
|
|
153
|
+
}).attr('cy', function(d, i){
|
|
154
|
+
return scale.y(f["y" + d]);
|
|
155
|
+
}).attr('r', 2).attr('fill', function(){
|
|
156
|
+
return infcolor.get(f.name[0]);
|
|
172
157
|
});
|
|
158
|
+
return m.selectAll('line').attr('x1', function(d, i){
|
|
159
|
+
return scale.x(e.name);
|
|
160
|
+
}).attr('x2', function(d, i){
|
|
161
|
+
return scale.x(e.name) + bw;
|
|
162
|
+
}).attr('y1', function(d, i){
|
|
163
|
+
return scale.y(f.y1);
|
|
164
|
+
}).attr('y2', function(d, i){
|
|
165
|
+
return scale.y(f.y2);
|
|
166
|
+
}).attr('stroke', function(){
|
|
167
|
+
return infcolor.get(f.name[0]);
|
|
168
|
+
}).attr('stroke-width', 1);
|
|
173
169
|
});
|
|
174
|
-
}
|
|
175
|
-
}
|
|
170
|
+
});
|
|
171
|
+
}
|
|
176
172
|
};
|
|
177
|
-
|
|
178
|
-
});</script></div>
|
|
173
|
+
};</script></div>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<div style="width:100%;height:100%"><script type="@plotdb/block">
|
|
1
|
+
<div style="width:100%;height:100%"><script type="@plotdb/block">module.exports = {
|
|
2
2
|
pkg: {
|
|
3
3
|
name: 'empty',
|
|
4
4
|
version: '0.0.1',
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
render: function(){}
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
|
-
}
|
|
71
|
+
};
|
|
72
72
|
function import$(obj, src){
|
|
73
73
|
var own = {}.hasOwnProperty;
|
|
74
74
|
for (var key in src) if (own.call(src, key)) obj[key] = src[key];
|