@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
|
@@ -26,289 +26,284 @@
|
|
|
26
26
|
justify-content: start;
|
|
27
27
|
align-items: start;
|
|
28
28
|
}
|
|
29
|
-
</style><script type="@plotdb/block">
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
name:
|
|
36
|
-
version:
|
|
37
|
-
extend: {
|
|
38
|
-
name: "base",
|
|
39
|
-
version: "0.0.1"
|
|
40
|
-
},
|
|
41
|
-
dependencies: [],
|
|
42
|
-
i18n: {
|
|
43
|
-
"zh-TW": {
|
|
44
|
-
"other": "其它"
|
|
45
|
-
}
|
|
46
|
-
}
|
|
29
|
+
</style><script type="@plotdb/block">var mod;
|
|
30
|
+
module.exports = {
|
|
31
|
+
pkg: {
|
|
32
|
+
name: 'percent-list',
|
|
33
|
+
version: '0.0.1',
|
|
34
|
+
extend: {
|
|
35
|
+
name: "base",
|
|
36
|
+
version: "0.0.1"
|
|
47
37
|
},
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
context: context,
|
|
54
|
-
t: t
|
|
55
|
-
})
|
|
56
|
-
});
|
|
38
|
+
dependencies: [],
|
|
39
|
+
i18n: {
|
|
40
|
+
"zh-TW": {
|
|
41
|
+
"other": "其它"
|
|
42
|
+
}
|
|
57
43
|
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
var
|
|
61
|
-
context = arg$.context, t = arg$.t;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
44
|
+
},
|
|
45
|
+
init: function(arg$){
|
|
46
|
+
var root, context, pubsub, t;
|
|
47
|
+
root = arg$.root, context = arg$.context, pubsub = arg$.pubsub, t = arg$.t;
|
|
48
|
+
return pubsub.fire('init', {
|
|
49
|
+
mod: mod({
|
|
50
|
+
context: context,
|
|
51
|
+
t: t
|
|
52
|
+
})
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
mod = function(arg$){
|
|
57
|
+
var context, t, chart, d3, wrapSvgText, debounce;
|
|
58
|
+
context = arg$.context, t = arg$.t;
|
|
59
|
+
chart = context.chart, d3 = context.d3, wrapSvgText = context.wrapSvgText, debounce = context.debounce;
|
|
60
|
+
return {
|
|
61
|
+
sample: function(){
|
|
62
|
+
return {
|
|
63
|
+
raw: ["Bachchan Pandey", "The Good Maharaja", "Ramprasad Ki Tehrvi", "Madam Chief Minister", "Satya Sai Baba", "Lahore Confidential", "Sandeep Aur Pinky Faraar", "Silence... Can You Hear It?", "Hum Bhi Akele Tum Bhi Akele", "Radhe", "Shaadisthan", "Chandigarh Kare Aashiqui", "Gangubai Kathiawadi", "Attack", "The Battle of Bhima Koregaon", "Tadap", "Looop Lapeta"].map(function(val){
|
|
64
|
+
return {
|
|
65
|
+
val: Math.random(),
|
|
66
|
+
name: val
|
|
67
|
+
};
|
|
68
|
+
}),
|
|
69
|
+
binding: {
|
|
70
|
+
name: {
|
|
71
|
+
key: 'name'
|
|
72
|
+
},
|
|
73
|
+
value: {
|
|
74
|
+
key: 'val'
|
|
79
75
|
}
|
|
80
|
-
};
|
|
81
|
-
},
|
|
82
|
-
config: {},
|
|
83
|
-
dimension: {
|
|
84
|
-
value: {
|
|
85
|
-
type: 'R',
|
|
86
|
-
name: "value",
|
|
87
|
-
priority: 20
|
|
88
|
-
},
|
|
89
|
-
name: {
|
|
90
|
-
type: 'N',
|
|
91
|
-
name: "name",
|
|
92
|
-
priority: 10
|
|
93
76
|
}
|
|
77
|
+
};
|
|
78
|
+
},
|
|
79
|
+
config: {},
|
|
80
|
+
dimension: {
|
|
81
|
+
value: {
|
|
82
|
+
type: 'R',
|
|
83
|
+
name: "value",
|
|
84
|
+
priority: 20
|
|
94
85
|
},
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
this.layout.getGroup('
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
86
|
+
name: {
|
|
87
|
+
type: 'N',
|
|
88
|
+
name: "name",
|
|
89
|
+
priority: 10
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
init: function(){
|
|
93
|
+
var tint, this$ = this;
|
|
94
|
+
this.g = {
|
|
95
|
+
view: d3.select(this.layout.getGroup('view')),
|
|
96
|
+
link: d3.select(this.layout.getGroup('link')),
|
|
97
|
+
legend: d3.select(this.layout.getGroup('legend'))
|
|
98
|
+
};
|
|
99
|
+
this.tint = tint = new chart.utils.tint();
|
|
100
|
+
this.scale = {
|
|
101
|
+
y: d3.scaleLinear()
|
|
102
|
+
};
|
|
103
|
+
this.layout.getGroup('view').addEventListener('mousemove', function(evt){
|
|
104
|
+
var n;
|
|
105
|
+
if (!((n = evt.target) && n.nodeName.toLowerCase() === 'rect')) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
this$.idx = Array.from(n.parentNode.childNodes).indexOf(n);
|
|
109
|
+
return this$.renderDebounced();
|
|
110
|
+
});
|
|
111
|
+
return this.renderDebounced = debounce(350, function(){
|
|
112
|
+
return this$.render();
|
|
113
|
+
});
|
|
114
|
+
},
|
|
115
|
+
parse: function(){
|
|
116
|
+
var ref$, other, total, sum, i$, to$, idx, offset, i, ret, this$ = this;
|
|
117
|
+
((ref$ = this.cfg).collapse || (ref$.collapse = {})).enabled = false;
|
|
118
|
+
this.parsed = this.data.map(function(it){
|
|
119
|
+
return import$({}, it);
|
|
120
|
+
});
|
|
121
|
+
this.parsed.sort(function(a, b){
|
|
122
|
+
return b.value - a.value;
|
|
123
|
+
});
|
|
124
|
+
if (this.cfg.collapse.enabled) {
|
|
125
|
+
if (this.cfg.collapse.method === 'count') {
|
|
126
|
+
other = this.parsed.splice(this.cfg.collapse.threshold || 7);
|
|
127
|
+
if (other.length) {
|
|
128
|
+
this.parsed.push({
|
|
129
|
+
name: t("other"),
|
|
130
|
+
value: other.reduce(function(a, b){
|
|
131
|
+
return a + b.value;
|
|
132
|
+
}, 0)
|
|
133
|
+
});
|
|
110
134
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
return import$({}, it);
|
|
123
|
-
});
|
|
124
|
-
this.parsed.sort(function(a, b){
|
|
125
|
-
return b.value - a.value;
|
|
126
|
-
});
|
|
127
|
-
if (this.cfg.collapse.enabled) {
|
|
128
|
-
if (this.cfg.collapse.method === 'count') {
|
|
129
|
-
other = this.parsed.splice(this.cfg.collapse.threshold || 7);
|
|
130
|
-
if (other.length) {
|
|
131
|
-
this.parsed.push({
|
|
132
|
-
name: t("other"),
|
|
133
|
-
value: other.reduce(function(a, b){
|
|
134
|
-
return a + b.value;
|
|
135
|
-
}, 0)
|
|
136
|
-
});
|
|
135
|
+
} else {
|
|
136
|
+
ref$ = [
|
|
137
|
+
this.parsed.reduce(function(a, b){
|
|
138
|
+
return a + b.value;
|
|
139
|
+
}, 0), 0
|
|
140
|
+
], total = ref$[0], sum = ref$[1];
|
|
141
|
+
for (i$ = 0, to$ = this.parsed.length; i$ < to$; ++i$) {
|
|
142
|
+
idx = i$;
|
|
143
|
+
sum += this.parsed[idx].value;
|
|
144
|
+
if (sum / total > (this.cfg.collapse.threshold || 0.75)) {
|
|
145
|
+
break;
|
|
137
146
|
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
|
|
147
|
+
}
|
|
148
|
+
other = this.parsed.splice(idx + 1);
|
|
149
|
+
if (other.length) {
|
|
150
|
+
this.parsed.push({
|
|
151
|
+
name: t("other"),
|
|
152
|
+
value: other.reduce(function(a, b){
|
|
141
153
|
return a + b.value;
|
|
142
|
-
}, 0)
|
|
143
|
-
|
|
144
|
-
for (i$ = 0, to$ = this.parsed.length; i$ < to$; ++i$) {
|
|
145
|
-
idx = i$;
|
|
146
|
-
sum += this.parsed[idx].value;
|
|
147
|
-
if (sum / total > (this.cfg.collapse.threshold || 0.75)) {
|
|
148
|
-
break;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
other = this.parsed.splice(idx + 1);
|
|
152
|
-
if (other.length) {
|
|
153
|
-
this.parsed.push({
|
|
154
|
-
name: t("other"),
|
|
155
|
-
value: other.reduce(function(a, b){
|
|
156
|
-
return a + b.value;
|
|
157
|
-
}, 0)
|
|
158
|
-
});
|
|
159
|
-
}
|
|
154
|
+
}, 0)
|
|
155
|
+
});
|
|
160
156
|
}
|
|
161
157
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
158
|
+
}
|
|
159
|
+
this.tint.reset();
|
|
160
|
+
this.parsed.map(function(it){
|
|
161
|
+
return this$.tint.get(it.name || it._idx);
|
|
162
|
+
});
|
|
163
|
+
offset = 0;
|
|
164
|
+
for (i$ = 0, to$ = this.parsed.length; i$ < to$; ++i$) {
|
|
165
|
+
i = i$;
|
|
166
|
+
ret = this.parsed[i];
|
|
167
|
+
ret.offset = offset;
|
|
168
|
+
offset += ret.value;
|
|
169
|
+
}
|
|
170
|
+
return this.total = offset || 1;
|
|
171
|
+
},
|
|
172
|
+
resize: function(){
|
|
173
|
+
var node, box, ref$, w, h, size, this$ = this;
|
|
174
|
+
this.layout.update(false);
|
|
175
|
+
node = this.layout.getNode('legend');
|
|
176
|
+
node.textContent = "";
|
|
177
|
+
this.parsed.map(function(it){
|
|
178
|
+
var div, p;
|
|
179
|
+
div = document.createElement('div');
|
|
180
|
+
p = (100 * (it.value / this$.total)).toFixed(1);
|
|
181
|
+
div.textContent = it.text = it.name + " / " + p + "%";
|
|
182
|
+
return node.appendChild(div);
|
|
183
|
+
});
|
|
184
|
+
this.nboxes = this.parsed.map(function(d, i){
|
|
185
|
+
return this$.layout.getNode('legend').childNodes[i].getBoundingClientRect();
|
|
186
|
+
});
|
|
187
|
+
this.rbox = this.layout.getNode('legend').getBoundingClientRect();
|
|
188
|
+
this.lbox = this.layout.getBox('link');
|
|
189
|
+
box = this.layout.getBox('view');
|
|
190
|
+
this.layout.update(false);
|
|
191
|
+
box = this.layout.getBox('view');
|
|
192
|
+
ref$ = [box.width, box.height], w = ref$[0], h = ref$[1];
|
|
193
|
+
size = Math.min(w, h);
|
|
194
|
+
return this.scale.y.range([0, box.height]).domain([0, this.total]);
|
|
195
|
+
},
|
|
196
|
+
render: function(){
|
|
197
|
+
var total, cfg, layout, tint, scale, nboxes, rbox, lbox, box, offset, ref$, ref1$, ref2$, last, x$, y$, z$, z1$;
|
|
198
|
+
total = this.total, cfg = this.cfg, layout = this.layout, tint = this.tint, scale = this.scale, nboxes = this.nboxes, rbox = this.rbox, lbox = this.lbox;
|
|
199
|
+
if (this.cfg != null && this.cfg.palette) {
|
|
200
|
+
this.tint.set(this.cfg.palette.colors.map(function(it){
|
|
201
|
+
return it.value || it;
|
|
202
|
+
}));
|
|
203
|
+
}
|
|
204
|
+
box = this.layout.getBox('view');
|
|
205
|
+
offset = 0;
|
|
206
|
+
if (this.idx != null && nboxes.length) {
|
|
207
|
+
this.idx = (ref$ = (ref1$ = this.idx) < (ref2$ = this.nboxes.length - 1) ? ref1$ : ref2$) > 0 ? ref$ : 0;
|
|
208
|
+
offset = nboxes[this.idx].y - rbox.y;
|
|
209
|
+
last = nboxes[nboxes.length - 1].y + nboxes[nboxes.length - 1].height - rbox.y;
|
|
210
|
+
if (last - offset < rbox.height) {
|
|
211
|
+
offset = last - rbox.height;
|
|
206
212
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
213
|
+
}
|
|
214
|
+
x$ = this.g.view.selectAll('rect').data(this.parsed);
|
|
215
|
+
x$.exit().remove();
|
|
216
|
+
x$.enter().append('rect');
|
|
217
|
+
y$ = this.g.view.selectAll('rect');
|
|
218
|
+
y$.attr('x', function(){
|
|
219
|
+
return 0;
|
|
220
|
+
});
|
|
221
|
+
y$.attr('y', function(d, i){
|
|
222
|
+
return scale.y(d.offset);
|
|
223
|
+
});
|
|
224
|
+
y$.attr('width', function(){
|
|
225
|
+
return box.width;
|
|
226
|
+
});
|
|
227
|
+
y$.attr('height', function(d, i){
|
|
228
|
+
var ref$;
|
|
229
|
+
return (ref$ = scale.y(d.offset + d.value) - scale.y(d.offset) - 1) > 1 ? ref$ : 1;
|
|
230
|
+
});
|
|
231
|
+
y$.attr('fill', function(d, i){
|
|
232
|
+
var ret, nbox, y1;
|
|
233
|
+
return tint.get(Math.ceil(((d.offset + d.value / 2) / total) * 5));
|
|
234
|
+
ret = tint.get(0, (i % 3 - 1) / 5);
|
|
235
|
+
if (cfg.collapse.enabled) {
|
|
236
|
+
nbox = nboxes[i];
|
|
237
|
+
y1 = (nbox.y - rbox.y) + nbox.height / 2;
|
|
238
|
+
if (y1 < rbox.height) {
|
|
239
|
+
return ret;
|
|
215
240
|
}
|
|
241
|
+
ret = ldcolor.hcl(ret);
|
|
242
|
+
ret.c = ret.c * 0.1;
|
|
243
|
+
ret.l = ret.l * 1.1;
|
|
244
|
+
}
|
|
245
|
+
return ldcolor.web(ret);
|
|
246
|
+
});
|
|
247
|
+
z$ = this.g.legend.selectAll('g.label').data(this.parsed);
|
|
248
|
+
z$.exit().remove();
|
|
249
|
+
z$.enter().append('g').attr('class', 'label');
|
|
250
|
+
this.g.legend.selectAll('g.label').each(function(d, i){
|
|
251
|
+
var n, ret;
|
|
252
|
+
if (this._text !== d.text) {
|
|
253
|
+
this._text = d.text;
|
|
254
|
+
n = layout.getNode('legend').childNodes[i];
|
|
255
|
+
ret = wrapSvgText({
|
|
256
|
+
node: n,
|
|
257
|
+
useRange: true
|
|
258
|
+
});
|
|
259
|
+
this.textContent = "";
|
|
260
|
+
return this.appendChild(ret);
|
|
216
261
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
y
|
|
221
|
-
y
|
|
262
|
+
}).transition().duration(350).attr('opacity', function(d, i){
|
|
263
|
+
var nbox, y;
|
|
264
|
+
nbox = nboxes[i];
|
|
265
|
+
y = nbox.y - rbox.y - offset;
|
|
266
|
+
if (y < 0 || y > rbox.height - nbox.height / 2) {
|
|
222
267
|
return 0;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
useRange: true
|
|
261
|
-
});
|
|
262
|
-
this.textContent = "";
|
|
263
|
-
return this.appendChild(ret);
|
|
264
|
-
}
|
|
265
|
-
}).transition().duration(350).attr('opacity', function(d, i){
|
|
266
|
-
var nbox, y;
|
|
267
|
-
nbox = nboxes[i];
|
|
268
|
-
y = nbox.y - rbox.y - offset;
|
|
269
|
-
if (y < 0 || y > rbox.height - nbox.height / 2) {
|
|
270
|
-
return 0;
|
|
271
|
-
} else {
|
|
272
|
-
return 1;
|
|
273
|
-
}
|
|
274
|
-
}).attr('transform', function(d, i){
|
|
275
|
-
var nbox;
|
|
276
|
-
nbox = nboxes[i];
|
|
277
|
-
return "translate(" + (nbox.x - rbox.x) + ", " + (nbox.y - rbox.y - offset) + ")";
|
|
278
|
-
});
|
|
279
|
-
z1$ = this.g.link.selectAll('path').data(this.parsed);
|
|
280
|
-
z1$.exit().remove();
|
|
281
|
-
z1$.enter().append('path').attr('fill', 'none').attr('stroke-width', 1);
|
|
282
|
-
return this.g.link.selectAll('path').attr('stroke', function(d, i){
|
|
283
|
-
return tint.get(Math.ceil(((d.offset + d.value / 2) / total) * 5));
|
|
284
|
-
}).transition().duration(350).attr('d', function(d, i){
|
|
285
|
-
var x0, x1, x2, x3, y0, nbox, y1;
|
|
286
|
-
x0 = 0;
|
|
287
|
-
x1 = lbox.width / 10;
|
|
288
|
-
x2 = 9 * lbox.width / 10;
|
|
289
|
-
x3 = lbox.width;
|
|
290
|
-
y0 = scale.y(d.offset + d.value / 2);
|
|
291
|
-
nbox = nboxes[i];
|
|
292
|
-
y1 = (nbox.y - rbox.y) + nbox.height / 2 - offset;
|
|
293
|
-
if (Math.abs(y1 - y0) < 2) {
|
|
294
|
-
y1 = y0;
|
|
295
|
-
}
|
|
296
|
-
return "M" + x0 + " " + y0 + " L" + x1 + " " + y0 + " L" + x2 + " " + y1 + " L" + x3 + " " + y1;
|
|
297
|
-
}).attr('opacity', function(d, i){
|
|
298
|
-
var nbox, y0, y1;
|
|
299
|
-
nbox = nboxes[i];
|
|
300
|
-
y0 = scale.y(d.offset + d.value / 2);
|
|
301
|
-
y1 = (nbox.y - rbox.y) + nbox.height / 2 - offset;
|
|
302
|
-
if (Math.abs(y1 - y0) < 2) {
|
|
303
|
-
y1 = y0;
|
|
304
|
-
}
|
|
305
|
-
return y1 > rbox.height || y1 < 0 ? 0 : 1;
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
};
|
|
268
|
+
} else {
|
|
269
|
+
return 1;
|
|
270
|
+
}
|
|
271
|
+
}).attr('transform', function(d, i){
|
|
272
|
+
var nbox;
|
|
273
|
+
nbox = nboxes[i];
|
|
274
|
+
return "translate(" + (nbox.x - rbox.x) + ", " + (nbox.y - rbox.y - offset) + ")";
|
|
275
|
+
});
|
|
276
|
+
z1$ = this.g.link.selectAll('path').data(this.parsed);
|
|
277
|
+
z1$.exit().remove();
|
|
278
|
+
z1$.enter().append('path').attr('fill', 'none').attr('stroke-width', 1);
|
|
279
|
+
return this.g.link.selectAll('path').attr('stroke', function(d, i){
|
|
280
|
+
return tint.get(Math.ceil(((d.offset + d.value / 2) / total) * 5));
|
|
281
|
+
}).transition().duration(350).attr('d', function(d, i){
|
|
282
|
+
var x0, x1, x2, x3, y0, nbox, y1;
|
|
283
|
+
x0 = 0;
|
|
284
|
+
x1 = lbox.width / 10;
|
|
285
|
+
x2 = 9 * lbox.width / 10;
|
|
286
|
+
x3 = lbox.width;
|
|
287
|
+
y0 = scale.y(d.offset + d.value / 2);
|
|
288
|
+
nbox = nboxes[i];
|
|
289
|
+
y1 = (nbox.y - rbox.y) + nbox.height / 2 - offset;
|
|
290
|
+
if (Math.abs(y1 - y0) < 2) {
|
|
291
|
+
y1 = y0;
|
|
292
|
+
}
|
|
293
|
+
return "M" + x0 + " " + y0 + " L" + x1 + " " + y0 + " L" + x2 + " " + y1 + " L" + x3 + " " + y1;
|
|
294
|
+
}).attr('opacity', function(d, i){
|
|
295
|
+
var nbox, y0, y1;
|
|
296
|
+
nbox = nboxes[i];
|
|
297
|
+
y0 = scale.y(d.offset + d.value / 2);
|
|
298
|
+
y1 = (nbox.y - rbox.y) + nbox.height / 2 - offset;
|
|
299
|
+
if (Math.abs(y1 - y0) < 2) {
|
|
300
|
+
y1 = y0;
|
|
301
|
+
}
|
|
302
|
+
return y1 > rbox.height || y1 < 0 ? 0 : 1;
|
|
303
|
+
});
|
|
304
|
+
}
|
|
309
305
|
};
|
|
310
|
-
|
|
311
|
-
});
|
|
306
|
+
};
|
|
312
307
|
function import$(obj, src){
|
|
313
308
|
var own = {}.hasOwnProperty;
|
|
314
309
|
for (var key in src) if (own.call(src, key)) obj[key] = src[key];
|