@plotdb/chart 0.0.3 → 2.0.0
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 +34 -1
- package/README.md +3 -3
- package/{dist/data → data}/index.js +0 -0
- package/{dist/chart.css → index.css} +0 -0
- package/{dist/chart.js → index.js} +3 -1
- package/{dist/chart.min.css → index.min.css} +0 -0
- package/index.min.js +1 -0
- package/package.json +1 -89
- package/{dist/utils → utils}/axis.js +6 -0
- package/utils/axis.min.js +1 -0
- package/{dist/utils → utils}/config.js +0 -0
- package/utils/config.min.js +1 -0
- package/{dist/utils → utils}/data.js +0 -0
- package/utils/data.min.js +1 -0
- package/{dist/utils → utils}/format.js +0 -0
- package/utils/format.min.js +1 -0
- package/{dist/utils → utils}/legend.css +0 -0
- package/{dist/utils → utils}/legend.js +0 -0
- package/{dist/utils → utils}/legend.min.css +0 -0
- package/utils/legend.min.js +1 -0
- package/{dist/utils → utils}/tint.js +0 -0
- package/utils/tint.min.js +1 -0
- package/{dist/utils → utils}/tip.js +0 -0
- package/utils/tip.min.js +1 -0
- package/build +0 -39
- package/dist/chart.min.js +0 -1
- package/dist/utils/axis.min.js +0 -1
- package/dist/utils/config.min.js +0 -1
- package/dist/utils/data.min.js +0 -1
- package/dist/utils/format.min.js +0 -1
- package/dist/utils/legend.min.js +0 -1
- package/dist/utils/tint.min.js +0 -1
- package/dist/utils/tip.min.js +0 -1
- 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/chart.ls +0 -323
- package/src/chart.styl +0 -6
- 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/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 -20
- package/web/src/pug/block/axis/0.0.1/index.ls +0 -38
- 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 -141
- 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 -274
- 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 -85
- 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 -83
- 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 -67
- 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 -25
- 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 -220
- package/web/src/pug/block/bubble/0.0.1/index.pug +0 -28
- package/web/src/pug/block/curve-bar/0.0.1/index.ls +0 -89
- 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 -90
- 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 -27
- 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 -100
- 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 -302
- 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 -69
- 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 -167
- 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 -125
- 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 -185
- 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 -113
- 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 -128
- 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 -38
- 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 -40
- 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 -74
- 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 -48
- 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 -53
- 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 -172
- 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 -174
- 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 -61
- 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 -81
- 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 -0
- 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 -79
- package/web/static/block/axis-bubble/0.0.1/index.html +0 -222
- package/web/static/block/bar/0.0.1/index.html +0 -581
- package/web/static/block/bar-list/0.0.1/index.html +0 -231
- package/web/static/block/bar-race/0.0.1/index.html +0 -184
- package/web/static/block/base/0.0.1/index.html +0 -197
- package/web/static/block/blank/0.0.1/index.html +0 -42
- package/web/static/block/bubble/0.0.1/index.html +0 -402
- package/web/static/block/bubble/0.0.1/test.html +0 -0
- package/web/static/block/curve-bar/0.0.1/index.html +0 -148
- package/web/static/block/dumbbell/0.0.1/index.html +0 -178
- package/web/static/block/empty/0.0.1/index.html +0 -76
- package/web/static/block/gauge/0.0.1/index.html +0 -150
- package/web/static/block/line/0.0.1/index.html +0 -571
- package/web/static/block/number/0.0.1/index.html +0 -152
- package/web/static/block/percent-list/0.0.1/index.html +0 -316
- package/web/static/block/pie/0.0.1/index.html +0 -281
- package/web/static/block/pie-bubble/0.0.1/index.html +0 -358
- package/web/static/block/radar/0.0.1/index.html +0 -149
- package/web/static/block/scatter/0.0.1/index.html +0 -251
- package/web/static/block/sheet/0.0.1/index.html +0 -103
- package/web/static/block/table/0.0.1/index.html +0 -73
- package/web/static/block/taiwancounty/0.0.1/index.html +0 -202
- package/web/static/block/taiwantown/0.0.1/index.html +0 -210
- package/web/static/block/taiwanvillage/0.0.1/index.html +0 -220
- package/web/static/block/treemap/0.0.1/index.html +0 -360
- package/web/static/block/voronoi-treemap/0.0.1/index.html +0 -350
- package/web/static/block/wordcloud/0.0.1/index.html +0 -92
- package/web/static/block/worldmap/0.0.1/index.html +0 -207
- package/web/static/css/index.css +0 -0
- package/web/static/css/index.min.css +0 -0
- package/web/static/favicon.ico +0 -0
- package/web/static/index.html +0 -153
|
@@ -1,360 +0,0 @@
|
|
|
1
|
-
<div><div plug="layout"><div class="pdl-layout"><div data-type="layout"><div class="pdl-cell" data-name="view"></div><div class="pdl-cell" data-name="unit"></div><div class="pdl-cell" data-name="legend"></div></div><div data-type="render"></div></div></div><style type="text/css">.pdl-layout > div[data-type=layout] {
|
|
2
|
-
display: grid;
|
|
3
|
-
grid-template-columns: 1fr fit-content(10em);
|
|
4
|
-
grid-template-rows: 1fr fit-content(1em);
|
|
5
|
-
}
|
|
6
|
-
.pdl-layout > div[data-type=layout] > .pdl-cell[data-name=view] {
|
|
7
|
-
grid-area: 1/1;
|
|
8
|
-
}
|
|
9
|
-
.pdl-layout > div[data-type=layout] > .pdl-cell[data-name=legend] {
|
|
10
|
-
grid-column: 2;
|
|
11
|
-
grid-row: 1/span 2;
|
|
12
|
-
padding: 0 0.5em 0 0.5em;
|
|
13
|
-
}
|
|
14
|
-
.pdl-layout > div[data-type=layout] > .pdl-cell[data-name=unit] {
|
|
15
|
-
grid-column: 1;
|
|
16
|
-
grid-row: 2;
|
|
17
|
-
line-height: 1em;
|
|
18
|
-
text-align: right;
|
|
19
|
-
padding: 0.25em 0;
|
|
20
|
-
}
|
|
21
|
-
.pdl-layout.legend-bottom > div[data-type=layout] {
|
|
22
|
-
grid-template-columns: 1fr fit-content(1em);
|
|
23
|
-
grid-template-rows: 1fr fit-content(3em);
|
|
24
|
-
}
|
|
25
|
-
.pdl-layout.legend-bottom > div[data-type=layout] .pdl-cell[data-name=view] {
|
|
26
|
-
grid-column: 1/span 2;
|
|
27
|
-
grid-row: 1;
|
|
28
|
-
}
|
|
29
|
-
.pdl-layout.legend-bottom > div[data-type=layout] .pdl-cell[data-name=legend] {
|
|
30
|
-
padding-top: 1em;
|
|
31
|
-
grid-column: 1;
|
|
32
|
-
grid-row: 2;
|
|
33
|
-
}
|
|
34
|
-
.pdl-layout.legend-bottom > div[data-type=layout] .pdl-cell[data-name=unit] {
|
|
35
|
-
padding-top: 1em;
|
|
36
|
-
grid-column: 2;
|
|
37
|
-
grid-row: 2;
|
|
38
|
-
}
|
|
39
|
-
</style><script type="@plotdb/block">(function(it){
|
|
40
|
-
return it();
|
|
41
|
-
})(function(){
|
|
42
|
-
var blockFactory, mod;
|
|
43
|
-
blockFactory = {
|
|
44
|
-
pkg: {
|
|
45
|
-
name: 'treemap',
|
|
46
|
-
version: '0.0.1',
|
|
47
|
-
extend: {
|
|
48
|
-
name: "base",
|
|
49
|
-
version: "0.0.1"
|
|
50
|
-
},
|
|
51
|
-
dependencies: [],
|
|
52
|
-
i18n: {
|
|
53
|
-
"zh-TW": {
|
|
54
|
-
"other": "其它",
|
|
55
|
-
"unit": "單位"
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
init: function(arg$){
|
|
60
|
-
var root, context, pubsub, t;
|
|
61
|
-
root = arg$.root, context = arg$.context, pubsub = arg$.pubsub, t = arg$.t;
|
|
62
|
-
return pubsub.fire('init', {
|
|
63
|
-
mod: mod({
|
|
64
|
-
root: root,
|
|
65
|
-
context: context,
|
|
66
|
-
t: t
|
|
67
|
-
})
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
mod = function(arg$){
|
|
72
|
-
var root, context, t, chart, d3, ldcolor, wrapSvgText;
|
|
73
|
-
root = arg$.root, context = arg$.context, t = arg$.t;
|
|
74
|
-
chart = context.chart, d3 = context.d3, ldcolor = context.ldcolor, wrapSvgText = context.wrapSvgText;
|
|
75
|
-
return {
|
|
76
|
-
sample: function(){
|
|
77
|
-
return {
|
|
78
|
-
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].map(function(val){
|
|
79
|
-
return {
|
|
80
|
-
val: Math.random().toFixed(2),
|
|
81
|
-
cat: Math.floor(1 + 6 * Math.random())
|
|
82
|
-
};
|
|
83
|
-
}),
|
|
84
|
-
binding: {
|
|
85
|
-
color: {
|
|
86
|
-
key: 'cat'
|
|
87
|
-
},
|
|
88
|
-
area: {
|
|
89
|
-
key: 'val',
|
|
90
|
-
unit: 'MB'
|
|
91
|
-
},
|
|
92
|
-
name: {
|
|
93
|
-
key: 'cat'
|
|
94
|
-
},
|
|
95
|
-
category: {
|
|
96
|
-
key: 'cat'
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
},
|
|
101
|
-
config: {
|
|
102
|
-
unitPosition: {
|
|
103
|
-
type: 'choice',
|
|
104
|
-
values: ['inner', 'outside', 'none']
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
dimension: {
|
|
108
|
-
color: {
|
|
109
|
-
type: 'RC',
|
|
110
|
-
name: "顏色",
|
|
111
|
-
priority: 4
|
|
112
|
-
},
|
|
113
|
-
area: {
|
|
114
|
-
type: 'R',
|
|
115
|
-
name: "面積",
|
|
116
|
-
priority: 1
|
|
117
|
-
},
|
|
118
|
-
name: {
|
|
119
|
-
type: 'NC',
|
|
120
|
-
name: "名稱",
|
|
121
|
-
priority: 2
|
|
122
|
-
},
|
|
123
|
-
category: {
|
|
124
|
-
type: 'C',
|
|
125
|
-
name: "分類",
|
|
126
|
-
priority: 3
|
|
127
|
-
}
|
|
128
|
-
},
|
|
129
|
-
init: function(){
|
|
130
|
-
var tint, textRenderer, ref$, this$ = this;
|
|
131
|
-
this.tint = tint = new chart.utils.tint();
|
|
132
|
-
this.g = Object.fromEntries(['view', 'unit', 'legend'].map(function(it){
|
|
133
|
-
return [it, d3.select(this$.layout.getGroup(it))];
|
|
134
|
-
}));
|
|
135
|
-
this.textRenderer = textRenderer = document.createElement('div');
|
|
136
|
-
import$(textRenderer.style, {
|
|
137
|
-
textAlign: 'right',
|
|
138
|
-
fontSize: '0.9em',
|
|
139
|
-
padding: ".5em .5em",
|
|
140
|
-
lineHeight: '1.1em',
|
|
141
|
-
whiteSpace: "pre-line",
|
|
142
|
-
display: 'inline-block',
|
|
143
|
-
position: 'absolute',
|
|
144
|
-
top: 0,
|
|
145
|
-
left: 0,
|
|
146
|
-
opacity: 0,
|
|
147
|
-
pointerEvents: 'none',
|
|
148
|
-
userSelect: 'none',
|
|
149
|
-
zIndex: 0
|
|
150
|
-
});
|
|
151
|
-
root.appendChild(textRenderer);
|
|
152
|
-
this.legend = new chart.utils.legend({
|
|
153
|
-
layout: this.layout,
|
|
154
|
-
name: 'legend',
|
|
155
|
-
root: this.root,
|
|
156
|
-
shape: function(d){
|
|
157
|
-
return d3.select(this).attr('fill', tint.get(d.key));
|
|
158
|
-
},
|
|
159
|
-
direction: ((ref$ = this.cfg).legend || (ref$.legend = {})).position === 'bottom' ? 'horizontal' : 'vertical',
|
|
160
|
-
cfg: {
|
|
161
|
-
selectable: true
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
this.legend.on('select', function(){
|
|
165
|
-
this$.bind();
|
|
166
|
-
this$.resize();
|
|
167
|
-
return this$.render();
|
|
168
|
-
});
|
|
169
|
-
return this.tip = new chart.utils.tip({
|
|
170
|
-
root: this.root,
|
|
171
|
-
accessor: function(arg$){
|
|
172
|
-
var evt, data, v;
|
|
173
|
-
evt = arg$.evt;
|
|
174
|
-
if (!(evt.target && (data = d3.select(evt.target).datum()))) {
|
|
175
|
-
return null;
|
|
176
|
-
}
|
|
177
|
-
v = isNaN(data.data.area)
|
|
178
|
-
? '-'
|
|
179
|
-
: data.data.area.toFixed(2) + "" + (this$.binding.area.unit || '');
|
|
180
|
-
return {
|
|
181
|
-
name: data.data.name,
|
|
182
|
-
value: v
|
|
183
|
-
};
|
|
184
|
-
},
|
|
185
|
-
range: function(){
|
|
186
|
-
return this$.layout.getNode('view').getBoundingClientRect();
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
},
|
|
190
|
-
destroy: function(){
|
|
191
|
-
return this.tip.destroy();
|
|
192
|
-
},
|
|
193
|
-
parse: function(){
|
|
194
|
-
var hash, k, v;
|
|
195
|
-
this.tint.reset();
|
|
196
|
-
hash = {};
|
|
197
|
-
this.data.map(function(d, i){
|
|
198
|
-
d.id = "name-" + i;
|
|
199
|
-
if (!d.category || d.category === "") {
|
|
200
|
-
return d.category = t("other");
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
if (!this.binding.category) {
|
|
204
|
-
this.data.map(function(d){
|
|
205
|
-
return d.category = 'root-1';
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
this.data.map(function(it){
|
|
209
|
-
return hash[it.category] = {
|
|
210
|
-
id: it.category,
|
|
211
|
-
category: 'root'
|
|
212
|
-
};
|
|
213
|
-
});
|
|
214
|
-
this.cats = Array.from(new Set(this.data.map(function(it){
|
|
215
|
-
return it.category;
|
|
216
|
-
}))).filter(function(it){
|
|
217
|
-
return it !== 'root-1';
|
|
218
|
-
});
|
|
219
|
-
this.data = this.data.concat((function(){
|
|
220
|
-
var ref$, results$ = [];
|
|
221
|
-
for (k in ref$ = hash) {
|
|
222
|
-
v = ref$[k];
|
|
223
|
-
results$.push(v);
|
|
224
|
-
}
|
|
225
|
-
return results$;
|
|
226
|
-
}()), [{
|
|
227
|
-
id: 'root'
|
|
228
|
-
}]);
|
|
229
|
-
return this.legend.data(this.cats.map(function(it){
|
|
230
|
-
return {
|
|
231
|
-
key: it,
|
|
232
|
-
text: it
|
|
233
|
-
};
|
|
234
|
-
}));
|
|
235
|
-
},
|
|
236
|
-
bind: function(){
|
|
237
|
-
var data, s, this$ = this;
|
|
238
|
-
data = this.data.filter(function(it){
|
|
239
|
-
var ref$;
|
|
240
|
-
return it.id === 'root' || ((ref$ = it.category) === 'root' || ref$ === 'root-1') || this$.legend.isSelected(it.category);
|
|
241
|
-
});
|
|
242
|
-
s = d3.stratify().id(function(it){
|
|
243
|
-
return it.id;
|
|
244
|
-
}).parentId(function(it){
|
|
245
|
-
return it.category;
|
|
246
|
-
});
|
|
247
|
-
return this.ret = s(data);
|
|
248
|
-
},
|
|
249
|
-
resize: function(){
|
|
250
|
-
var ref$, ref1$, x$, box, tree;
|
|
251
|
-
this.root.querySelector('.pdl-layout').classList.toggle('legend-bottom', ((ref$ = this.cfg).legend || (ref$.legend = {})).position === 'bottom');
|
|
252
|
-
this.tip.toggle(((ref$ = this.cfg).tip || (ref$.tip = {})).enabled != null ? this.cfg.tip.enabled : true);
|
|
253
|
-
this.unit = {
|
|
254
|
-
inner: ((ref$ = this.cfg).unit || (ref$.unit = {})).position === 'inner' ? this.binding.area.unit || '' : '',
|
|
255
|
-
outer: (ref$ = ((ref1$ = this.cfg).unit || (ref1$.unit = {})).position) === 'inner' || ref$ === 'none'
|
|
256
|
-
? ''
|
|
257
|
-
: this.binding.area.unit ? t('unit') + ": " + (this.binding.area.unit || '') : ''
|
|
258
|
-
};
|
|
259
|
-
x$ = this.layout.getNode('unit');
|
|
260
|
-
x$.style.display = !this.unit.outer ? 'none' : '';
|
|
261
|
-
x$.textContent = this.unit.outer;
|
|
262
|
-
this.legend.config(this.cfg.legend);
|
|
263
|
-
this.legend.update();
|
|
264
|
-
this.layout.update(false);
|
|
265
|
-
this.ret.sum(function(it){
|
|
266
|
-
return it.area;
|
|
267
|
-
});
|
|
268
|
-
box = this.layout.getBox('view');
|
|
269
|
-
tree = d3.treemap().padding(1).size([box.width, box.height])(this.ret);
|
|
270
|
-
this.nodes = this.ret.leaves().filter(function(it){
|
|
271
|
-
return it.data._raw;
|
|
272
|
-
});
|
|
273
|
-
this.nodes.map(function(it){
|
|
274
|
-
return it._raw = it.data._raw;
|
|
275
|
-
});
|
|
276
|
-
return this.extent = d3.extent(this.nodes.map(function(it){
|
|
277
|
-
return it.value;
|
|
278
|
-
}));
|
|
279
|
-
},
|
|
280
|
-
render: function(){
|
|
281
|
-
var cfg, unit, binding, layout, textRenderer, tint, x$, y$, this$ = this;
|
|
282
|
-
cfg = this.cfg, unit = this.unit, binding = this.binding, layout = this.layout, textRenderer = this.textRenderer, tint = this.tint;
|
|
283
|
-
tint.set(cfg.palette);
|
|
284
|
-
this.g.unit.call(function(){
|
|
285
|
-
var node, ret;
|
|
286
|
-
node = layout.getNode('unit');
|
|
287
|
-
ret = wrapSvgText({
|
|
288
|
-
node: node,
|
|
289
|
-
useRange: true
|
|
290
|
-
});
|
|
291
|
-
this$.g.unit.node().textContent = '';
|
|
292
|
-
return this$.g.unit.node().appendChild(ret);
|
|
293
|
-
});
|
|
294
|
-
x$ = this.g.view.selectAll('rect.data').data(this.nodes, function(it){
|
|
295
|
-
return it._raw._idx;
|
|
296
|
-
});
|
|
297
|
-
x$.exit().remove();
|
|
298
|
-
x$.enter().append('rect').attr('class', 'data').attr('x', function(it){
|
|
299
|
-
return (it.x1 + it.x0) / 2 - (it.x1 - it.x0) / 4;
|
|
300
|
-
}).attr('y', function(it){
|
|
301
|
-
return (it.y1 + it.y0) / 2 - (it.y1 - it.y0) / 4;
|
|
302
|
-
}).attr('width', function(it){
|
|
303
|
-
return (it.x1 - it.x0) / 2;
|
|
304
|
-
}).attr('height', function(it){
|
|
305
|
-
return (it.y1 - it.y0) / 2;
|
|
306
|
-
}).attr('fill', function(it){
|
|
307
|
-
return tint.get(it.data.color || it.data.category);
|
|
308
|
-
}).style('opacity', 0);
|
|
309
|
-
this.g.view.selectAll('rect').transition().duration(350).attr('x', function(it){
|
|
310
|
-
return it.x0;
|
|
311
|
-
}).attr('y', function(it){
|
|
312
|
-
return it.y0;
|
|
313
|
-
}).attr('width', function(it){
|
|
314
|
-
return it.x1 - it.x0;
|
|
315
|
-
}).attr('height', function(it){
|
|
316
|
-
return it.y1 - it.y0;
|
|
317
|
-
}).attr('fill', function(it){
|
|
318
|
-
var v;
|
|
319
|
-
v = (it.value - this$.extent[0]) / (this$.extent[1] - this$.extent[0]) - 0.5;
|
|
320
|
-
return tint.get(it.data.color || it.data.category);
|
|
321
|
-
}).style('opacity', 1);
|
|
322
|
-
y$ = this.g.view.selectAll('g.label').data(this.nodes, function(it){
|
|
323
|
-
return it._raw._idx;
|
|
324
|
-
});
|
|
325
|
-
y$.exit().remove();
|
|
326
|
-
y$.enter().append('g').attr('class', 'label data').attr('transform', function(d, i){
|
|
327
|
-
return "translate(" + d.x0 + "," + d.y0 + ")";
|
|
328
|
-
}).attr('opacity', 0).style('pointer-events', 'none').style('cursor', 'pointer');
|
|
329
|
-
this.g.view.selectAll('g.label').attr('font-size', '0.9em').each(function(d, i){
|
|
330
|
-
var area, ret;
|
|
331
|
-
textRenderer.style.width = (d.x1 - d.x0) + "px";
|
|
332
|
-
area = d.data.area;
|
|
333
|
-
area = d3.format('.3s')(area);
|
|
334
|
-
textRenderer.innerHTML = "<div>" + (d.data.name || '') + "</div>\n<div>" + area + unit.inner + "</div>";
|
|
335
|
-
ret = wrapSvgText({
|
|
336
|
-
node: textRenderer,
|
|
337
|
-
useRange: true
|
|
338
|
-
});
|
|
339
|
-
this.textContent = '';
|
|
340
|
-
return this.appendChild(ret);
|
|
341
|
-
}).transition().duration(350).attr('transform', function(d, i){
|
|
342
|
-
return "translate(" + d.x0 + "," + d.y0 + ")";
|
|
343
|
-
}).attr('fill', function(it){
|
|
344
|
-
return tint.text(it.data.color || it.data.category);
|
|
345
|
-
}).attr('opacity', function(d, i){
|
|
346
|
-
var box;
|
|
347
|
-
box = this.getBBox();
|
|
348
|
-
return box.width > d.x1 - d.x0 || box.height > d.y1 - d.y0 ? 0 : 1;
|
|
349
|
-
});
|
|
350
|
-
return this.legend.render();
|
|
351
|
-
}
|
|
352
|
-
};
|
|
353
|
-
};
|
|
354
|
-
return blockFactory;
|
|
355
|
-
});
|
|
356
|
-
function import$(obj, src){
|
|
357
|
-
var own = {}.hasOwnProperty;
|
|
358
|
-
for (var key in src) if (own.call(src, key)) obj[key] = src[key];
|
|
359
|
-
return obj;
|
|
360
|
-
}</script></div>
|
|
@@ -1,350 +0,0 @@
|
|
|
1
|
-
<div><div plug="layout"><div class="pdl-layout"><div data-type="layout"><div class="pdl-cell" data-name="view"></div><div class="pdl-cell" data-name="legend"></div></div><div data-type="render"></div></div></div><style type="text/css">.pdl-layout > div[data-type=layout] {
|
|
2
|
-
display: grid;
|
|
3
|
-
grid-template-columns: 1fr fit-content(10em);
|
|
4
|
-
}
|
|
5
|
-
.pdl-layout > div[data-type=layout] > .pdl-cell[data-name=view] {
|
|
6
|
-
grid-column: 1;
|
|
7
|
-
}
|
|
8
|
-
.pdl-layout > div[data-type=layout] > .pdl-cell[data-name=legend] {
|
|
9
|
-
grid-column: 2;
|
|
10
|
-
padding: 0 0.5em 0 0.5em;
|
|
11
|
-
}
|
|
12
|
-
</style><script type="@plotdb/block">(function(it){
|
|
13
|
-
return it();
|
|
14
|
-
})(function(){
|
|
15
|
-
var blockFactory, mod;
|
|
16
|
-
blockFactory = {
|
|
17
|
-
pkg: {
|
|
18
|
-
name: 'voronoi-treemap',
|
|
19
|
-
version: '0.0.1',
|
|
20
|
-
extend: {
|
|
21
|
-
name: "base",
|
|
22
|
-
version: "0.0.1"
|
|
23
|
-
},
|
|
24
|
-
dependencies: [{
|
|
25
|
-
name: "@zbryikt/voronoijs",
|
|
26
|
-
version: "main",
|
|
27
|
-
path: "voronoi.min.js"
|
|
28
|
-
}]
|
|
29
|
-
},
|
|
30
|
-
init: function(arg$){
|
|
31
|
-
var root, context, pubsub;
|
|
32
|
-
root = arg$.root, context = arg$.context, pubsub = arg$.pubsub;
|
|
33
|
-
return pubsub.fire('init', {
|
|
34
|
-
mod: mod({
|
|
35
|
-
context: context
|
|
36
|
-
})
|
|
37
|
-
}).then(function(it){
|
|
38
|
-
return it[0];
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
mod = function(arg$){
|
|
43
|
-
var context, d3, ldcolor, voronoi, chart;
|
|
44
|
-
context = arg$.context;
|
|
45
|
-
d3 = context.d3, ldcolor = context.ldcolor, voronoi = context.voronoi, chart = context.chart;
|
|
46
|
-
return {
|
|
47
|
-
sample: function(){
|
|
48
|
-
return {
|
|
49
|
-
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){
|
|
50
|
-
return {
|
|
51
|
-
val: Math.random() * 10,
|
|
52
|
-
cat: Math.floor(1 + 10 * Math.random()),
|
|
53
|
-
name: val
|
|
54
|
-
};
|
|
55
|
-
}),
|
|
56
|
-
binding: {
|
|
57
|
-
name: {
|
|
58
|
-
key: 'name'
|
|
59
|
-
},
|
|
60
|
-
area: {
|
|
61
|
-
key: 'val'
|
|
62
|
-
},
|
|
63
|
-
category: {
|
|
64
|
-
key: 'cat'
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
},
|
|
69
|
-
config: {},
|
|
70
|
-
dimension: {
|
|
71
|
-
area: {
|
|
72
|
-
type: 'R',
|
|
73
|
-
name: "area"
|
|
74
|
-
},
|
|
75
|
-
name: {
|
|
76
|
-
type: 'N',
|
|
77
|
-
desc: "name"
|
|
78
|
-
},
|
|
79
|
-
category: {
|
|
80
|
-
type: 'N',
|
|
81
|
-
desc: "category"
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
init: function(){
|
|
85
|
-
var tint, g, this$ = this;
|
|
86
|
-
this.tint = tint = new chart.utils.tint();
|
|
87
|
-
this.g = Object.fromEntries(['view', 'legend'].map(function(it){
|
|
88
|
-
return [it, d3.select(this$.layout.getGroup(it))];
|
|
89
|
-
}));
|
|
90
|
-
this.layout.getGroup('view').appendChild(g = document.createElementNS("http://www.w3.org/2000/svg", "g"));
|
|
91
|
-
this.g.shape = d3.select(g);
|
|
92
|
-
this.siteBoxes = [];
|
|
93
|
-
this.legend = new chart.utils.legend({
|
|
94
|
-
layout: this.layout,
|
|
95
|
-
name: 'legend',
|
|
96
|
-
root: this.root,
|
|
97
|
-
shape: function(d){
|
|
98
|
-
return d3.select(this).attr('fill', tint.get(d.key));
|
|
99
|
-
},
|
|
100
|
-
cfg: {
|
|
101
|
-
selectable: true
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
this.legend.on('select', function(){
|
|
105
|
-
this$.bind();
|
|
106
|
-
this$.resize();
|
|
107
|
-
return this$.render();
|
|
108
|
-
});
|
|
109
|
-
this.tip = new chart.utils.tip({
|
|
110
|
-
root: this.root,
|
|
111
|
-
accessor: function(arg$){
|
|
112
|
-
var evt, data;
|
|
113
|
-
evt = arg$.evt;
|
|
114
|
-
if (!(evt.target && (data = d3.select(evt.target).datum()))) {
|
|
115
|
-
return null;
|
|
116
|
-
}
|
|
117
|
-
if (Array.isArray(data)) {
|
|
118
|
-
if (!this$._sites) {
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
if (!(data.idx != null)) {
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
if (!(data = this$._sites[data.idx])) {
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
return {
|
|
129
|
-
name: data.name,
|
|
130
|
-
value: data.area.toFixed(2) + "" + (this$.binding.area.unit || '')
|
|
131
|
-
};
|
|
132
|
-
},
|
|
133
|
-
range: function(){
|
|
134
|
-
return this$.layout.getNode('view').getBoundingClientRect();
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
return this.start();
|
|
138
|
-
},
|
|
139
|
-
parse: function(){
|
|
140
|
-
this.data.map(function(it){
|
|
141
|
-
return it.key = it.name, it.value = it.area, it;
|
|
142
|
-
});
|
|
143
|
-
this.total = this.data.reduce(function(a, b){
|
|
144
|
-
return a + b.area;
|
|
145
|
-
}, 0);
|
|
146
|
-
this.cats = Array.from(new Set(this.data.map(function(d){
|
|
147
|
-
return d.category;
|
|
148
|
-
})));
|
|
149
|
-
return this.legend.data(this.cats.map(function(it){
|
|
150
|
-
return {
|
|
151
|
-
key: it,
|
|
152
|
-
text: it
|
|
153
|
-
};
|
|
154
|
-
}));
|
|
155
|
-
},
|
|
156
|
-
bind: function(){
|
|
157
|
-
var data, box, ref$, w, h, sites, x$, y$, this$ = this;
|
|
158
|
-
data = this.data.filter(function(it){
|
|
159
|
-
return this$.legend.isSelected(it.category);
|
|
160
|
-
});
|
|
161
|
-
this.parsed = {
|
|
162
|
-
children: d3.nest().key(function(it){
|
|
163
|
-
return it.category;
|
|
164
|
-
}).entries(data).map(function(it){
|
|
165
|
-
return it.children = it.values, it;
|
|
166
|
-
})
|
|
167
|
-
};
|
|
168
|
-
box = this.box || this.svg.getBoundingClientRect();
|
|
169
|
-
ref$ = [box.width, box.height], w = ref$[0], h = ref$[1];
|
|
170
|
-
w = h = Math.min(w, h);
|
|
171
|
-
this.treemap = new voronoi.Treemap(this.parsed, voronoi.Polygon.create(w, h, 60), w, h);
|
|
172
|
-
sites = this.treemap.getSites();
|
|
173
|
-
x$ = this.g.shape.selectAll('path.data').data(this.treemap.getPolygons());
|
|
174
|
-
x$.exit().remove();
|
|
175
|
-
x$.enter().append('path').attr('class', 'data').each(function(d, i){
|
|
176
|
-
return d.idx = i;
|
|
177
|
-
});
|
|
178
|
-
this.g.shape.selectAll('path.data').attr('class', function(d, i){
|
|
179
|
-
if (sites[i].lv <= 0) {
|
|
180
|
-
return 'data group';
|
|
181
|
-
} else {
|
|
182
|
-
return 'data';
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
this.polygons = this.g.shape.selectAll('path.data');
|
|
186
|
-
y$ = this.g.shape.selectAll('g.label').data(sites);
|
|
187
|
-
y$.exit().remove();
|
|
188
|
-
y$.enter().append('g').attr('class', 'label').each(function(d, i){
|
|
189
|
-
var x$;
|
|
190
|
-
x$ = d3.select(this);
|
|
191
|
-
x$.append('text').attr('class', 'name').attr('font-size', '.8em');
|
|
192
|
-
x$.append('text').attr('class', 'value');
|
|
193
|
-
return x$;
|
|
194
|
-
});
|
|
195
|
-
this.sites = this.g.shape.selectAll('g.label');
|
|
196
|
-
return this.sites.each(function(d, i){
|
|
197
|
-
return d3.select(this).selectAll('text').data([d, d]).attr('text-anchor', 'middle').attr('dominant-baseline', 'center');
|
|
198
|
-
});
|
|
199
|
-
},
|
|
200
|
-
resize: function(){
|
|
201
|
-
var box, ref$, w, h, s, sites;
|
|
202
|
-
box = this.layout.getBox('view');
|
|
203
|
-
ref$ = [box.width, box.height], w = ref$[0], h = ref$[1];
|
|
204
|
-
s = Math.min(w, h);
|
|
205
|
-
this.legend.config(this.cfg.legend);
|
|
206
|
-
this.legend.update();
|
|
207
|
-
this.layout.update(false);
|
|
208
|
-
this.g.shape.attr('transform', "translate(" + (w / 2 - s / 2) + "," + (h / 2 - s / 2) + ")");
|
|
209
|
-
this.scale = {
|
|
210
|
-
x: d3.scaleLinear().domain([0, w]).range([0, w]),
|
|
211
|
-
y: d3.scaleLinear().domain([0, h]).range([0, h]),
|
|
212
|
-
color: d3.interpolateTurbo
|
|
213
|
-
};
|
|
214
|
-
if (this.cfg != null && this.cfg.palette) {
|
|
215
|
-
this.scale.color = d3.interpolateDiscrete(this.cfg.palette.colors.map(function(it){
|
|
216
|
-
return ldcolor.web(it.value || it);
|
|
217
|
-
}));
|
|
218
|
-
}
|
|
219
|
-
this.tint.set(this.cfg.palette);
|
|
220
|
-
sites = this.treemap.getSites();
|
|
221
|
-
this.count = 0;
|
|
222
|
-
return this.gbox = this.svg.getBoundingClientRect();
|
|
223
|
-
},
|
|
224
|
-
render: function(tick){
|
|
225
|
-
var sites, polygons, ref$, w, h, siteBoxes, boxes, this$ = this;
|
|
226
|
-
tick == null && (tick = false);
|
|
227
|
-
this._sites = sites = this.treemap.getSites();
|
|
228
|
-
polygons = this.treemap.getPolygons();
|
|
229
|
-
ref$ = [this.box.width, this.box.height], w = ref$[0], h = ref$[1];
|
|
230
|
-
if (!tick) {
|
|
231
|
-
this.legend.render();
|
|
232
|
-
this.sites.selectAll('.name').attr('dy', '0.88em').text(function(it){
|
|
233
|
-
var n;
|
|
234
|
-
n = (it.name || '') + "";
|
|
235
|
-
return n;
|
|
236
|
-
if (it.lv > 0) {
|
|
237
|
-
return n.substring(0, 7) + (n.length > 7 ? '...' : '');
|
|
238
|
-
} else {
|
|
239
|
-
return '';
|
|
240
|
-
}
|
|
241
|
-
}).attr('fill', function(d, i){
|
|
242
|
-
if (ldcolor.hcl(this$.tint.get(d.category)).l > 60) {
|
|
243
|
-
return '#000';
|
|
244
|
-
} else {
|
|
245
|
-
return '#eee';
|
|
246
|
-
}
|
|
247
|
-
}).style('pointer-events', 'none');
|
|
248
|
-
this.sites.selectAll('.value').attr('dy', '-0.28em').text(function(it){
|
|
249
|
-
if (it.lv > 0) {
|
|
250
|
-
return (it.value || 0).toFixed(2);
|
|
251
|
-
} else {
|
|
252
|
-
return '';
|
|
253
|
-
}
|
|
254
|
-
}).attr('fill', function(d, i){
|
|
255
|
-
if (ldcolor.hcl(this$.tint.get(d.category)).l > 60) {
|
|
256
|
-
return '#000';
|
|
257
|
-
} else {
|
|
258
|
-
return '#eee';
|
|
259
|
-
}
|
|
260
|
-
}).style('pointer-events', 'none');
|
|
261
|
-
this.siteBoxes = siteBoxes = [];
|
|
262
|
-
this.sites.each(function(d, i){
|
|
263
|
-
return siteBoxes.push(this.getBoundingClientRect());
|
|
264
|
-
});
|
|
265
|
-
this.polygons.attr('fill', function(d, i){
|
|
266
|
-
return this$.tint.get(sites[i].category);
|
|
267
|
-
}).attr('stroke', '#fff').attr('stroke-width', 1);
|
|
268
|
-
}
|
|
269
|
-
siteBoxes = this.siteBoxes;
|
|
270
|
-
boxes = [];
|
|
271
|
-
this.polygons.data(polygons).attr('d', function(d, i){
|
|
272
|
-
var ret, ref$, min, max, i$, to$, idx, x, y;
|
|
273
|
-
d.idx = i;
|
|
274
|
-
if (!(d && d.length)) {
|
|
275
|
-
boxes.push({});
|
|
276
|
-
return "";
|
|
277
|
-
}
|
|
278
|
-
ret = [['M', d[0].x, d[0].y]];
|
|
279
|
-
ref$ = [
|
|
280
|
-
{
|
|
281
|
-
x: d[0].x,
|
|
282
|
-
y: d[0].y
|
|
283
|
-
}, {
|
|
284
|
-
x: d[0].x,
|
|
285
|
-
y: d[0].y
|
|
286
|
-
}
|
|
287
|
-
], min = ref$[0], max = ref$[1];
|
|
288
|
-
for (i$ = 0, to$ = d.length; i$ < to$; ++i$) {
|
|
289
|
-
idx = i$;
|
|
290
|
-
ref$ = [d[idx].x, d[idx].y], x = ref$[0], y = ref$[1];
|
|
291
|
-
if (min.x > x) {
|
|
292
|
-
min.x = x;
|
|
293
|
-
}
|
|
294
|
-
if (max.x < x) {
|
|
295
|
-
max.x = x;
|
|
296
|
-
}
|
|
297
|
-
if (min.y > y) {
|
|
298
|
-
min.y = y;
|
|
299
|
-
}
|
|
300
|
-
if (max.y < y) {
|
|
301
|
-
max.y = y;
|
|
302
|
-
}
|
|
303
|
-
ret.push(['L', x, y]);
|
|
304
|
-
}
|
|
305
|
-
ret.push(['L', d[0].x, d[0].y]);
|
|
306
|
-
boxes.push({
|
|
307
|
-
x: min.x,
|
|
308
|
-
y: min.y,
|
|
309
|
-
width: max.x - min.x,
|
|
310
|
-
height: max.y - min.y
|
|
311
|
-
});
|
|
312
|
-
return ret.map(function(it){
|
|
313
|
-
return it.join(' ');
|
|
314
|
-
}).join(' ');
|
|
315
|
-
});
|
|
316
|
-
return this.sites.each(function(d, i){
|
|
317
|
-
var box, mybox;
|
|
318
|
-
box = boxes[i];
|
|
319
|
-
mybox = siteBoxes[i];
|
|
320
|
-
if (!mybox) {
|
|
321
|
-
mybox = this.getBoundingClientRect();
|
|
322
|
-
}
|
|
323
|
-
return d3.select(this).attr('transform', function(){
|
|
324
|
-
var x, y;
|
|
325
|
-
x = box.x + box.width / 2;
|
|
326
|
-
y = box.y + box.height / 2;
|
|
327
|
-
if (isNaN(x)) {
|
|
328
|
-
x = -10000;
|
|
329
|
-
}
|
|
330
|
-
if (isNaN(y)) {
|
|
331
|
-
y = -10000;
|
|
332
|
-
}
|
|
333
|
-
return "translate(" + x + ", " + y + ")";
|
|
334
|
-
}).attr('opacity', function(){
|
|
335
|
-
var ref$, ref1$, ref2$;
|
|
336
|
-
return (ref$ = 1 - 6 * ((ref1$ = mybox.width / ((ref2$ = box.width) > 0 ? ref2$ : 0) - 1) > 0 ? ref1$ : 0)) > 0 ? ref$ : 0;
|
|
337
|
-
});
|
|
338
|
-
});
|
|
339
|
-
},
|
|
340
|
-
tick: function(){
|
|
341
|
-
this.count = (this.count || 0) + 1;
|
|
342
|
-
if (this.count < 100) {
|
|
343
|
-
this.treemap.compute();
|
|
344
|
-
return this.render(true);
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
};
|
|
348
|
-
};
|
|
349
|
-
return blockFactory;
|
|
350
|
-
});</script></div>
|