@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
|
@@ -1,92 +1,87 @@
|
|
|
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: [{
|
|
14
|
-
url: "https://unpkg.com/d3-cloud@1.2.5/build/d3.layout.cloud.js"
|
|
15
|
-
}]
|
|
1
|
+
<div><script type="@plotdb/block">var mod;
|
|
2
|
+
module.exports = {
|
|
3
|
+
pkg: {
|
|
4
|
+
name: 'wordcloud',
|
|
5
|
+
version: '0.0.1',
|
|
6
|
+
extend: {
|
|
7
|
+
name: "base",
|
|
8
|
+
version: "0.0.1"
|
|
16
9
|
},
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
10
|
+
dependencies: [{
|
|
11
|
+
url: "https://unpkg.com/d3-cloud@1.2.5/build/d3.layout.cloud.js"
|
|
12
|
+
}]
|
|
13
|
+
},
|
|
14
|
+
init: function(arg$){
|
|
15
|
+
var root, context, pubsub;
|
|
16
|
+
root = arg$.root, context = arg$.context, pubsub = arg$.pubsub;
|
|
17
|
+
return pubsub.fire('init', {
|
|
18
|
+
mod: mod({
|
|
19
|
+
context: context
|
|
20
|
+
})
|
|
21
|
+
}).then(function(it){
|
|
22
|
+
return it[0];
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
mod = function(arg$){
|
|
27
|
+
var context, root, d3, forceBoundary, ldColor, repeatString$;
|
|
28
|
+
context = arg$.context, root = arg$.root;
|
|
29
|
+
d3 = context.d3, forceBoundary = context.forceBoundary, ldColor = context.ldColor, repeatString$ = context.repeatString$;
|
|
30
|
+
return {
|
|
31
|
+
sample: function(){
|
|
32
|
+
return {
|
|
33
|
+
raw: [],
|
|
34
|
+
binding: {}
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
config: {},
|
|
38
|
+
dimension: {},
|
|
39
|
+
init: function(){
|
|
40
|
+
var this$ = this;
|
|
41
|
+
this.dd = ['cover', 'scandal', 'seem', 'consumption', 'garbage', 'hunter', 'pepper', 'west', 'guilt', 'conspiracy', 'pupil', 'boat', 'muscle', 'nightmare', 'gene', 'royalty', 'salon', 'difficult', 'management', 'brainstorm', 'aid', 'moving', 'plaster', 'cake', 'issue', 'realism', 'subject', 'speed', 'railcar', 'break', 'grass', 'collapse', 'is', 'leave', 'retiree', 'looting', 'transaction', 'copyright', 'serve', 'guard', 'colony', 'spell', 'ask', 'ranch', 'cell', 'sensation', 'name', 'default', 'reflection'].map(function(d, i){
|
|
35
42
|
return {
|
|
36
|
-
|
|
37
|
-
|
|
43
|
+
text: d,
|
|
44
|
+
value: 1.5 * i + 10
|
|
38
45
|
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
this
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return this.cloud.size([this.box.width, this.box.height].map(function(it){
|
|
60
|
-
return Math.round(it);
|
|
61
|
-
})).words(this.dd).start();
|
|
62
|
-
},
|
|
63
|
-
render: function(){
|
|
64
|
-
var color, vext, vscale, x$, this$ = this;
|
|
65
|
-
color = d3.interpolateTurbo;
|
|
66
|
-
if (this.cfg != null && this.cfg.palette) {
|
|
67
|
-
color = d3.interpolateDiscrete(this.cfg.palette.colors.map(function(it){
|
|
68
|
-
return ldColor.web(it.value || it);
|
|
69
|
-
}));
|
|
70
|
-
}
|
|
71
|
-
vext = d3.extent(this.dd.map(function(it){
|
|
72
|
-
return it.value;
|
|
46
|
+
});
|
|
47
|
+
this.cloud = d3.layout.cloud();
|
|
48
|
+
return this.cloud.font('arial').padding(2).fontSize(function(it){
|
|
49
|
+
return it.value;
|
|
50
|
+
}).on('end', function(){
|
|
51
|
+
return this$.render();
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
parse: function(){},
|
|
55
|
+
resize: function(){
|
|
56
|
+
return this.cloud.size([this.box.width, this.box.height].map(function(it){
|
|
57
|
+
return Math.round(it);
|
|
58
|
+
})).words(this.dd).start();
|
|
59
|
+
},
|
|
60
|
+
render: function(){
|
|
61
|
+
var color, vext, vscale, x$, this$ = this;
|
|
62
|
+
color = d3.interpolateTurbo;
|
|
63
|
+
if (this.cfg != null && this.cfg.palette) {
|
|
64
|
+
color = d3.interpolateDiscrete(this.cfg.palette.colors.map(function(it){
|
|
65
|
+
return ldColor.web(it.value || it);
|
|
73
66
|
}));
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
67
|
+
}
|
|
68
|
+
vext = d3.extent(this.dd.map(function(it){
|
|
69
|
+
return it.value;
|
|
70
|
+
}));
|
|
71
|
+
vscale = d3.scaleLinear().domain(vext).range([0, 1]);
|
|
72
|
+
x$ = d3.select(this.svg).selectAll('text').data(this.dd);
|
|
73
|
+
x$.exit().remove();
|
|
74
|
+
x$.enter().append('text');
|
|
75
|
+
return d3.select(this.svg).selectAll('text').attr('transform', function(it){
|
|
76
|
+
return "translate(" + (it.x + this$.box.width / 2) + " " + (it.y + this$.box.height / 2) + ") rotate(" + it.rotate + ")";
|
|
77
|
+
}).attr('text-anchor', 'middle').attr('font-size', function(it){
|
|
78
|
+
return it.size;
|
|
79
|
+
}).attr('font-family', 'arial').attr('fill', function(it){
|
|
80
|
+
return color(vscale(it.value));
|
|
81
|
+
}).text(function(it){
|
|
82
|
+
return it.text;
|
|
83
|
+
});
|
|
84
|
+
},
|
|
85
|
+
tick: function(){}
|
|
90
86
|
};
|
|
91
|
-
|
|
92
|
-
});</script></div>
|
|
87
|
+
};</script></div>
|
|
@@ -2,206 +2,201 @@
|
|
|
2
2
|
display: grid;
|
|
3
3
|
grid-template-columns: 1fr fit-content(5em);
|
|
4
4
|
}
|
|
5
|
-
</style><script type="@plotdb/block">
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
name:
|
|
12
|
-
version:
|
|
13
|
-
extend: {
|
|
14
|
-
name: "base",
|
|
15
|
-
version: "0.0.1"
|
|
16
|
-
},
|
|
17
|
-
dependencies: [
|
|
18
|
-
{
|
|
19
|
-
url: "https://d3js.org/d3-geo.v2.min.js",
|
|
20
|
-
async: false
|
|
21
|
-
}, {
|
|
22
|
-
url: "https://d3js.org/topojson.v2.min.js",
|
|
23
|
-
async: false
|
|
24
|
-
}, {
|
|
25
|
-
url: "/assets/lib/@plotdb/pdmap-world/main/index.js"
|
|
26
|
-
}
|
|
27
|
-
]
|
|
5
|
+
</style><script type="@plotdb/block">var mod;
|
|
6
|
+
module.exports = {
|
|
7
|
+
pkg: {
|
|
8
|
+
name: 'worldmap',
|
|
9
|
+
version: '0.0.1',
|
|
10
|
+
extend: {
|
|
11
|
+
name: "base",
|
|
12
|
+
version: "0.0.1"
|
|
28
13
|
},
|
|
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
|
-
|
|
14
|
+
dependencies: [
|
|
15
|
+
{
|
|
16
|
+
url: "https://d3js.org/d3-geo.v2.min.js",
|
|
17
|
+
async: false
|
|
18
|
+
}, {
|
|
19
|
+
url: "https://d3js.org/topojson.v2.min.js",
|
|
20
|
+
async: false
|
|
21
|
+
}, {
|
|
22
|
+
url: "/assets/lib/@plotdb/pdmap-world/main/index.js"
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
init: function(arg$){
|
|
27
|
+
var root, context, pubsub;
|
|
28
|
+
root = arg$.root, context = arg$.context, pubsub = arg$.pubsub;
|
|
29
|
+
return pubsub.fire('init', {
|
|
30
|
+
mod: mod({
|
|
31
|
+
context: context
|
|
32
|
+
})
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
mod = function(arg$){
|
|
37
|
+
var context, chart, d3, ldcolor, pdmapWorld, topojson;
|
|
38
|
+
context = arg$.context;
|
|
39
|
+
chart = context.chart, d3 = context.d3, ldcolor = context.ldcolor, pdmapWorld = context.pdmapWorld, topojson = context.topojson;
|
|
40
|
+
return {
|
|
41
|
+
sample: function(){
|
|
42
|
+
return {
|
|
43
|
+
raw: pdmapWorld.meta.alpha2.map(function(it){
|
|
44
|
+
return {
|
|
45
|
+
country: it,
|
|
46
|
+
val: Math.random()
|
|
47
|
+
};
|
|
48
|
+
}),
|
|
49
|
+
binding: {
|
|
50
|
+
color: {
|
|
51
|
+
key: 'val'
|
|
52
|
+
},
|
|
53
|
+
name: {
|
|
54
|
+
key: 'country'
|
|
59
55
|
}
|
|
60
|
-
};
|
|
61
|
-
},
|
|
62
|
-
config: {},
|
|
63
|
-
dimension: {
|
|
64
|
-
name: {
|
|
65
|
-
type: 'N',
|
|
66
|
-
name: "國家"
|
|
67
|
-
},
|
|
68
|
-
color: {
|
|
69
|
-
type: 'R',
|
|
70
|
-
name: "顏色"
|
|
71
56
|
}
|
|
57
|
+
};
|
|
58
|
+
},
|
|
59
|
+
config: {},
|
|
60
|
+
dimension: {
|
|
61
|
+
name: {
|
|
62
|
+
type: 'N',
|
|
63
|
+
name: "國家"
|
|
72
64
|
},
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
this.
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
65
|
+
color: {
|
|
66
|
+
type: 'R',
|
|
67
|
+
name: "顏色"
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
init: function(){
|
|
71
|
+
var scale, this$ = this;
|
|
72
|
+
this.g = this.layout.getGroup('view');
|
|
73
|
+
this.obj = new pdmapWorld({
|
|
74
|
+
root: this.g
|
|
75
|
+
});
|
|
76
|
+
this.scale = scale = {
|
|
77
|
+
color: d3.interpolateTurbo
|
|
78
|
+
};
|
|
79
|
+
this.legend = new chart.utils.legend({
|
|
80
|
+
root: this.root,
|
|
81
|
+
name: 'legend',
|
|
82
|
+
layout: this.layout,
|
|
83
|
+
shape: function(d){
|
|
84
|
+
return d3.select(this).attr('fill', scale.color(d.key));
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
this.tip = new chart.utils.tip({
|
|
88
|
+
root: this.root,
|
|
89
|
+
accessor: function(arg$){
|
|
90
|
+
var evt, data, ret, k, v, name;
|
|
91
|
+
evt = arg$.evt;
|
|
92
|
+
if (!(evt.target && (data = d3.select(evt.target).datum()))) {
|
|
93
|
+
return null;
|
|
88
94
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
evt = arg$.evt;
|
|
95
|
-
if (!(evt.target && (data = d3.select(evt.target).datum()))) {
|
|
96
|
-
return null;
|
|
95
|
+
ret = (function(){
|
|
96
|
+
var ref$, results$ = [];
|
|
97
|
+
for (k in ref$ = pdmapWorld.meta.zhalpha2) {
|
|
98
|
+
v = ref$[k];
|
|
99
|
+
results$.push([k, v]);
|
|
97
100
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
name = ret
|
|
109
|
-
? ret[0]
|
|
110
|
-
: data.properties.shortname || data.data.name;
|
|
111
|
-
v = isNaN(data.data.color)
|
|
112
|
-
? '-'
|
|
113
|
-
: data.data.color.toFixed(2) + "" + (this$.binding.color.unit || '');
|
|
114
|
-
return {
|
|
115
|
-
name: name,
|
|
116
|
-
value: v
|
|
117
|
-
};
|
|
118
|
-
},
|
|
119
|
-
range: function(){
|
|
120
|
-
return this$.layout.getNode('view').getBoundingClientRect();
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
return this.obj.init().then(function(){
|
|
124
|
-
return this$.obj.fit();
|
|
125
|
-
});
|
|
126
|
-
},
|
|
127
|
-
destroy: function(){
|
|
128
|
-
return this.tip.destroy();
|
|
129
|
-
},
|
|
130
|
-
parse: function(){
|
|
131
|
-
var geoData, this$ = this;
|
|
132
|
-
geoData = d3.select(this.g).selectAll('path').data();
|
|
133
|
-
geoData.map(function(d){
|
|
134
|
-
d.data = null;
|
|
135
|
-
d.properties.value = 0;
|
|
136
|
-
return d.properties.data = {};
|
|
137
|
-
});
|
|
138
|
-
this.data.map(function(it){
|
|
139
|
-
return {
|
|
140
|
-
c: this$.obj.findCountry(it.name),
|
|
141
|
-
v: it
|
|
142
|
-
};
|
|
143
|
-
}).filter(function(it){
|
|
144
|
-
return it.c;
|
|
145
|
-
}).map(function(it){
|
|
146
|
-
var ref$;
|
|
147
|
-
return ref$ = it.c, ref$.value = it.v.color, ref$.data = it.v, ref$;
|
|
148
|
-
});
|
|
149
|
-
geoData.map(function(d){
|
|
150
|
-
return d.data = d.properties.data || {};
|
|
151
|
-
});
|
|
152
|
-
return this.extent = {
|
|
153
|
-
c: d3.extent(geoData, function(it){
|
|
154
|
-
return it.properties.value;
|
|
155
|
-
})
|
|
156
|
-
};
|
|
157
|
-
},
|
|
158
|
-
resize: function(){
|
|
159
|
-
var ref$, pal, len, this$ = this;
|
|
160
|
-
this.tip.toggle(((ref$ = this.cfg).tip || (ref$.tip = {})).enabled != null ? this.cfg.tip.enabled : true);
|
|
161
|
-
this.obj.fit(this.layout.getBox('view'));
|
|
162
|
-
pal = this.cfg.palette
|
|
163
|
-
? this.cfg.palette.colors
|
|
164
|
-
: ['#f00', '#999', '#00f'];
|
|
165
|
-
len = pal.length;
|
|
166
|
-
this.ticks = d3.quantize(function(it){
|
|
167
|
-
return (1 - it) * (this$.extent.c[1] - this$.extent.c[0]) + this$.extent.c[0];
|
|
168
|
-
}, len).map(function(it){
|
|
169
|
-
var that;
|
|
101
|
+
return results$;
|
|
102
|
+
}()).filter(function(it){
|
|
103
|
+
return it[1].toLowerCase() === data.properties.alpha2;
|
|
104
|
+
})[0];
|
|
105
|
+
name = ret
|
|
106
|
+
? ret[0]
|
|
107
|
+
: data.properties.shortname || data.data.name;
|
|
108
|
+
v = isNaN(data.data.color)
|
|
109
|
+
? '-'
|
|
110
|
+
: data.data.color.toFixed(2) + "" + (this$.binding.color.unit || '');
|
|
170
111
|
return {
|
|
171
|
-
|
|
172
|
-
|
|
112
|
+
name: name,
|
|
113
|
+
value: v
|
|
173
114
|
};
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
return
|
|
177
|
-
});
|
|
178
|
-
if (this.cfg.palette) {
|
|
179
|
-
this.scale.color = d3.scaleLinear().domain(this.ticks.map(function(it){
|
|
180
|
-
return it.key;
|
|
181
|
-
})).range(pal.map(function(it){
|
|
182
|
-
return ldcolor.web(it.value || it);
|
|
183
|
-
}));
|
|
115
|
+
},
|
|
116
|
+
range: function(){
|
|
117
|
+
return this$.layout.getNode('view').getBoundingClientRect();
|
|
184
118
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
119
|
+
});
|
|
120
|
+
return this.obj.init().then(function(){
|
|
121
|
+
return this$.obj.fit();
|
|
122
|
+
});
|
|
123
|
+
},
|
|
124
|
+
destroy: function(){
|
|
125
|
+
return this.tip.destroy();
|
|
126
|
+
},
|
|
127
|
+
parse: function(){
|
|
128
|
+
var geoData, this$ = this;
|
|
129
|
+
geoData = d3.select(this.g).selectAll('path').data();
|
|
130
|
+
geoData.map(function(d){
|
|
131
|
+
d.data = null;
|
|
132
|
+
d.properties.value = 0;
|
|
133
|
+
return d.properties.data = {};
|
|
134
|
+
});
|
|
135
|
+
this.data.map(function(it){
|
|
136
|
+
return {
|
|
137
|
+
c: this$.obj.findCountry(it.name),
|
|
138
|
+
v: it
|
|
139
|
+
};
|
|
140
|
+
}).filter(function(it){
|
|
141
|
+
return it.c;
|
|
142
|
+
}).map(function(it){
|
|
143
|
+
var ref$;
|
|
144
|
+
return ref$ = it.c, ref$.value = it.v.color, ref$.data = it.v, ref$;
|
|
145
|
+
});
|
|
146
|
+
geoData.map(function(d){
|
|
147
|
+
return d.data = d.properties.data || {};
|
|
148
|
+
});
|
|
149
|
+
return this.extent = {
|
|
150
|
+
c: d3.extent(geoData, function(it){
|
|
151
|
+
return it.properties.value;
|
|
152
|
+
})
|
|
153
|
+
};
|
|
154
|
+
},
|
|
155
|
+
resize: function(){
|
|
156
|
+
var ref$, pal, len, this$ = this;
|
|
157
|
+
this.tip.toggle(((ref$ = this.cfg).tip || (ref$.tip = {})).enabled != null ? this.cfg.tip.enabled : true);
|
|
158
|
+
this.obj.fit(this.layout.getBox('view'));
|
|
159
|
+
pal = this.cfg.palette
|
|
160
|
+
? this.cfg.palette.colors
|
|
161
|
+
: ['#f00', '#999', '#00f'];
|
|
162
|
+
len = pal.length;
|
|
163
|
+
this.ticks = d3.quantize(function(it){
|
|
164
|
+
return (1 - it) * (this$.extent.c[1] - this$.extent.c[0]) + this$.extent.c[0];
|
|
165
|
+
}, len).map(function(it){
|
|
166
|
+
var that;
|
|
167
|
+
return {
|
|
168
|
+
key: it,
|
|
169
|
+
text: d3.format(this$.cfg.legendFormat || '.2f')(it) + ((that = this$.binding.color.unit) ? that : '')
|
|
170
|
+
};
|
|
171
|
+
});
|
|
172
|
+
this.ticks.sort(function(a, b){
|
|
173
|
+
return a.key - b.key;
|
|
174
|
+
});
|
|
175
|
+
if (this.cfg.palette) {
|
|
176
|
+
this.scale.color = d3.scaleLinear().domain(this.ticks.map(function(it){
|
|
177
|
+
return it.key;
|
|
178
|
+
})).range(pal.map(function(it){
|
|
179
|
+
return ldcolor.web(it.value || it);
|
|
180
|
+
}));
|
|
181
|
+
}
|
|
182
|
+
return this.legend.data(this.ticks);
|
|
183
|
+
},
|
|
184
|
+
render: function(){
|
|
185
|
+
var this$ = this;
|
|
186
|
+
this.legend.render();
|
|
187
|
+
return d3.select(this.g).selectAll('path').transition().duration(350).attr('fill', function(d, i){
|
|
188
|
+
return this$.scale.color(d.properties.value);
|
|
189
|
+
}).attr('fill-opacity', function(d, i){
|
|
190
|
+
if (this$.cfg.dimEmpty) {
|
|
191
|
+
if (d.properties.value) {
|
|
200
192
|
return 1;
|
|
193
|
+
} else {
|
|
194
|
+
return 0.2;
|
|
201
195
|
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
|
|
196
|
+
} else {
|
|
197
|
+
return 1;
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}
|
|
205
201
|
};
|
|
206
|
-
|
|
207
|
-
});</script></div>
|
|
202
|
+
};</script></div>
|
package/web/static/css/index.css
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@font-face{font-family:'ldi';font-weight:normal;font-style:normal;src:url("/assets/lib/ldiconfont/main/ldif.ttf") format('truetype')}
|
package/web/static/index.html
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<!DOCTYPE html><html><head><link rel="stylesheet" type="text/css" href="/assets/lib/bootstrap/main/css/bootstrap.min.css"><link rel="stylesheet" type="text/css" href="/assets/lib/@loadingio/bootstrap.ext/main/index.min.css"><link rel="stylesheet" type="text/css" href="/assets/lib/@loadingio/loading.css/main/loading.min.css"><link rel="stylesheet" type="text/css" href="/css/index.css"><link rel="stylesheet" type="text/css" href="/assets/lib/ldpalettepicker/main/index.min.css"><style type="text/css">html,
|
|
1
|
+
<!DOCTYPE html><html><head><link rel="stylesheet" type="text/css" href="/assets/lib/bootstrap/main/css/bootstrap.min.css"><link rel="stylesheet" type="text/css" href="/assets/lib/@loadingio/bootstrap.ext/main/index.min.css"><link rel="stylesheet" type="text/css" href="/assets/lib/@loadingio/loading.css/main/loading.min.css"><link rel="stylesheet" type="text/css" href="/assets/lib/ldiconfont/main/ldif.min.css"><link rel="stylesheet" type="text/css" href="/css/index.css"><link rel="stylesheet" type="text/css" href="/assets/lib/ldpalettepicker/main/index.min.css"><style type="text/css">html,
|
|
2
2
|
body {
|
|
3
3
|
width: 100%;
|
|
4
4
|
height: 100%;
|