@plotdb/chart 1.0.1 → 1.0.2
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/package.json +3 -1
- package/CHANGELOG.md +0 -29
- package/build +0 -45
- package/doc/charts.md +0 -58
- package/doc/config.md +0 -44
- package/doc/draft/chart.md +0 -146
- package/doc/draft/data.md +0 -8
- package/doc/draft/definition.md +0 -0
- package/doc/draft/events.md +0 -0
- package/doc/draft/filter.md +0 -0
- package/doc/draft/lifecycle.md +0 -89
- package/doc/spec.md +0 -89
- package/doc/todo.md +0 -27
- package/doc/utils/tip.md +0 -84
- package/src/data/en-US/category +0 -20
- package/src/data/en-US/fruit +0 -39
- package/src/data/en-US/movie +0 -125
- package/src/data/en-US/name +0 -58
- package/src/data/index.ls +0 -34
- package/src/data/zh-TW/category +0 -20
- package/src/data/zh-TW/fruits +0 -38
- package/src/data/zh-TW/movie +0 -125
- package/src/data/zh-TW/names +0 -105
- package/src/index.ls +0 -323
- package/src/index.styl +0 -6
- package/src/utils/axis.ls +0 -229
- package/src/utils/config.ls +0 -11
- package/src/utils/data.ls +0 -104
- package/src/utils/format.ls +0 -30
- package/src/utils/legend.ls +0 -134
- package/src/utils/legend.styl +0 -37
- package/src/utils/tint.ls +0 -66
- package/src/utils/tip.ls +0 -97
- package/web/src/pug/base.pug +0 -21
- package/web/src/pug/block/axis/0.0.1/index.ls +0 -32
- package/web/src/pug/block/axis/0.0.1/index.pug +0 -1
- package/web/src/pug/block/axis-bubble/0.0.1/index.ls +0 -137
- package/web/src/pug/block/axis-bubble/0.0.1/index.pug +0 -1
- package/web/src/pug/block/bar/0.0.1/index.ls +0 -270
- package/web/src/pug/block/bar/0.0.1/index.pug +0 -35
- package/web/src/pug/block/bar-list/0.0.1/index.ls +0 -81
- package/web/src/pug/block/bar-list/0.0.1/index.pug +0 -30
- package/web/src/pug/block/bar-race/0.0.1/index.ls +0 -79
- package/web/src/pug/block/bar-race/0.0.1/index.pug +0 -21
- package/web/src/pug/block/base/0.0.1/index.ls +0 -66
- package/web/src/pug/block/base/0.0.1/index.pug +0 -5
- package/web/src/pug/block/blank/0.0.1/index.ls +0 -21
- package/web/src/pug/block/blank/0.0.1/index.pug +0 -1
- package/web/src/pug/block/bubble/0.0.1/index.ls +0 -218
- package/web/src/pug/block/bubble/0.0.1/index.pug +0 -42
- package/web/src/pug/block/curve-bar/0.0.1/index.ls +0 -85
- package/web/src/pug/block/curve-bar/0.0.1/index.pug +0 -16
- package/web/src/pug/block/curve-bar/0.0.1/sample.js +0 -338
- package/web/src/pug/block/dumbbell/0.0.1/index.ls +0 -86
- package/web/src/pug/block/dumbbell/0.0.1/index.pug +0 -1
- package/web/src/pug/block/empty/0.0.1/index.ls +0 -28
- package/web/src/pug/block/empty/0.0.1/index.pug +0 -2
- package/web/src/pug/block/gauge/0.0.1/index.ls +0 -96
- package/web/src/pug/block/gauge/0.0.1/index.pug +0 -31
- package/web/src/pug/block/gauge/0.0.1/sample.js +0 -338
- package/web/src/pug/block/line/0.0.1/index.ls +0 -297
- package/web/src/pug/block/line/0.0.1/index.pug +0 -33
- package/web/src/pug/block/number/0.0.1/index.ls +0 -65
- package/web/src/pug/block/number/0.0.1/index.pug +0 -20
- package/web/src/pug/block/percent-list/0.0.1/index.ls +0 -161
- package/web/src/pug/block/percent-list/0.0.1/index.pug +0 -34
- package/web/src/pug/block/pie/0.0.1/index.ls +0 -121
- package/web/src/pug/block/pie/0.0.1/index.pug +0 -19
- package/web/src/pug/block/pie/0.0.1/sample.js +0 -338
- package/web/src/pug/block/pie-bubble/0.0.1/index.ls +0 -181
- package/web/src/pug/block/pie-bubble/0.0.1/index.pug +0 -40
- package/web/src/pug/block/radar/0.0.1/index.ls +0 -109
- package/web/src/pug/block/radar/0.0.1/index.pug +0 -1
- package/web/src/pug/block/radar/0.0.1/xx +0 -285
- package/web/src/pug/block/scatter/0.0.1/index.ls +0 -124
- package/web/src/pug/block/scatter/0.0.1/index.pug +0 -30
- package/web/src/pug/block/sheet/0.0.1/index.ls +0 -34
- package/web/src/pug/block/sheet/0.0.1/index.pug +0 -5
- package/web/src/pug/block/table/0.0.1/index.ls +0 -36
- package/web/src/pug/block/table/0.0.1/index.pug +0 -3
- package/web/src/pug/block/taiwancounty/0.0.1/index.ls +0 -70
- package/web/src/pug/block/taiwancounty/0.0.1/index.pug +0 -64
- package/web/src/pug/block/taiwantown/0.0.1/index.ls +0 -44
- package/web/src/pug/block/taiwantown/0.0.1/index.pug +0 -52
- package/web/src/pug/block/taiwanvillage/0.0.1/index.ls +0 -49
- package/web/src/pug/block/taiwanvillage/0.0.1/index.pug +0 -52
- package/web/src/pug/block/treemap/0.0.1/index.ls +0 -168
- package/web/src/pug/block/treemap/0.0.1/index.pug +0 -42
- package/web/src/pug/block/voronoi-treemap/0.0.1/index.ls +0 -170
- package/web/src/pug/block/voronoi-treemap/0.0.1/index.pug +0 -17
- package/web/src/pug/block/voronoi-treemap/0.0.1/sample.js +0 -241
- package/web/src/pug/block/wordcloud/0.0.1/index.ls +0 -57
- package/web/src/pug/block/wordcloud/0.0.1/index.pug +0 -1
- package/web/src/pug/block/worldmap/0.0.1/index.ls +0 -77
- package/web/src/pug/block/worldmap/0.0.1/index.pug +0 -12
- package/web/src/pug/index.ls +0 -72
- package/web/src/pug/index.pug +0 -51
- package/web/src/styl/index.styl +0 -6
- package/web/static/assets/block/cache.js +0 -4
- package/web/static/assets/custom-lib/d3/d3-array.v2.js +0 -1182
- package/web/static/assets/custom-lib/d3/d3-array.v2.min.js +0 -2
- package/web/static/assets/custom-lib/d3/d3-array.v3.js +0 -1273
- package/web/static/assets/custom-lib/d3/d3-array.v3.min.js +0 -1273
- package/web/static/assets/custom-lib/d3/d3-axis.v2.min.js +0 -2
- package/web/static/assets/custom-lib/d3/d3-brush.v2.min.js +0 -2
- package/web/static/assets/custom-lib/d3/d3-color.v2.min.js +0 -2
- package/web/static/assets/custom-lib/d3/d3-dispatch.v2.min.js +0 -2
- package/web/static/assets/custom-lib/d3/d3-drag.v2.min.js +0 -2
- package/web/static/assets/custom-lib/d3/d3-ease.v2.min.js +0 -2
- package/web/static/assets/custom-lib/d3/d3-force-boundary.v0.0.1.min.js +0 -2
- package/web/static/assets/custom-lib/d3/d3-force.v2.min.js +0 -2
- package/web/static/assets/custom-lib/d3/d3-format.v2.min.js +0 -2
- package/web/static/assets/custom-lib/d3/d3-geo.v2.js +0 -3127
- package/web/static/assets/custom-lib/d3/d3-geo.v2.min.js +0 -2
- package/web/static/assets/custom-lib/d3/d3-hierarchy.v2.min.js +0 -2
- package/web/static/assets/custom-lib/d3/d3-interpolate.v2.min.js +0 -2
- package/web/static/assets/custom-lib/d3/d3-path.v2.min.js +0 -2
- package/web/static/assets/custom-lib/d3/d3-quadtree.v2.min.js +0 -2
- package/web/static/assets/custom-lib/d3/d3-random.v2.min.js +0 -2
- package/web/static/assets/custom-lib/d3/d3-scale-chromatic.v1.min.js +0 -2
- package/web/static/assets/custom-lib/d3/d3-selection.v2.min.js +0 -2
- package/web/static/assets/custom-lib/d3/d3-shape.v2.min.js +0 -2
- package/web/static/assets/custom-lib/d3/d3-timer.v2.min.js +0 -2
- package/web/static/assets/custom-lib/d3/d3-transition.v2.min.js +0 -2
- package/web/static/assets/custom-lib/d3/d3.v4.js +0 -17178
- package/web/static/assets/custom-lib/d3/d3.v4.min.js +0 -2
- package/web/static/assets/custom-lib/d3/d3.v6.js +0 -19708
- package/web/static/assets/data/countrycode.json +0 -1
- package/web/static/assets/data/world-110m.json +0 -1
- package/web/static/assets/data/zh-to-alpha2.json +0 -1
- package/web/static/assets/img/fluid.svg +0 -16
- package/web/static/block/axis/0.0.1/index.html +0 -74
- package/web/static/block/axis-bubble/0.0.1/index.html +0 -217
- package/web/static/block/bar/0.0.1/index.html +0 -576
- package/web/static/block/bar-list/0.0.1/index.html +0 -226
- package/web/static/block/bar-race/0.0.1/index.html +0 -179
- package/web/static/block/base/0.0.1/index.html +0 -197
- package/web/static/block/blank/0.0.1/index.html +0 -37
- package/web/static/block/bubble/0.0.1/index.html +0 -422
- package/web/static/block/bubble/0.0.1/test.html +0 -0
- package/web/static/block/curve-bar/0.0.1/index.html +0 -143
- package/web/static/block/dumbbell/0.0.1/index.html +0 -173
- package/web/static/block/empty/0.0.1/index.html +0 -76
- package/web/static/block/gauge/0.0.1/index.html +0 -145
- package/web/static/block/line/0.0.1/index.html +0 -566
- package/web/static/block/number/0.0.1/index.html +0 -147
- package/web/static/block/percent-list/0.0.1/index.html +0 -311
- package/web/static/block/pie/0.0.1/index.html +0 -276
- package/web/static/block/pie-bubble/0.0.1/index.html +0 -353
- package/web/static/block/radar/0.0.1/index.html +0 -144
- package/web/static/block/scatter/0.0.1/index.html +0 -246
- package/web/static/block/sheet/0.0.1/index.html +0 -98
- package/web/static/block/table/0.0.1/index.html +0 -67
- package/web/static/block/taiwancounty/0.0.1/index.html +0 -197
- package/web/static/block/taiwantown/0.0.1/index.html +0 -205
- package/web/static/block/taiwanvillage/0.0.1/index.html +0 -215
- package/web/static/block/treemap/0.0.1/index.html +0 -355
- package/web/static/block/voronoi-treemap/0.0.1/index.html +0 -345
- package/web/static/block/wordcloud/0.0.1/index.html +0 -87
- package/web/static/block/worldmap/0.0.1/index.html +0 -202
- package/web/static/css/index.css +0 -6
- package/web/static/css/index.min.css +0 -1
- package/web/static/favicon.ico +0 -0
- package/web/static/index.html +0 -153
|
@@ -1,576 +0,0 @@
|
|
|
1
|
-
<div><div plug="layout"><div class="pdl-layout"><div data-type="layout"><div class="pdl-cell" data-name="yaxis"> </div><div class="pdl-cell" data-name="view"></div><div class="pdl-cell"></div><div class="pdl-cell" data-name="xaxis"> </div><div class="pdl-cell" data-name="legend"> </div></div><div data-type="render"></div></div></div><style type="text/css">[data-name=xaxis] {
|
|
2
|
-
font-size: 0.8em;
|
|
3
|
-
}
|
|
4
|
-
[data-name=yaxis] {
|
|
5
|
-
font-size: 0.8em;
|
|
6
|
-
}
|
|
7
|
-
.pdl-layout > div[data-type=layout] {
|
|
8
|
-
display: grid;
|
|
9
|
-
grid-template-columns: fit-content(2em) 1fr fit-content(10em);
|
|
10
|
-
grid-template-rows: 1fr fit-content(1em);
|
|
11
|
-
/* 0.5em for axis label at the boundary */
|
|
12
|
-
padding: 0 0.5em;
|
|
13
|
-
}
|
|
14
|
-
.pdl-layout > div[data-type=layout] > .pdl-cell[data-name=legend] {
|
|
15
|
-
grid-column: 3;
|
|
16
|
-
grid-row: 1/span 2;
|
|
17
|
-
padding-left: 1em;
|
|
18
|
-
}
|
|
19
|
-
.pdl-layout.legend-below > div[data-type=layout] {
|
|
20
|
-
grid-template-columns: 2em 1fr;
|
|
21
|
-
grid-template-rows: 1fr fit-content(2em) fit-content(3em);
|
|
22
|
-
}
|
|
23
|
-
.pdl-layout.legend-below > div[data-type=layout] .pdl-cell[data-name=legend] {
|
|
24
|
-
padding-top: 1em;
|
|
25
|
-
grid-column: 1/span 2;
|
|
26
|
-
grid-row: 3;
|
|
27
|
-
}
|
|
28
|
-
</style><script type="@plotdb/block">var mod;
|
|
29
|
-
module.exports = {
|
|
30
|
-
pkg: {
|
|
31
|
-
name: 'bar',
|
|
32
|
-
version: '0.0.1',
|
|
33
|
-
extend: {
|
|
34
|
-
name: "base",
|
|
35
|
-
version: "0.0.1"
|
|
36
|
-
},
|
|
37
|
-
dependencies: [],
|
|
38
|
-
i18n: {
|
|
39
|
-
"zh-TW": {
|
|
40
|
-
"size": "長度"
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
init: function(arg$){
|
|
45
|
-
var root, context, t, pubsub;
|
|
46
|
-
root = arg$.root, context = arg$.context, t = arg$.t, pubsub = arg$.pubsub;
|
|
47
|
-
return pubsub.fire('init', {
|
|
48
|
-
mod: mod({
|
|
49
|
-
context: context,
|
|
50
|
-
t: t
|
|
51
|
-
})
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
mod = function(arg$){
|
|
56
|
-
var context, t, chart, d3, debounce, ref$;
|
|
57
|
-
context = arg$.context, t = arg$.t;
|
|
58
|
-
chart = context.chart, d3 = context.d3, debounce = context.debounce;
|
|
59
|
-
return {
|
|
60
|
-
sample: function(){
|
|
61
|
-
return {
|
|
62
|
-
raw: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(function(val){
|
|
63
|
-
var ret, i$, i;
|
|
64
|
-
ret = {
|
|
65
|
-
name: val
|
|
66
|
-
};
|
|
67
|
-
for (i$ = 1; i$ <= 4; ++i$) {
|
|
68
|
-
i = i$;
|
|
69
|
-
ret["val" + i] = Math.random();
|
|
70
|
-
}
|
|
71
|
-
return ret;
|
|
72
|
-
}),
|
|
73
|
-
binding: {
|
|
74
|
-
size: [1, 2, 3, 4].map(function(it){
|
|
75
|
-
return {
|
|
76
|
-
key: "val" + it,
|
|
77
|
-
unit: "amount"
|
|
78
|
-
};
|
|
79
|
-
}),
|
|
80
|
-
name: {
|
|
81
|
-
key: "name"
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
},
|
|
86
|
-
config: (ref$ = import$({}, chart.utils.config.preset['default']), ref$.sort = {
|
|
87
|
-
enabled: {
|
|
88
|
-
type: 'boolean'
|
|
89
|
-
},
|
|
90
|
-
dir: {
|
|
91
|
-
type: 'choice',
|
|
92
|
-
values: ['asc', 'desc', 'none']
|
|
93
|
-
}
|
|
94
|
-
}, ref$.type = {
|
|
95
|
-
type: 'choice',
|
|
96
|
-
values: ['bar', 'column'],
|
|
97
|
-
'default': 'column'
|
|
98
|
-
}, ref$),
|
|
99
|
-
dimension: {
|
|
100
|
-
size: {
|
|
101
|
-
type: 'R',
|
|
102
|
-
multiple: true,
|
|
103
|
-
name: "size"
|
|
104
|
-
},
|
|
105
|
-
name: {
|
|
106
|
-
type: 'NO',
|
|
107
|
-
name: "name"
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
init: function(){
|
|
111
|
-
var tint, brush, scale, this$ = this;
|
|
112
|
-
this.tint = tint = new chart.utils.tint();
|
|
113
|
-
[['multiple', 'stack'], ['percent', false], ['dancing', true]].map(function(arg$){
|
|
114
|
-
var k, v;
|
|
115
|
-
k = arg$[0], v = arg$[1];
|
|
116
|
-
if (!(this$.cfg[k] != null)) {
|
|
117
|
-
return this$.cfg[k] = v;
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
this.svg.addEventListener('click', function(){
|
|
121
|
-
if (!this$.cfg.dancing || this$.cfg.percent) {
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
this$.alignIdx = ((this$.alignIdx || 0) + 1) % (this$.binding.size.length + 1);
|
|
125
|
-
this$.resize();
|
|
126
|
-
return this$.render();
|
|
127
|
-
});
|
|
128
|
-
this.brush = d3.brushX();
|
|
129
|
-
this.g = Object.fromEntries(['view', 'xaxis', 'yaxis', 'legend'].map(function(it){
|
|
130
|
-
return [it, d3.select(this$.layout.getGroup(it))];
|
|
131
|
-
}));
|
|
132
|
-
this.range = "null";
|
|
133
|
-
brush = debounce(150, function(e){
|
|
134
|
-
var ref$, range, _range, domain, bandwidth;
|
|
135
|
-
if (((ref$ = this$.cfg).brush || (ref$.brush = {})).enabled != null && !this$.cfg.brush.enabled) {
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
range = e.selection;
|
|
139
|
-
if ((_range = JSON.stringify(range)) === this$.range) {
|
|
140
|
-
return;
|
|
141
|
-
} else {
|
|
142
|
-
this$.range = _range;
|
|
143
|
-
}
|
|
144
|
-
if (!range) {
|
|
145
|
-
return this$.filter({
|
|
146
|
-
name: undefined
|
|
147
|
-
}, true);
|
|
148
|
-
} else {
|
|
149
|
-
domain = this$.scale.x.domain();
|
|
150
|
-
bandwidth = this$.scale.x.bandwidth();
|
|
151
|
-
range = range.map(function(it){
|
|
152
|
-
var ref$, ref1$, ref2$;
|
|
153
|
-
return (ref$ = (ref2$ = Math.floor(it / bandwidth)) > 0 ? ref2$ : 0) < (ref1$ = domain.length - 1) ? ref$ : ref1$;
|
|
154
|
-
});
|
|
155
|
-
range = (function(){
|
|
156
|
-
var i$, to$, results$ = [];
|
|
157
|
-
for (i$ = range[0], to$ = range[1]; i$ <= to$; ++i$) {
|
|
158
|
-
results$.push(i$);
|
|
159
|
-
}
|
|
160
|
-
return results$;
|
|
161
|
-
}()).map(function(it){
|
|
162
|
-
return domain[it];
|
|
163
|
-
});
|
|
164
|
-
return this$.filter({
|
|
165
|
-
name: {
|
|
166
|
-
type: 'index',
|
|
167
|
-
value: range
|
|
168
|
-
}
|
|
169
|
-
}, true);
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
this.brush.on('end', brush);
|
|
173
|
-
this.brush.on('brush', brush);
|
|
174
|
-
this.scale = scale = {};
|
|
175
|
-
this.yaxis = new chart.utils.axis({
|
|
176
|
-
layout: this.layout,
|
|
177
|
-
name: 'yaxis',
|
|
178
|
-
direction: 'left'
|
|
179
|
-
});
|
|
180
|
-
this.xaxis = new chart.utils.axis({
|
|
181
|
-
layout: this.layout,
|
|
182
|
-
name: 'xaxis',
|
|
183
|
-
direction: 'bottom'
|
|
184
|
-
});
|
|
185
|
-
return this.legend = new chart.utils.legend({
|
|
186
|
-
layout: this.layout,
|
|
187
|
-
name: 'legend',
|
|
188
|
-
root: this.root,
|
|
189
|
-
shape: function(d){
|
|
190
|
-
return d3.select(this).attr('fill', tint.get(d.key));
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
},
|
|
194
|
-
destroy: function(){
|
|
195
|
-
if (this.tip) {
|
|
196
|
-
return this.tip.destroy();
|
|
197
|
-
}
|
|
198
|
-
},
|
|
199
|
-
filter: function(filters, internal){
|
|
200
|
-
var this$ = this;
|
|
201
|
-
internal == null && (internal = false);
|
|
202
|
-
this.render();
|
|
203
|
-
if (internal) {
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
return this.brush.move(this.g.view, filters.name ? filters.name.map(function(it){
|
|
207
|
-
return this$.scale.x(it);
|
|
208
|
-
}) : null);
|
|
209
|
-
},
|
|
210
|
-
parse: function(){
|
|
211
|
-
this.data.map(function(d){
|
|
212
|
-
return d.size = d.size.map(function(it){
|
|
213
|
-
if (isNaN(it)) {
|
|
214
|
-
return 0;
|
|
215
|
-
} else {
|
|
216
|
-
return it;
|
|
217
|
-
}
|
|
218
|
-
});
|
|
219
|
-
});
|
|
220
|
-
return this.alignIdx = undefined;
|
|
221
|
-
},
|
|
222
|
-
resize: function(){
|
|
223
|
-
var alignIdx, ref$, ref1$, delta, max, i, box, maxTick, yticks, v, xticks, i$, w, h, r, this$ = this;
|
|
224
|
-
this.type = this.cfg.type || 'column';
|
|
225
|
-
this.legend.config(this.cfg.legend);
|
|
226
|
-
this.legend.update();
|
|
227
|
-
this.layout.update(false);
|
|
228
|
-
this.maxPerGroup = this.binding.size.map(function(d, i){
|
|
229
|
-
return Math.max.apply(Math, this$.data.map(function(it){
|
|
230
|
-
return it.size[i];
|
|
231
|
-
}));
|
|
232
|
-
});
|
|
233
|
-
if (this.cfg.alignIdx && !this.alignIdx) {
|
|
234
|
-
this.alignIdx = this.cfg.alignIdx;
|
|
235
|
-
}
|
|
236
|
-
alignIdx = (ref$ = this.cfg.percent
|
|
237
|
-
? 0
|
|
238
|
-
: this.alignIdx || 0) < (ref1$ = this.binding.size.length) ? ref$ : ref1$;
|
|
239
|
-
this.baseOffset = this.data.map(function(d){
|
|
240
|
-
return (function(){
|
|
241
|
-
var i$, to$, results$ = [];
|
|
242
|
-
for (i$ = 0, to$ = alignIdx; i$ < to$; ++i$) {
|
|
243
|
-
results$.push(i$);
|
|
244
|
-
}
|
|
245
|
-
return results$;
|
|
246
|
-
}()).reduce(function(a, b){
|
|
247
|
-
return a + d.size[b];
|
|
248
|
-
}, 0) || 0;
|
|
249
|
-
});
|
|
250
|
-
this.delta = delta = Math.max.apply(Math, this.baseOffset);
|
|
251
|
-
if (this.cfg.multiple === 'stack') {
|
|
252
|
-
if (this.cfg.percent) {
|
|
253
|
-
max = 1;
|
|
254
|
-
} else {
|
|
255
|
-
max = Math.max.apply(Math, this.data.map(function(d){
|
|
256
|
-
return (function(){
|
|
257
|
-
var i$, to$, results$ = [];
|
|
258
|
-
for (i$ = alignIdx, to$ = d.size.length; i$ < to$; ++i$) {
|
|
259
|
-
results$.push(i$);
|
|
260
|
-
}
|
|
261
|
-
return results$;
|
|
262
|
-
}()).reduce(function(a, b){
|
|
263
|
-
return a + d.size[b];
|
|
264
|
-
}, 0);
|
|
265
|
-
})) + (delta || 0);
|
|
266
|
-
}
|
|
267
|
-
} else if (this.cfg.multiple === 'group') {
|
|
268
|
-
max = Math.max.apply(Math, this.data.map(function(d){
|
|
269
|
-
return Math.max.apply(Math, d.size);
|
|
270
|
-
}));
|
|
271
|
-
} else if (this.cfg.multiple === 'split') {
|
|
272
|
-
max = this.maxPerGroup.reduce(function(a, b){
|
|
273
|
-
return a + b;
|
|
274
|
-
}, 0);
|
|
275
|
-
}
|
|
276
|
-
this.order = this.data.map(function(d, i){
|
|
277
|
-
return {
|
|
278
|
-
key: d._idx,
|
|
279
|
-
idx: i,
|
|
280
|
-
name: d.name
|
|
281
|
-
};
|
|
282
|
-
});
|
|
283
|
-
this.data.map(function(d, i){
|
|
284
|
-
return d.sum = d.size.reduce(function(a, b){
|
|
285
|
-
return a + b;
|
|
286
|
-
}, 0);
|
|
287
|
-
});
|
|
288
|
-
if (((ref$ = this.cfg).sort || (ref$.sort = {})).enabled) {
|
|
289
|
-
this.order.sort(function(a, b){
|
|
290
|
-
return (this$.cfg.sort.dir === 'asc'
|
|
291
|
-
? 1
|
|
292
|
-
: -1) * (this$.data[a.idx].sum - this$.data[b.idx].sum);
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
|
-
console.log(this.cfg);
|
|
296
|
-
if (this.cfg.palette) {
|
|
297
|
-
this.tint.set(this.cfg.palette.colors.map(function(it){
|
|
298
|
-
return it.value || it;
|
|
299
|
-
}));
|
|
300
|
-
}
|
|
301
|
-
this.legend.data((function(){
|
|
302
|
-
var i$, results$ = [];
|
|
303
|
-
for (i$ = this.binding.size.length - 1; i$ >= 0; --i$) {
|
|
304
|
-
i = i$;
|
|
305
|
-
results$.push({
|
|
306
|
-
key: i,
|
|
307
|
-
text: this.binding.size[i].name || this.binding.size[i].key
|
|
308
|
-
});
|
|
309
|
-
}
|
|
310
|
-
return results$;
|
|
311
|
-
}.call(this)));
|
|
312
|
-
this.layout.update(false);
|
|
313
|
-
box = this.layout.getBox('view');
|
|
314
|
-
if (this.type === 'column') {
|
|
315
|
-
ref$ = this.scale;
|
|
316
|
-
ref$.y = d3.scaleLinear().domain([0, max]).range([box.height, 0]);
|
|
317
|
-
ref$.x = d3.scaleBand().domain(this.order.map(function(it){
|
|
318
|
-
return it.name || it.key;
|
|
319
|
-
})).range([0, box.width]);
|
|
320
|
-
maxTick = (ref$ = Math.ceil(this.layout.getBox('yaxis').height / 40)) > 2 ? ref$ : 2;
|
|
321
|
-
yticks = this.cfg.bump
|
|
322
|
-
? (function(){
|
|
323
|
-
var i$, to$, ref$, results$ = [];
|
|
324
|
-
for (i$ = 1, to$ = (ref$ = this.parsed.length || 1) > 1 ? ref$ : 1; i$ <= to$; ++i$) {
|
|
325
|
-
results$.push(i$);
|
|
326
|
-
}
|
|
327
|
-
return results$;
|
|
328
|
-
}.call(this))
|
|
329
|
-
: this.scale.y.ticks((ref$ = ((ref1$ = this.cfg).yaxis || (ref1$.yaxis = {})).tickCount || 4) < maxTick ? ref$ : maxTick);
|
|
330
|
-
this.yaxis.config(this.cfg.yaxis);
|
|
331
|
-
v = this.binding.size[0] || {};
|
|
332
|
-
if (this.binding.size.length > 1) {
|
|
333
|
-
this.yaxis.caption(v.unit ? v.unit + "" : '');
|
|
334
|
-
} else {
|
|
335
|
-
this.yaxis.caption((v.name || v.key || '') + (v.unit ? "(" + v.unit + ")" : ''));
|
|
336
|
-
}
|
|
337
|
-
this.yaxis.ticks(yticks);
|
|
338
|
-
this.yaxis.scale(this.scale.y);
|
|
339
|
-
this.xaxis.config((ref$ = this.cfg).xaxis || (ref$.xaxis = {}));
|
|
340
|
-
this.xaxis.ticks(this.data.map(function(it){
|
|
341
|
-
return it.name;
|
|
342
|
-
}));
|
|
343
|
-
this.xaxis.scale(this.scale.x);
|
|
344
|
-
this.xaxis.caption((this.binding.name.name || this.binding.name.key) + (this.binding.name.unit ? "(" + this.binding.name.unit + ")" : ''));
|
|
345
|
-
} else {
|
|
346
|
-
ref$ = this.scale;
|
|
347
|
-
ref$.x = d3.scaleLinear().domain([0, max]).range([box.width, 0]);
|
|
348
|
-
ref$.y = d3.scaleBand().domain(this.order.map(function(it){
|
|
349
|
-
return it.name || it.key;
|
|
350
|
-
})).range([0, box.height]);
|
|
351
|
-
maxTick = (ref$ = Math.ceil(this.layout.getBox('xaxis').width / 80)) > 2 ? ref$ : 2;
|
|
352
|
-
xticks = this.cfg.bump
|
|
353
|
-
? (function(){
|
|
354
|
-
var i$, to$, ref$, results$ = [];
|
|
355
|
-
for (i$ = 1, to$ = (ref$ = this.parsed.length || 1) > 1 ? ref$ : 1; i$ <= to$; ++i$) {
|
|
356
|
-
results$.push(i$);
|
|
357
|
-
}
|
|
358
|
-
return results$;
|
|
359
|
-
}.call(this))
|
|
360
|
-
: this.scale.x.ticks((ref$ = ((ref1$ = this.cfg).xaxis || (ref1$.xaxis = {})).tickCount || 4) < maxTick ? ref$ : maxTick);
|
|
361
|
-
this.xaxis.config(this.cfg.xaxis);
|
|
362
|
-
v = this.binding.size[0] || {};
|
|
363
|
-
if (this.binding.size.length > 1) {
|
|
364
|
-
this.xaxis.caption(v.unit ? v.unit + "" : '');
|
|
365
|
-
} else {
|
|
366
|
-
this.xaxis.caption((v.name || v.key || '') + (v.unit ? "(" + v.unit + ")" : ''));
|
|
367
|
-
}
|
|
368
|
-
this.xaxis.ticks(xticks);
|
|
369
|
-
this.xaxis.scale(this.scale.x);
|
|
370
|
-
this.yaxis.config((ref$ = this.cfg).yaxis || (ref$.yaxis = {}));
|
|
371
|
-
this.yaxis.ticks(this.data.map(function(it){
|
|
372
|
-
return it.name;
|
|
373
|
-
}));
|
|
374
|
-
this.yaxis.scale(this.scale.y);
|
|
375
|
-
this.yaxis.caption((this.binding.name.name || this.binding.name.key) + (this.binding.name.unit ? "(" + this.binding.name.unit + ")" : ''));
|
|
376
|
-
}
|
|
377
|
-
for (i$ = 0; i$ < 2; ++i$) {
|
|
378
|
-
i = i$;
|
|
379
|
-
this.layout.update(false);
|
|
380
|
-
box = this.layout.getBox('view');
|
|
381
|
-
ref$ = [box.width, box.height], w = ref$[0], h = ref$[1];
|
|
382
|
-
this.tint.set(this.cfg.palette);
|
|
383
|
-
r = this.cfg.dotSize || 3;
|
|
384
|
-
this.scale.x.range([0, w - r]);
|
|
385
|
-
this.scale.y.range([h, r]);
|
|
386
|
-
this.xaxis.render();
|
|
387
|
-
this.yaxis.render();
|
|
388
|
-
}
|
|
389
|
-
box = this.layout.getBox('view');
|
|
390
|
-
return this.brush.extent([[0, 1], [box.width, box.height - 1]]);
|
|
391
|
-
},
|
|
392
|
-
render: function(){
|
|
393
|
-
var binding, scale, range, delta, baseOffset, maxPerGroup, cfg, tint, data, type, x$, ref$, this$ = this;
|
|
394
|
-
binding = this.binding, scale = this.scale, range = this.range, delta = this.delta, baseOffset = this.baseOffset, maxPerGroup = this.maxPerGroup, cfg = this.cfg, tint = this.tint, data = this.data, type = this.type;
|
|
395
|
-
x$ = this.g.view.selectAll('g.bar').data(this.data);
|
|
396
|
-
x$.exit().remove();
|
|
397
|
-
x$.enter().append('g').attr('class', 'bar');
|
|
398
|
-
this.g.view.selectAll('g.bar').attr('transform', function(d, i){
|
|
399
|
-
if (this$.type === 'column') {
|
|
400
|
-
return "translate(" + scale.x(d.name) + ",0)";
|
|
401
|
-
} else {
|
|
402
|
-
return "translate(0," + scale.y(d.name) + ")";
|
|
403
|
-
}
|
|
404
|
-
}).each(function(item, j){
|
|
405
|
-
var ref$, bars, offset, sum, i$, to$, idx, size, key, x$, y$, tran;
|
|
406
|
-
ref$ = [[], 0], bars = ref$[0], offset = ref$[1];
|
|
407
|
-
offset = delta - baseOffset[j];
|
|
408
|
-
sum = 1;
|
|
409
|
-
if (cfg.percent === true) {
|
|
410
|
-
sum = (ref$ = item.size.reduce(function(a, b){
|
|
411
|
-
return a + b;
|
|
412
|
-
}, 0)) > 1 ? ref$ : 1;
|
|
413
|
-
}
|
|
414
|
-
for (i$ = 0, to$ = item.size.length; i$ < to$; ++i$) {
|
|
415
|
-
idx = i$;
|
|
416
|
-
size = item.size[idx];
|
|
417
|
-
key = idx;
|
|
418
|
-
bars.push({
|
|
419
|
-
size: size / sum,
|
|
420
|
-
offset: offset / sum,
|
|
421
|
-
key: key,
|
|
422
|
-
group: item.name,
|
|
423
|
-
name: binding.size[key].name || binding.size[key].key,
|
|
424
|
-
unit: binding.size[key].unit || ''
|
|
425
|
-
});
|
|
426
|
-
if (cfg.multiple === 'split') {
|
|
427
|
-
offset += maxPerGroup[idx];
|
|
428
|
-
} else if (cfg.multiple === 'stack') {
|
|
429
|
-
offset += size;
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
x$ = d3.select(this).selectAll('rect').data(bars, function(d, i){
|
|
433
|
-
return d.key;
|
|
434
|
-
});
|
|
435
|
-
x$.exit().remove();
|
|
436
|
-
y$ = x$.enter().append('rect');
|
|
437
|
-
if (type === 'column') {
|
|
438
|
-
y$.attr('width', function(d, i){
|
|
439
|
-
var ref$;
|
|
440
|
-
return (ref$ = scale.x.bandwidth() - 2) > 1 ? ref$ : 1;
|
|
441
|
-
});
|
|
442
|
-
}
|
|
443
|
-
if (type === 'column') {
|
|
444
|
-
y$.attr('y', function(d, i){
|
|
445
|
-
return scale.y(0);
|
|
446
|
-
});
|
|
447
|
-
}
|
|
448
|
-
if (type !== 'column') {
|
|
449
|
-
y$.attr('height', function(d, i){
|
|
450
|
-
var ref$;
|
|
451
|
-
return (ref$ = scale.y.bandwidth() - 2) > 1 ? ref$ : 1;
|
|
452
|
-
});
|
|
453
|
-
}
|
|
454
|
-
if (type !== 'column') {
|
|
455
|
-
y$.attr('x', function(d, i){
|
|
456
|
-
return scale.x(0);
|
|
457
|
-
});
|
|
458
|
-
}
|
|
459
|
-
tran = d3.select(this).selectAll('rect').transition().duration(350).call(function(sel){
|
|
460
|
-
var x$;
|
|
461
|
-
if (cfg.multiple !== 'group') {
|
|
462
|
-
return;
|
|
463
|
-
}
|
|
464
|
-
x$ = sel;
|
|
465
|
-
if (type === 'column') {
|
|
466
|
-
x$.attr('x', function(d, i){
|
|
467
|
-
return 1 + i * (scale.x.bandwidth() - 2) / bars.length;
|
|
468
|
-
});
|
|
469
|
-
}
|
|
470
|
-
if (type === 'column') {
|
|
471
|
-
x$.attr('width', function(d, i){
|
|
472
|
-
return (scale.x.bandwidth() - 2) / bars.length;
|
|
473
|
-
});
|
|
474
|
-
}
|
|
475
|
-
if (type === 'column') {
|
|
476
|
-
x$.attr('y', function(d, i){
|
|
477
|
-
return Math.round(Math.min(scale.y(0), scale.y(d.size)));
|
|
478
|
-
});
|
|
479
|
-
}
|
|
480
|
-
if (type !== 'column') {
|
|
481
|
-
x$.attr('y', function(d, i){
|
|
482
|
-
return 1 + i * (scale.y.bandwidth() - 2) / bars.length;
|
|
483
|
-
});
|
|
484
|
-
}
|
|
485
|
-
if (type !== 'column') {
|
|
486
|
-
x$.attr('height', function(d, i){
|
|
487
|
-
return (scale.y.bandwidth() - 2) / bars.length;
|
|
488
|
-
});
|
|
489
|
-
}
|
|
490
|
-
if (type !== 'column') {
|
|
491
|
-
x$.attr('x', function(d, i){
|
|
492
|
-
return Math.round(Math.min(scale.x(0), scale.x(d.size)));
|
|
493
|
-
});
|
|
494
|
-
}
|
|
495
|
-
return x$;
|
|
496
|
-
}).call(function(sel){
|
|
497
|
-
var x$;
|
|
498
|
-
if (cfg.multiple !== 'stack') {
|
|
499
|
-
return;
|
|
500
|
-
}
|
|
501
|
-
x$ = sel;
|
|
502
|
-
if (type === 'column') {
|
|
503
|
-
x$.attr('x', 1);
|
|
504
|
-
}
|
|
505
|
-
if (type === 'column') {
|
|
506
|
-
x$.attr('width', function(d, i){
|
|
507
|
-
return scale.x.bandwidth() - 2;
|
|
508
|
-
});
|
|
509
|
-
}
|
|
510
|
-
if (type === 'column') {
|
|
511
|
-
x$.attr('y', function(d, i){
|
|
512
|
-
return Math.round(Math.min(scale.y(d.offset), scale.y(d.offset + d.size)));
|
|
513
|
-
});
|
|
514
|
-
}
|
|
515
|
-
if (type !== 'column') {
|
|
516
|
-
x$.attr('y', 1);
|
|
517
|
-
}
|
|
518
|
-
if (type !== 'column') {
|
|
519
|
-
x$.attr('height', function(d, i){
|
|
520
|
-
return scale.y.bandwidth() - 2;
|
|
521
|
-
});
|
|
522
|
-
}
|
|
523
|
-
if (type !== 'column') {
|
|
524
|
-
x$.attr('x', function(d, i){
|
|
525
|
-
return Math.round(Math.min(scale.x(d.offset), scale.x(d.offset + d.size)));
|
|
526
|
-
});
|
|
527
|
-
}
|
|
528
|
-
return x$;
|
|
529
|
-
});
|
|
530
|
-
if (type === 'column') {
|
|
531
|
-
tran.attr('height', function(d, i){
|
|
532
|
-
return Math.round(Math.abs(scale.y(0) - scale.y(d.size)));
|
|
533
|
-
});
|
|
534
|
-
} else {
|
|
535
|
-
tran.attr('width', function(d, i){
|
|
536
|
-
return Math.round(Math.abs(scale.x(0) - scale.x(d.size)));
|
|
537
|
-
});
|
|
538
|
-
}
|
|
539
|
-
return tran.attr('fill', function(d, i){
|
|
540
|
-
return tint.get(i, cfg.colorVariant ? j / data.length - 0.5 : 0);
|
|
541
|
-
}).attr('fill-opacity', function(d, i){
|
|
542
|
-
var filter, range;
|
|
543
|
-
if (!(binding.name && (filter = binding.name.filter))) {
|
|
544
|
-
return 1;
|
|
545
|
-
}
|
|
546
|
-
if (!(range = filter.value)) {
|
|
547
|
-
return 1;
|
|
548
|
-
}
|
|
549
|
-
if (in$(item.name, range)) {
|
|
550
|
-
return 1;
|
|
551
|
-
} else {
|
|
552
|
-
return 0.2;
|
|
553
|
-
}
|
|
554
|
-
});
|
|
555
|
-
});
|
|
556
|
-
if (!(((ref$ = this.cfg).brush || (ref$.brush = {})).enabled != null && !this.cfg.brush.enabled)) {
|
|
557
|
-
this.g.view.call(this.brush);
|
|
558
|
-
}
|
|
559
|
-
this.g.view.selectAll('rect.selection').attr('shape-rendering', 'auto');
|
|
560
|
-
this.legend.render();
|
|
561
|
-
this.yaxis.render();
|
|
562
|
-
return this.xaxis.render();
|
|
563
|
-
},
|
|
564
|
-
tick: function(){}
|
|
565
|
-
};
|
|
566
|
-
};
|
|
567
|
-
function import$(obj, src){
|
|
568
|
-
var own = {}.hasOwnProperty;
|
|
569
|
-
for (var key in src) if (own.call(src, key)) obj[key] = src[key];
|
|
570
|
-
return obj;
|
|
571
|
-
}
|
|
572
|
-
function in$(x, xs){
|
|
573
|
-
var i = -1, l = xs.length >>> 0;
|
|
574
|
-
while (++i < l) if (x === xs[i]) return true;
|
|
575
|
-
return false;
|
|
576
|
-
}</script></div>
|