Skip to content

Instantly share code, notes, and snippets.

@radbrt
Last active September 26, 2015 20:24
Show Gist options
  • Save radbrt/c728f5bd29f3d3e11d81 to your computer and use it in GitHub Desktop.
Save radbrt/c728f5bd29f3d3e11d81 to your computer and use it in GitHub Desktop.
European earnings

#European earnings Click on a country to see earnings for the tree Structure of Earnings surveys collected by Eurostat (2002, 2006, 2010). The chloropleth map displays earnings from latest year. Unfortunately, many countries do not have data for 2002 (other datasets are being explored).

Choose between nominal Euros and purchasing power adjusted figures. Unfortunately the barchart doesn't update automatically upon changing between the two.

Data from Eurostat, map blatantly borrowed from https://gist.github.com/Hedva/8226636.

Display the source blob
Display the rendered blob
Raw
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[
4.3,
51.26
],
[
4.25,
51.38
],
[
5.04,
51.49
],
[
6.01,
50.76
],
[
6.13,
50.13
],
[
6.03,
50.18
],
[
5.81,
49.55
],
[
4.83,
50.17
],
[
4.15,
49.98
],
[
2.54,
51.09
],
[
3.37,
51.37
],
[
4.24,
51.35
],
[
4.3,
51.26
]
]
]
]
},
"properties": {
"name": "Belgi\u00eb"
},
"id": "BE"
},
{
"type": "Feature",
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[
27.88,
42.84
],
[
27.45,
42.47
],
[
28.01,
41.98
],
[
27.39,
42.01
],
[
26.36,
41.71
],
[
26.29,
41.71
],
[
25.29,
41.24
],
[
22.94,
41.34
],
[
22.37,
42.32
],
[
23,
43.19
],
[
22.37,
43.83
],
[
22.68,
44.22
],
[
24.18,
43.68
],
[
27.04,
44.15
],
[
28.58,
43.75
],
[
27.88,
42.84
]
]
]
]
},
"properties": {
"name": "Bulgarije"
},
"id": "BG"
},
{
"type": "Feature",
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[
14.7,
48.58
],
[
13.83,
48.77
],
[
12.09,
50.32
],
[
14.83,
50.87
],
[
16.34,
50.66
],
[
16.64,
50.11
],
[
17.72,
50.32
],
[
18.85,
49.52
],
[
16.95,
48.62
],
[
15.03,
49.02
],
[
14.7,
48.58
]
]
]
]
},
"properties": {
"name": "Tjechi\u00eb"
},
"id": "CZ"
},
{
"type": "Feature",
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[
10.75,
55.48
],
[
10.5,
55.03
],
[
9.68,
55.5
],
[
10.75,
55.48
]
]
],
[
[
[
12.57,
55.99
],
[
12.07,
54.97
],
[
10.87,
55.73
],
[
12.57,
55.99
]
]
],
[
[
[
8.92,
56.92
],
[
8.77,
56.69
],
[
8.51,
56.74
],
[
8.92,
56.92
]
]
],
[
[
[
9.97,
57.07
],
[
10.31,
56.98
],
[
10.31,
56.75
],
[
9.87,
56.65
],
[
10.96,
56.44
],
[
9.55,
55.71
],
[
9.77,
54.89
],
[
9.45,
54.83
],
[
8.66,
54.91
],
[
8.62,
55.43
],
[
8.09,
55.55
],
[
8.17,
56.65
],
[
8.73,
56.48
],
[
8.68,
56.62
],
[
9.08,
56.81
],
[
9.15,
56.7
],
[
9.06,
56.57
],
[
9.27,
56.63
],
[
9.32,
56.53
],
[
9.18,
56.92
],
[
9.97,
57.07
]
]
],
[
[
[
10.43,
57.59
],
[
10.34,
56.99
],
[
10.01,
57.09
],
[
9.12,
57.05
],
[
8.67,
56.95
],
[
8.42,
56.68
],
[
8.59,
56.69
],
[
8.55,
56.58
],
[
8.24,
56.71
],
[
8.62,
57.12
],
[
9.39,
57.15
],
[
9.95,
57.58
],
[
10.65,
57.74
],
[
10.43,
57.59
]
]
]
]
},
"properties": {
"name": "Denemarken"
},
"id": "DK"
},
{
"type": "Feature",
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[
10.98,
54.38
],
[
10.82,
53.89
],
[
12.53,
54.47
],
[
14.28,
53.7
],
[
14.83,
50.87
],
[
12.09,
50.32
],
[
13.83,
48.77
],
[
12.76,
48.12
],
[
13.02,
47.47
],
[
9.57,
47.54
],
[
7.7,
47.54
],
[
7.59,
47.58
],
[
8.23,
48.96
],
[
6.36,
49.46
],
[
6.13,
50.13
],
[
6.01,
50.76
],
[
5.96,
51.81
],
[
6.83,
51.97
],
[
7.07,
52.39
],
[
6.69,
52.55
],
[
7.21,
53.24
],
[
7.3,
53.69
],
[
8.5,
53.35
],
[
8.67,
53.89
],
[
9.83,
53.54
],
[
8.9,
53.94
],
[
8.6,
54.33
],
[
9.02,
54.5
],
[
8.28,
54.75
],
[
8.66,
54.91
],
[
9.45,
54.83
],
[
10.98,
54.38
]
]
]
]
},
"properties": {
"name": "Duitsland"
},
"id": "DE"
},
{
"type": "Feature",
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[
22.99,
58.6
],
[
23.33,
58.44
],
[
21.99,
57.92
],
[
21.83,
58.5
],
[
22.99,
58.6
]
]
],
[
[
[
22.75,
59
],
[
23.05,
58.84
],
[
22.04,
58.94
],
[
22.75,
59
]
]
],
[
[
[
25.78,
59.63
],
[
28.02,
59.48
],
[
27.43,
58.81
],
[
27.82,
57.87
],
[
27.37,
57.54
],
[
25.29,
58.08
],
[
24.31,
57.87
],
[
24.56,
58.33
],
[
23.73,
58.37
],
[
23.46,
59.21
],
[
25.78,
59.63
]
]
]
]
},
"properties": {
"name": "Estland"
},
"id": "EE"
},
{
"type": "Feature",
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[
-7.41,
54.95
],
[
-8.16,
54.44
],
[
-6.27,
54.1
],
[
-6.01,
52.95
],
[
-6.36,
52.18
],
[
-9.23,
51.48
],
[
-10.34,
51.78
],
[
-9.76,
52.15
],
[
-10.46,
52.18
],
[
-8.82,
52.67
],
[
-9.94,
52.56
],
[
-8.94,
53.26
],
[
-10.18,
53.41
],
[
-9.56,
53.86
],
[
-10.11,
54.23
],
[
-8.47,
54.27
],
[
-8.19,
54.63
],
[
-8.8,
54.69
],
[
-8.32,
55.11
],
[
-6.93,
55.24
],
[
-7.25,
55.07
],
[
-7.41,
54.95
]
]
]
]
},
"properties": {
"name": "Ierland"
},
"id": "IE"
},
{
"type": "Feature",
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[
23.86,
35.52
],
[
26.29,
35.13
],
[
24.75,
34.94
],
[
23.52,
35.29
],
[
23.86,
35.52
]
]
],
[
[
[
23.46,
38.85
],
[
24.56,
37.99
],
[
22.83,
38.83
],
[
23.46,
38.85
]
]
],
[
[
[
26.29,
41.71
],
[
26.36,
41.71
],
[
26.63,
41.35
],
[
26.04,
40.74
],
[
23.74,
40.75
],
[
24.4,
40.15
],
[
23.35,
40.25
],
[
23.71,
39.91
],
[
22.59,
40.48
],
[
23.34,
39.18
],
[
22.94,
39.36
],
[
23.07,
39.04
],
[
22.52,
38.86
],
[
24.07,
38.2
],
[
24.03,
37.65
],
[
23.52,
38.04
],
[
22.99,
37.88
],
[
23.51,
37.43
],
[
22.73,
37.57
],
[
23.2,
36.43
],
[
22.63,
36.8
],
[
22.49,
36.39
],
[
22.15,
37.02
],
[
21.7,
36.82
],
[
21.11,
37.85
],
[
21.86,
38.34
],
[
23.23,
38.15
],
[
22.4,
38.45
],
[
21.15,
38.3
],
[
20.73,
38.8
],
[
21.15,
39
],
[
20.01,
39.69
],
[
20.98,
40.86
],
[
22.94,
41.34
],
[
25.29,
41.24
],
[
26.29,
41.71
]
]
]
]
},
"properties": {
"name": "Griekenland"
},
"id": "GR"
},
{
"type": "Feature",
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[
-16.34,
28.37
],
[
-16.67,
27.98
],
[
-16.91,
28.34
],
[
-16.34,
28.37
]
]
],
[
[
[
3.25,
39.73
],
[
3.06,
39.26
],
[
2.36,
39.56
],
[
3.25,
39.73
]
]
],
[
[
[
-7.86,
43.76
],
[
-1.78,
43.36
],
[
1.45,
42.6
],
[
1.72,
42.51
],
[
3.18,
42.44
],
[
3.18,
41.87
],
[
0.96,
41.03
],
[
0.05,
40.04
],
[
-0.34,
39.44
],
[
0.21,
38.73
],
[
-0.72,
37.61
],
[
-2.13,
36.73
],
[
-4.4,
36.72
],
[
-5.33,
36.16
],
[
-5.36,
36.16
],
[
-6.04,
36.18
],
[
-6.36,
36.86
],
[
-7.43,
37.25
],
[
-6.95,
39.03
],
[
-7.53,
39.67
],
[
-7.02,
39.67
],
[
-6.93,
41.02
],
[
-6.19,
41.58
],
[
-6.59,
41.95
],
[
-8.2,
41.87
],
[
-8.75,
41.95
],
[
-9.21,
43.15
],
[
-7.86,
43.76
]
]
]
]
},
"properties": {
"name": "Spanje"
},
"id": "ES"
},
{
"type": "Feature",
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[
9.45,
42.68
],
[
9.18,
41.36
],
[
8.58,
42.38
],
[
9.35,
43
],
[
9.45,
42.68
]
]
],
[
[
[
2.54,
51.09
],
[
4.15,
49.98
],
[
4.83,
50.17
],
[
5.81,
49.55
],
[
6.36,
49.46
],
[
8.23,
48.96
],
[
7.59,
47.58
],
[
6.99,
47.5
],
[
5.97,
46.21
],
[
6.79,
46.43
],
[
7.04,
45.93
],
[
7.13,
45.26
],
[
6.62,
45.11
],
[
6.98,
44.28
],
[
7.66,
44.17
],
[
7.53,
43.79
],
[
7.44,
43.76
],
[
7.42,
43.77
],
[
7.39,
43.73
],
[
6.17,
43.05
],
[
3.96,
43.54
],
[
3.08,
43.07
],
[
3.18,
42.44
],
[
1.72,
42.51
],
[
1.78,
42.57
],
[
1.45,
42.6
],
[
-1.78,
43.36
],
[
-1.04,
44.68
],
[
-1.25,
44.66
],
[
-1.08,
45.56
],
[
-0.54,
44.9
],
[
-0.78,
45.46
],
[
-1.24,
45.7
],
[
-1.11,
46.32
],
[
-2.13,
46.84
],
[
-2.13,
47.28
],
[
-1.73,
47.21
],
[
-4.37,
47.8
],
[
-4.73,
48.04
],
[
-4.19,
48.3
],
[
-4.78,
48.51
],
[
-1.37,
48.64
],
[
-1.94,
49.72
],
[
0.42,
49.45
],
[
0.07,
49.53
],
[
1.46,
50.12
],
[
1.63,
50.88
],
[
2.54,
51.09
]
]
]
]
},
"properties": {
"name": "Frankrijk"
},
"id": "FR"
},
{
"type": "Feature",
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[
15.53,
38.14
],
[
15.08,
36.65
],
[
12.42,
37.8
],
[
13.32,
38.22
],
[
15.53,
38.14
]
]
],
[
[
[
9.51,
41.15
],
[
9.57,
39.15
],
[
8.41,
38.96
],
[
8.19,
40.91
],
[
9.51,
41.15
]
]
],
[
[
[
12.13,
47
],
[
13.72,
46.53
],
[
13.38,
46.3
],
[
13.72,
45.6
],
[
12.28,
45.47
],
[
12.37,
44.25
],
[
13.62,
43.55
],
[
14.74,
42.09
],
[
16.14,
41.91
],
[
15.93,
41.48
],
[
18.51,
40.14
],
[
18.35,
39.79
],
[
16.91,
40.45
],
[
16.49,
39.77
],
[
17.17,
38.96
],
[
16.06,
37.92
],
[
15.63,
38.01
],
[
16.22,
38.91
],
[
15.67,
40.03
],
[
11.1,
42.39
],
[
10.11,
44.01
],
[
8.75,
44.43
],
[
7.53,
43.79
],
[
7.66,
44.17
],
[
6.98,
44.28
],
[
6.62,
45.11
],
[
7.13,
45.26
],
[
7.04,
45.93
],
[
7.86,
45.92
],
[
8.44,
46.46
],
[
9.04,
45.84
],
[
9.28,
46.5
],
[
10.13,
46.23
],
[
10.47,
46.87
],
[
12.13,
47
]
],
[
[
12.46,
43.9
],
[
12.51,
43.99
],
[
12.42,
43.96
],
[
12.46,
43.9
]
],
[
[
12.45,
41.9
],
[
12.46,
41.9
],
[
12.45,
41.91
],
[
12.45,
41.9
]
]
]
]
},
"properties": {
"name": "Itali\u00eb"
},
"id": "IT"
},
{
"type": "Feature",
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[
33.65,
35.35
],
[
34.59,
35.69
],
[
33.03,
34.56
],
[
32.27,
35.04
],
[
33.65,
35.35
]
]
]
]
},
"properties": {
"name": "Cyprus"
},
"id": "CY"
},
{
"type": "Feature",
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[
21.07,
56.44
],
[
21.73,
57.58
],
[
22.61,
57.76
],
[
23.79,
56.97
],
[
24.41,
57.26
],
[
24.31,
57.87
],
[
25.29,
58.08
],
[
27.37,
57.54
],
[
27.86,
57.3
],
[
28.17,
56.15
],
[
26.61,
55.67
],
[
25,
56.3
],
[
21.05,
56.08
],
[
21.07,
56.44
]
]
]
]
},
"properties": {
"name": "Letland"
},
"id": "LV"
},
{
"type": "Feature",
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[
25,
56.3
],
[
26.61,
55.67
],
[
26.82,
55.28
],
[
25.79,
54.87
],
[
25.79,
54.16
],
[
23.5,
53.95
],
[
22.79,
54.36
],
[
22.84,
54.9
],
[
21.43,
55.25
],
[
21.26,
55.25
],
[
21.05,
56.08
],
[
25,
56.3
]
]
]
]
},
"properties": {
"name": "Litouwen"
},
"id": "LT"
},
{
"type": "Feature",
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[
6.03,
50.18
],
[
6.13,
50.13
],
[
6.36,
49.46
],
[
5.81,
49.55
],
[
6.03,
50.18
]
]
]
]
},
"properties": {
"name": "Luxemburg"
},
"id": "LU"
},
{
"type": "Feature",
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[
18.82,
45.91
],
[
17.67,
45.83
],
[
16.61,
46.48
],
[
16.11,
46.87
],
[
16.51,
47.01
],
[
16.45,
47.7
],
[
17.17,
48.01
],
[
17.25,
48.02
],
[
18.66,
47.76
],
[
20.66,
48.56
],
[
22.15,
48.41
],
[
22.89,
47.95
],
[
20.73,
46.18
],
[
20.26,
46.11
],
[
18.82,
45.91
]
]
]
]
},
"properties": {
"name": "Hongarije"
},
"id": "HU"
},
{
"type": "Feature",
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[
14.56,
35.82
],
[
14.37,
35.85
],
[
14.33,
35.98
],
[
14.56,
35.82
]
]
],
[
[
[
14.27,
36.01
],
[
14.18,
36.06
],
[
14.34,
36.03
],
[
14.27,
36.01
]
]
]
]
},
"properties": {
"name": "Malta"
},
"id": "MT"
},
{
"type": "Feature",
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[
3.76,
51.35
],
[
3.37,
51.37
],
[
4.24,
51.35
],
[
3.76,
51.35
]
]
],
[
[
[
5.76,
52.42
],
[
5.43,
52.26
],
[
5.14,
52.38
],
[
5.64,
52.6
],
[
5.86,
52.54
],
[
5.76,
52.42
]
]
],
[
[
[
5.42,
52.64
],
[
5.05,
52.39
],
[
5.04,
52.63
],
[
5.42,
52.64
]
]
],
[
[
[
6.87,
53.42
],
[
7.21,
53.24
],
[
6.69,
52.55
],
[
7.07,
52.39
],
[
6.83,
51.97
],
[
5.96,
51.81
],
[
6.01,
50.76
],
[
5.04,
51.49
],
[
4.25,
51.38
],
[
3.44,
51.54
],
[
4.29,
51.45
],
[
3.69,
51.71
],
[
4.17,
51.69
],
[
3.87,
51.81
],
[
4.58,
52.46
],
[
5.42,
52.25
],
[
5.77,
52.41
],
[
5.88,
52.51
],
[
5.86,
52.61
],
[
5.6,
52.66
],
[
5.6,
52.76
],
[
5.72,
52.84
],
[
5.37,
52.88
],
[
5.42,
52.96
],
[
5.36,
53.07
],
[
5.1,
52.95
],
[
5.3,
52.71
],
[
5.03,
52.63
],
[
5.03,
52.38
],
[
4.58,
52.47
],
[
4.73,
52.96
],
[
6.87,
53.42
]
]
]
]
},
"properties": {
"name": "Nederland"
},
"id": "NL"
},
{
"type": "Feature",
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[
13.83,
48.77
],
[
14.7,
48.58
],
[
15.03,
49.02
],
[
16.95,
48.62
],
[
17.17,
48.01
],
[
16.45,
47.7
],
[
16.51,
47.01
],
[
16.11,
46.87
],
[
13.72,
46.53
],
[
12.13,
47
],
[
10.47,
46.87
],
[
9.6,
47.06
],
[
9.53,
47.27
],
[
9.57,
47.54
],
[
13.02,
47.47
],
[
12.76,
48.12
],
[
13.83,
48.77
]
]
]
]
},
"properties": {
"name": "Oostenrijk"
},
"id": "AT"
},
{
"type": "Feature",
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[
18.85,
49.52
],
[
17.72,
50.32
],
[
16.64,
50.11
],
[
16.34,
50.66
],
[
14.83,
50.87
],
[
14.28,
53.7
],
[
17.9,
54.82
],
[
19.8,
54.44
],
[
22.79,
54.36
],
[
23.5,
53.95
],
[
23.94,
52.73
],
[
23.17,
52.28
],
[
23.64,
52.08
],
[
23.6,
51.53
],
[
24.11,
50.57
],
[
22.56,
49.08
],
[
18.85,
49.52
]
]
]
]
},
"properties": {
"name": "Polen"
},
"id": "PL"
},
{
"type": "Feature",
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[
-8.2,
41.87
],
[
-6.59,
41.95
],
[
-6.19,
41.58
],
[
-6.93,
41.02
],
[
-7.02,
39.67
],
[
-7.53,
39.67
],
[
-6.95,
39.03
],
[
-7.43,
37.25
],
[
-8.99,
37.02
],
[
-8.67,
38.41
],
[
-9.18,
38.42
],
[
-8.98,
38.95
],
[
-9.48,
38.71
],
[
-8.66,
40.69
],
[
-8.75,
41.95
],
[
-8.2,
41.87
]
]
]
]
},
"properties": {
"name": "Portugal"
},
"id": "PT"
},
{
"type": "Feature",
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[
20.73,
46.18
],
[
22.89,
47.95
],
[
24.92,
47.71
],
[
26.63,
48.26
],
[
28.12,
46.85
],
[
28.21,
45.45
],
[
29.66,
45.21
],
[
29.55,
44.82
],
[
28.87,
44.94
],
[
28.58,
43.75
],
[
27.04,
44.15
],
[
24.18,
43.68
],
[
22.68,
44.22
],
[
22.48,
44.71
],
[
21.4,
44.78
],
[
21.51,
45.15
],
[
20.26,
46.11
],
[
20.73,
46.18
]
]
]
]
},
"properties": {
"name": "Roemeni\u00eb"
},
"id": "RO"
},
{
"type": "Feature",
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[
13.72,
46.53
],
[
16.11,
46.87
],
[
16.61,
46.48
],
[
16.57,
46.48
],
[
15.65,
46.22
],
[
15.17,
45.43
],
[
13.59,
45.48
],
[
13.72,
45.6
],
[
13.38,
46.3
],
[
13.72,
46.53
]
]
]
]
},
"properties": {
"name": "Sloveni\u00eb"
},
"id": "SI"
},
{
"type": "Feature",
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[
17.25,
48.02
],
[
17.17,
48.01
],
[
16.95,
48.62
],
[
18.85,
49.52
],
[
22.56,
49.08
],
[
22.15,
48.41
],
[
20.66,
48.56
],
[
18.66,
47.76
],
[
17.25,
48.02
]
]
]
]
},
"properties": {
"name": "Slovakije"
},
"id": "SK"
},
{
"type": "Feature",
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[
28.17,
69.91
],
[
29.18,
69.64
],
[
28.96,
69.05
],
[
28.43,
68.9
],
[
28.82,
68.84
],
[
28.69,
68.2
],
[
30.03,
67.69
],
[
29.07,
66.9
],
[
30.13,
65.72
],
[
29.64,
64.93
],
[
30.58,
64.22
],
[
29.99,
63.74
],
[
31.59,
62.91
],
[
27.81,
60.55
],
[
22.91,
59.8
],
[
23.34,
60.02
],
[
23.09,
60.35
],
[
21.36,
60.65
],
[
21.67,
61.55
],
[
21.06,
62.61
],
[
21.5,
63.21
],
[
25.45,
64.95
],
[
25.31,
65.51
],
[
24.17,
65.81
],
[
23.66,
66.31
],
[
24.01,
66.8
],
[
23.43,
67.47
],
[
23.67,
67.94
],
[
21.81,
68.57
],
[
20.58,
69.06
],
[
21.32,
69.33
],
[
22.4,
68.71
],
[
24.93,
68.58
],
[
26.45,
69.93
],
[
28.17,
69.91
]
]
]
]
},
"properties": {
"name": "Finland"
},
"id": "FI"
},
{
"type": "Feature",
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[
21.81,
68.57
],
[
23.67,
67.94
],
[
23.43,
67.47
],
[
24.01,
66.8
],
[
23.66,
66.31
],
[
24.17,
65.81
],
[
21.77,
65.72
],
[
22.2,
65.55
],
[
21.26,
65.34
],
[
21.62,
65.14
],
[
21.04,
64.82
],
[
21.58,
64.44
],
[
20.78,
63.87
],
[
18.21,
62.78
],
[
17.7,
62.99
],
[
18.05,
62.6
],
[
17.33,
62.49
],
[
17.65,
62.23
],
[
17.15,
60.95
],
[
19.08,
59.76
],
[
17.94,
59.34
],
[
17.59,
59.81
],
[
17.73,
59.44
],
[
16.02,
59.49
],
[
17.38,
59.25
],
[
18.65,
59.32
],
[
16.19,
58.63
],
[
16.94,
58.48
],
[
16.41,
58.47
],
[
16.82,
58.2
],
[
16.42,
57.89
],
[
16.69,
57.47
],
[
15.87,
56.09
],
[
14.7,
56.16
],
[
14.19,
55.39
],
[
12.98,
55.4
],
[
12.45,
56.3
],
[
12.89,
56.64
],
[
11.7,
57.7
],
[
11.8,
58.32
],
[
11.2,
58.4
],
[
11.11,
59
],
[
11.43,
58.99
],
[
11.82,
59.85
],
[
12.49,
60.11
],
[
12.21,
61
],
[
12.86,
61.36
],
[
12.12,
61.73
],
[
12.14,
63.58
],
[
13.99,
64.02
],
[
14.12,
64.47
],
[
13.66,
64.58
],
[
14.49,
65.31
],
[
14.5,
66.13
],
[
15.47,
66.28
],
[
16.73,
67.9
],
[
17.88,
67.95
],
[
18.09,
68.51
],
[
19.94,
68.34
],
[
20.35,
68.79
],
[
20.1,
69.04
],
[
20.58,
69.06
],
[
21.81,
68.57
]
]
]
]
},
"properties": {
"name": "Zweden"
},
"id": "SE"
},
{
"type": "Feature",
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[
-6.35,
55.24
],
[
-5.43,
54.48
],
[
-6.27,
54.1
],
[
-8.16,
54.44
],
[
-7.41,
54.95
],
[
-7.25,
55.07
],
[
-6.35,
55.24
]
]
],
[
[
[
-5.78,
56.51
],
[
-6.37,
56.31
],
[
-6.32,
56.6
],
[
-5.78,
56.51
]
]
],
[
[
[
-6.14,
57.57
],
[
-5.66,
57.2
],
[
-6.79,
57.45
],
[
-6.14,
57.57
]
]
],
[
[
[
-6.2,
58.36
],
[
-7.12,
57.82
],
[
-7.04,
58.23
],
[
-6.2,
58.36
]
]
],
[
[
[
-3.01,
58.63
],
[
-4.44,
57.57
],
[
-1.77,
57.46
],
[
-3.28,
56.36
],
[
-2.58,
56.27
],
[
-3.73,
56.03
],
[
-1.63,
55.58
],
[
-1.3,
54.76
],
[
-0.07,
54.11
],
[
0.12,
53.56
],
[
-0.72,
53.7
],
[
0.24,
53.4
],
[
0.000037000000134,
52.88
],
[
1.68,
52.75
],
[
1.59,
52.08
],
[
0.38,
51.45
],
[
1.41,
51.18
],
[
-5.68,
50.04
],
[
-4.23,
51.19
],
[
-3.03,
51.21
],
[
-2.38,
51.76
],
[
-3.35,
51.38
],
[
-5.25,
51.73
],
[
-4.13,
52.33
],
[
-4.13,
52.91
],
[
-4.76,
52.79
],
[
-4.2,
53.21
],
[
-2.7,
53.35
],
[
-3.11,
53.55
],
[
-2.81,
54.22
],
[
-3.63,
54.51
],
[
-3.04,
54.98
],
[
-4.95,
54.65
],
[
-5.17,
55
],
[
-4.61,
55.49
],
[
-4.92,
55.7
],
[
-4.88,
55.94
],
[
-4.48,
55.92
],
[
-4.83,
56.11
],
[
-5.3,
55.85
],
[
-5.03,
56.23
],
[
-5.78,
55.3
],
[
-5.12,
56.82
],
[
-6.24,
56.71
],
[
-5.4,
57.11
],
[
-5.82,
57.82
],
[
-5.1,
57.85
],
[
-5.46,
58.08
],
[
-5,
58.62
],
[
-3.01,
58.63
]
]
],
[
[
[
-2.79,
58.95
],
[
-3.19,
58.91
],
[
-3.35,
59.11
],
[
-2.79,
58.95
]
]
],
[
[
[
-1.3,
60.49
],
[
-1.27,
59.85
],
[
-1.69,
60.28
],
[
-1.3,
60.49
]
]
]
]
},
"properties": {
"name": "Verenigd Koninkrijk"
},
"id": "GB"
},
{
"type": "Feature",
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[
13.97,
68.24
],
[
14.14,
68.24
],
[
13.45,
68.07
],
[
13.97,
68.24
]
]
],
[
[
[
15.03,
68.35
],
[
14.2,
68.15
],
[
15.17,
68.45
],
[
15.03,
68.35
]
]
],
[
[
[
15.38,
68.85
],
[
15.06,
68.57
],
[
14.37,
68.68
],
[
15.38,
68.85
]
]
],
[
[
[
15.99,
68.75
],
[
15.74,
68.53
],
[
16.57,
68.65
],
[
14.99,
68.25
],
[
15.64,
68.95
],
[
15.99,
68.75
]
]
],
[
[
[
17.64,
69.52
],
[
18.07,
69.43
],
[
17.88,
69.24
],
[
18,
69.19
],
[
16.78,
69.06
],
[
17.64,
69.52
]
]
],
[
[
[
18.89,
69.69
],
[
18,
69.59
],
[
18.69,
69.88
],
[
18.89,
69.69
]
]
],
[
[
[
23.6,
70.58
],
[
23.23,
70.28
],
[
22.85,
70.41
],
[
23.6,
70.58
]
]
],
[
[
[
23.45,
70.78
],
[
22.78,
70.52
],
[
21.95,
70.65
],
[
23.45,
70.78
]
]
],
[
[
[
5.34,
61.59
],
[
4.94,
61.68
],
[
6.76,
61.87
],
[
5.15,
61.89
],
[
5.15,
62.21
],
[
6.36,
62.06
],
[
5.92,
62.22
],
[
6.31,
62.37
],
[
6.54,
62.1
],
[
6.39,
62.37
],
[
6.7,
62.45
],
[
6.87,
62.42
],
[
7,
62.25
],
[
6.94,
62.11
],
[
7.04,
62.09
],
[
7.42,
62.23
],
[
6.98,
62.31
],
[
6.92,
62.36
],
[
6.97,
62.37
],
[
6.78,
62.48
],
[
6.26,
62.45
],
[
6.65,
62.5
],
[
6.25,
62.57
],
[
8.15,
62.69
],
[
7.04,
62.97
],
[
8.55,
62.65
],
[
7.88,
63.01
],
[
8.53,
62.84
],
[
8.16,
63.12
],
[
9.65,
63.62
],
[
10.26,
63.26
],
[
10.05,
63.41
],
[
10.91,
63.45
],
[
11.49,
64.02
],
[
11.31,
64.12
],
[
10.57,
63.8
],
[
11.08,
63.84
],
[
10.94,
63.74
],
[
10.05,
63.5
],
[
9.79,
63.66
],
[
10.1,
63.76
],
[
9.54,
63.76
],
[
12.94,
65.31
],
[
12.25,
65.23
],
[
12.67,
65.92
],
[
13.18,
65.85
],
[
12.67,
66.07
],
[
14.15,
66.32
],
[
13.03,
66.19
],
[
13.54,
66.3
],
[
12.97,
66.52
],
[
13.73,
66.6
],
[
13.23,
66.71
],
[
13.99,
66.78
],
[
13.55,
66.93
],
[
15.74,
67.17
],
[
14.36,
67.23
],
[
15.9,
67.56
],
[
14.76,
67.81
],
[
15.97,
68.25
],
[
16.22,
67.89
],
[
16.5,
67.79
],
[
16.21,
68
],
[
16.52,
67.95
],
[
16.36,
68.03
],
[
16.72,
68.07
],
[
16.1,
68.28
],
[
16.81,
68.13
],
[
16.32,
68.37
],
[
17.35,
68.17
],
[
17.55,
68.52
],
[
16.46,
68.51
],
[
17.68,
68.65
],
[
17.24,
68.75
],
[
17.79,
68.76
],
[
17.43,
68.91
],
[
18.15,
69.15
],
[
18,
69.28
],
[
18.26,
69.49
],
[
19.44,
69.23
],
[
18.94,
69.61
],
[
19.76,
69.81
],
[
19.68,
69.43
],
[
20.3,
69.97
],
[
19.95,
69.26
],
[
21.31,
70.02
],
[
22.1,
69.74
],
[
21.8,
70.03
],
[
22.1,
70.11
],
[
21.3,
70.25
],
[
23.31,
69.94
],
[
24.73,
70.62
],
[
24.25,
70.78
],
[
24.59,
70.96
],
[
25.91,
70.89
],
[
25.07,
70.5
],
[
25.23,
70.09
],
[
26.57,
70.94
],
[
26.5,
70.36
],
[
27.03,
70.47
],
[
27.65,
71.11
],
[
28.55,
70.97
],
[
27.65,
70.61
],
[
28.3,
70.71
],
[
27.85,
70.48
],
[
28.34,
70.51
],
[
28.04,
70.06
],
[
29.04,
70.87
],
[
31.08,
70.29
],
[
28.61,
70.11
],
[
29.67,
69.97
],
[
29.49,
69.66
],
[
30.85,
69.79
],
[
28.96,
69.05
],
[
29.18,
69.64
],
[
28.17,
69.91
],
[
26.45,
69.93
],
[
24.93,
68.58
],
[
22.4,
68.71
],
[
21.32,
69.33
],
[
20.58,
69.06
],
[
20.1,
69.04
],
[
20.35,
68.79
],
[
19.94,
68.34
],
[
18.09,
68.51
],
[
17.88,
67.95
],
[
16.73,
67.9
],
[
15.47,
66.28
],
[
14.5,
66.13
],
[
14.49,
65.31
],
[
13.66,
64.58
],
[
14.12,
64.47
],
[
13.99,
64.02
],
[
12.14,
63.58
],
[
12.12,
61.73
],
[
12.86,
61.36
],
[
12.21,
61
],
[
12.49,
60.11
],
[
11.82,
59.85
],
[
11.43,
58.99
],
[
10.8,
59.19
],
[
10.53,
59.88
],
[
10.23,
59.04
],
[
9.54,
59.11
],
[
8.21,
58.12
],
[
6.6,
58.07
],
[
5.46,
58.74
],
[
6.62,
59.05
],
[
5.87,
59.07
],
[
6.47,
59.56
],
[
5.18,
59.51
],
[
7.11,
60.49
],
[
5.75,
59.99
],
[
5.73,
60.39
],
[
5.14,
60.35
],
[
5.7,
60.69
],
[
4.93,
60.8
],
[
6.59,
61.15
],
[
7.11,
60.86
],
[
7.57,
61.48
],
[
5.4,
61.07
],
[
4.95,
61.26
],
[
5.63,
61.36
],
[
4.95,
61.41
],
[
5.8,
61.45
],
[
5.34,
61.59
]
],
[
[
5.34,
61.59
],
[
5.35,
61.59
],
[
5.28,
61.59
],
[
5.34,
61.59
]
]
]
]
},
"properties": {
"name": "Noorwegen"
},
"id": "NO"
},
{
"type": "Feature",
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[
17.3,
43.01
],
[
17.65,
42.89
],
[
18.46,
42.57
],
[
18.5,
42.45
],
[
17.3,
43.01
]
]
],
[
[
[
16.85,
43.27
],
[
16.4,
43.33
],
[
16.75,
43.36
],
[
16.85,
43.27
]
]
],
[
[
[
14.46,
44.91
],
[
14.49,
44.61
],
[
14.29,
44.91
],
[
14.4,
44.92
],
[
14.32,
45.17
],
[
14.46,
44.91
]
]
],
[
[
[
14.76,
44.94
],
[
14.43,
45.08
],
[
14.54,
45.24
],
[
14.76,
44.94
]
]
],
[
[
[
16.57,
46.48
],
[
16.61,
46.48
],
[
17.67,
45.83
],
[
18.82,
45.91
],
[
19.42,
45.23
],
[
19.04,
44.86
],
[
15.79,
45.17
],
[
16.14,
44.2
],
[
17.58,
42.94
],
[
16.88,
43.4
],
[
15.99,
43.5
],
[
14.48,
45.31
],
[
14.29,
45.32
],
[
14.17,
44.98
],
[
13.9,
44.77
],
[
13.59,
45.48
],
[
15.17,
45.43
],
[
15.65,
46.22
],
[
16.57,
46.48
]
]
]
]
},
"properties": {
"name": "Kroati\u00eb"
},
"id": "HR"
},
{
"type": "Feature",
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[
35.1,
41.96
],
[
38.36,
40.91
],
[
40.15,
40.92
],
[
41.53,
41.52
],
[
42.83,
41.58
],
[
43.46,
41.11
],
[
43.66,
40.11
],
[
44.78,
39.71
],
[
44.81,
39.63
],
[
44.03,
39.38
],
[
44.79,
37.15
],
[
42.36,
37.11
],
[
36.66,
36.83
],
[
36.69,
36.24
],
[
35.92,
35.93
],
[
36.02,
36.93
],
[
32.81,
36.03
],
[
31.05,
36.85
],
[
29.68,
36.12
],
[
28.45,
36.88
],
[
27.38,
36.68
],
[
28.33,
37.04
],
[
27.25,
36.97
],
[
27.6,
37.23
],
[
27.19,
37.35
],
[
27.27,
37.96
],
[
26.28,
38.26
],
[
26.37,
38.66
],
[
27.16,
38.44
],
[
26.73,
38.65
],
[
26.95,
39.55
],
[
26.07,
39.48
],
[
26.71,
40.38
],
[
29.94,
40.72
],
[
29.17,
41.23
],
[
31.23,
41.09
],
[
33.33,
42.02
],
[
35.1,
41.96
]
]
],
[
[
[
27.39,
42.01
],
[
28.01,
41.98
],
[
29.04,
41.06
],
[
27.51,
40.98
],
[
26.18,
40.05
],
[
26.83,
40.59
],
[
26.04,
40.74
],
[
26.63,
41.35
],
[
26.36,
41.71
],
[
27.39,
42.01
]
]
]
]
},
"properties": {
"name": "Turkije"
},
"id": "TR"
}
]
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Diverse</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js" charset="utf-8"></script>
<script type="text/javascript" src="json-stat.js" ></script>
<style type="text/css">
body {
background-color: #fff;
font-family: "Helvetica Neue", "sans-serif";
font-size: 11px;
}
svg.mainFrame {
background-color: #6baed6;
}
svg path {
stroke: #4499aa;
stroke-width: 0.5px;
}
svg path:hover {
fill: orange;
cursor: pointer;
}
.axis path,
.axis line {
fill: none;
stroke: black;
shape-rendering: crispEdges;
}
.axis text {
font-family: "Helvetica Neue", "sans-serif";
font-size: 11px;
}
#tooltip {
position: absolute;
top: 15px;
left: 530px;
z-index: 10;
padding: 5px;
width: 420px;
height: 250px;
color: #CC5D0E;
font-family: sans-serif;
font-size: 12px;
font-weight: bold;
text-align: center;
background-color: rgba(100, 110, 110, 0.75);
opacity: 0;
pointer-events: none;
}
.xlabel {
text-align: center;
}
.bar {
text-align: center;
}
#tooltip.visible {
opacity: 1;
}
/* #radio {
position: absolute;
right: 15px;
bottom: 15px;
z-index: 10;
}*/
</style>
</head>
<body>
<div id="tooltip"></div>
<form id="radio">
<input type="radio" name="group-stack" value="eur" checked>EUR<br>
<input type="radio" name="group-stack" value="pps">PPS
</form>
<script>
var bh = 250;
var bw = 420;
var bp = {t: 10, r: 50, b: 15, l: 10 };
var map;
var nFormat = d3.format(",");
var w = 960;
var h = 500;
d3.select("#radio")
.style("position", "absolute")
.style("left", "900px")
.style("top", "460px");
var projection = d3.geo.equirectangular()
.center([29, 52])
.translate([ w/2, h/2 ])
.scale([ 650 ])
;
var path = d3.geo.path()
.projection(projection);
d3.json("europe3.json", function(json) {
var svg = d3.select("body")
.append("svg")
.attr("width", w)
.attr("height", h)
.attr("class", "mainFrame")
;
JSONstat("http://ec.europa.eu/eurostat/wdds/rest/data/v1.1/json/en/earn_ses_monthly?nace_r2=B-S_X_O&indic_se=ERN_MN_EUR&indic_se=ERN_MN_PPS&sex=T&precision=0&isco08=TOTAL&age=TOTAL&worktime=FT", function() {
dt=this.Dataset(0).toTable({ type : "arrobj", content : "id" })
dt2=d3.nest()
.key(function(d) { return d.geo; })
.entries(dt);
//console.log(dt2);
for (i=0; i<dt2.length; i++) {
for (j=0; j<json.features.length; j++) {
if(json.features[j].id==dt2[i].key) {
json.features[j].ERN_MN_EUR=dt2[i].values[dt2[i].values.length-1].value;
json.features[j].pps=dt2[i].values.filter(function(d) { return d.indic_se=="ERN_MN_PPS"; });
json.features[j].eur=dt2[i].values.filter(function(d) { return d.indic_se=="ERN_MN_EUR"; });
}
}
}
var color=d3.scale.quantize()
.domain([
// d.values[d.values.length-1] pattern to get latest year (if correctly sorted...)
d3.min(dt2, function(d) { return d.values[d.values.length-1].value; }),
d3.max(dt2, function(d) { return d.values[d.values.length-1].value; })
])
.range(["#c7e9c0", "#a1d99b", "#74c476", "#41ab5d", "#238b45", "#005a32"]);
var groups = svg.selectAll("g")
.data(json.features)
.enter()
.append("g")
.attr("class", "gr");
//console.log(json.features);
var map = groups.append("path")
.attr("d", path)
.attr("class", "euCountries")
.attr("fill", function(d) {
if(d.eur) {
return color(d.eur[d.eur.length-1].value);
} else {
return "#ccc";
}
});
var yScale = d3.scale.linear()
.domain([
//OK, this gets convoluted... to be improved. Needed to nest through countries and years.
0,
d3.max(dt2, function(d) {
return d3.max(d.values, function(d) { return d.value; }); })
])
.range([(bh-bp.b), bp.b]);
var xScale = d3.scale.ordinal()
.domain(d3.range(dt2[0].values.filter(function(d) { return d.indic_se=="ERN_MN_EUR"; }).length))
.rangeRoundBands([ bp.r, bw - bp.r ], 0.05);
var yAxis = d3.svg.axis()
.scale(yScale)
.orient("right")
;
var d0 = d3.select("#tooltip");
var divtip = d0
.append("svg")
.attr("width", bw)
.attr("height", bh)
;
var barGroups = divtip.selectAll("g")
.data(json.features[0].pps)
.enter()
.append("g")
.attr("class", "bar")
.attr("width", xScale.rangeBand());
var bar = barGroups
.append("rect")
.attr("class", "barGroups")
.style("fill", "#cc9900")
.attr("width", xScale.rangeBand() )
.attr("y", function(d) { return bh; })
.attr("height", function(d) { return 0; })
;
var yLine = divtip.append("g")
.attr("class", "y axis")
.call(yAxis)
.attr("transform", "translate(" + (bw-bp.r) + ", 0)");
yLine.append("text").text("Mean monthly earnings (€)")
.attr("transform", "rotate(-90), translate(-" + (bh/2) + ",50)")
.attr("text-anchor", "middle")
;
barGroups.append("text")
.attr("class", "xlabel")
.attr("x", function(d, i) { return xScale(i) + (xScale.rangeBand()/2); })
.attr("y", bh)
.attr("width", xScale.rangeBand() )
.text(function(d) { return d.time; })
.attr("text-anchor", "middle")
;
var title = d0.append("div")
.attr("class", "xBoxClass")
.style("position", "absolute")
.style("color", "#333")
.style("top", "5px")
.style("left", "5px")
.style("font-size", "20px");
d3.select("#radio").on("change", function() {
if (d3.select('input[name="group-stack"]:checked').node().value=='eur'){
map
.transition()
.duration(500)
.delay(300)
.attr("fill", function(d) {
if(d.eur) {
return color(d.eur[d.eur.length-1].value);
} else {
return "#ccc";
}
})
} else {
map
.transition()
.duration(500)
.delay(300)
.attr("fill", function(d) {
if(d.pps) {
return color(d.pps[d.pps.length-1].value);
} else { return "#ccc"; }
})
}
d3.select("#tooltip")
.transition()
.duration(300)
.style("opacity", 0.5)
;
});
map.on("click", function(d) {
if (d3.select('input[name="group-stack"]:checked').node().value=='eur' && d.eur) {
// ONLY UPDATE IF HAZ DATA
d3.select("#tooltip")
.transition()
.duration(300)
.style("opacity", 1);
title.text(d.properties.name);
bar.data(d.eur)
.transition()
.duration(500)
.delay(function(d, i) { return i*100; })
.attr("y", function(d) { return yScale(d.value); })
.attr("x", function(d, i) { return xScale(i); })
.attr("height", function(d) { return (bh-bp.b)-yScale(d.value); });
} else if (d3.select('input[name="group-stack"]:checked').node().value=='pps' && d.pps) {
d3.select("#tooltip")
.transition()
.duration(300)
.style("opacity", 1);
title.text(d.properties.name);
bar.data(d.pps)
.transition()
.duration(500)
.delay(function(d, i) { return i*100; })
.attr("y", function(d) { return yScale(d.value); })
.attr("x", function(d, i) { return xScale(i); })
.attr("height", function(d) { return (bh-bp.b)-yScale(d.value); });
}
});
});
});
</script>
</body>
</html>
/*
JSON-stat Javascript Toolkit v. 0.8.3
http://json-stat.org
https://github.com/badosa/JSON-stat
Copyright 2015 Xavier Badosa (http://xavierbadosa.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
or implied. See the License for the specific language governing
permissions and limitations under the License.
*/
function JSONstat(t,e){return window===this?new JSONstat.jsonstat(t,e):void 0}var JSONstat=JSONstat||{}
JSONstat.version="0.8.3",function(){"use strict"
function t(t){return"[object Array]"===Object.prototype.toString.call(t)}function e(e,n){var i,s,r,l,a=function(t,e){var n,i,s=e!==!1
if(window.XDomainRequest&&/^(http(s)?:)?\/\//.test(t)){if(!s)return
i=new XDomainRequest,i.onload=function(){n=JSON.parse(i.responseText),e.call(JSONstat(n))},i.open("GET",t),i.send()}else if(i=new XMLHttpRequest,i.onreadystatechange=function(){if(4===i.readyState){var t=i.status
n=t&&i.responseText&&(t>=200&&300>t||304===t)?JSON.parse(i.responseText):null,s&&e.call(JSONstat(n))}},i.open("GET",t,s),i.send(null),!s)return n},o=function(e,n){var i,s=[]
if("string"==typeof e&&(e=[e]),t(e)){if(e.length===n)return e
if(1===e.length){for(i=0;n>i;i++)s.push(e[0])
return s}}for(i=0;n>i;i++){var r=void 0===e[i]?null:e[i]
s.push(r)}return s}
if(this.length=0,this.id=[],null!==e&&void 0!==e)switch(this["class"]=e["class"]||"bundle",this["class"]){case"bundle":var u=[],h=0
if(this.error=null,this.length=0,"string"==typeof e&&e.length>0&&(e=a(e,"function"==typeof n?n:!1)),null===e||"object"!=typeof e)return this["class"]=null,void(void 0===e&&(delete this.id,delete this["class"],delete this.error,delete this.length))
if(e.hasOwnProperty("error"))return void(this.error=e.error)
if("dataset"===e["class"]||"collection"===e["class"])return JSONstat(e)
for(s in e)h++,u.push(s)
this.__tree__=e,this.length=h,this.id=u
break
case"dataset":e.hasOwnProperty("__tree__")||(delete e["class"],e={__tree__:e}),this.__tree__=i=e.__tree__,this.label=i.label||null,this.note=i.note||null,this.link=i.link||null,this.href=i.href||null,this.updated=i.updated||null,this.source=i.source||null,this.extension=i.extension||null
var f,c=0
if(i.hasOwnProperty("value")&&t(i.value))c=i.value.length
else if(i.hasOwnProperty("status")&&t(i.status))c=i.status.length
else if(i.hasOwnProperty("dimension")){var d=i.dimension.size,p=1
for(f=d.length;f--;)p*=d[f]
c=p}if(this.value=o(i.value,c),this.status=i.hasOwnProperty("status")?o(i.status,c):null,i.hasOwnProperty("dimension")){if(!t(i.dimension.id)||!t(i.dimension.size)||i.dimension.id.length!=i.dimension.size.length)return
var v=i.dimension,g=v.role||null,y=v.id,_=v.size.length,b=function(t){g.hasOwnProperty(t)||(g[t]=null)}
if(this.length=_,this.id=y,g&&(b("time"),b("geo"),b("metric"),b("classification")),g&&null===g.classification){var m=[],w=["time","geo","metric"],O=function(t,e){for(var n=e.length;n--;)if(t===e[n])return!0
return!1}
for(f=0;3>f;f++){var x=g[w[f]]
null!==x&&(m=m.concat(x))}for(g.classification=[],f=0;_>f;f++)O(y[f],m)||g.classification.push(y[f])
0===g.classification.length&&(g.classification=null)}this.role=g,this.n=c
for(var S=0,k=this.length;k>S;S++)if(v[v.id[S]].category.hasOwnProperty("index")){if(t(v[v.id[S]].category.index)){var P={},D=v[v.id[S]].category.index
for(r=D.length,l=0;r>l;l++)P[D[l]]=l
v[v.id[S]].category.index=P}}else{var j=0
v[v.id[S]].category.index={}
for(s in v[v.id[S]].category.label)v[v.id[S]].category.index[s]=j++}}else this.length=0
break
case"dimension":i=e.__tree__
var J=[],N=i.category
if(!e.hasOwnProperty("__tree__")||!i.hasOwnProperty("category"))return
if(!N.hasOwnProperty("label")){N.label={}
for(s in N.index)N.label[s]=s}for(s in N.index)J[N.index[s]]=s
this.__tree__=i,this.label=i.label||null,this.note=i.note||null,this.link=i.link||null,this.href=i.href||null,this.id=J,this.length=J.length,this.role=e.role,this.hierarchy=N.hasOwnProperty("child"),this.extension=i.extension||null
break
case"category":var T=e.child
this.id=T,this.length=null===T?0:T.length,this.index=e.index,this.label=e.label,this.note=e.note||null,this.unit=e.unit,this.coordinates=e.coord
break
case"collection":if(this.length=0,this.label=e.label||null,this.note=e.note||null,this.link=e.link||null,this.href=e.href||null,this.updated=e.updated||null,this.source=e.source||null,this.extension=e.extension||null,null!==this.link&&e.link.item){var z=e.link.item
if(this.length=t(z)?z.length:0,this.length)for(l=0;l<this.length;l++)this.id[l]=z[l].href}}}e.prototype.Item=function(t){if(null===this||"collection"!==this["class"]||!this.length)return null
if("number"==typeof t)return t>this.length||0>t?null:this.link.item[t]
var e,n=[]
if("object"==typeof t){if(!t["class"]&&!t.follow)return null
t["class"]?e=function(t,e,i){i["class"]===t.link.item[e]["class"]&&n.push(t.link.item[e])}:t.follow&&(e=function(t,e){n.push(JSONstat(t.id[e]))})}else e=function(t,e){n.push(t.link.item[e])}
for(var i=0;i<this.length;i++)e(this,i,t)
return n},e.prototype.Dataset=function(t){if(null===this)return null
if("dataset"===this["class"])return void 0!==t?this:[this]
if("bundle"!==this["class"])return null
if(void 0===t){for(var n=[],i=0,s=this.id.length;s>i;i++)n.push(this.Dataset(this.id[i]))
return n}if("number"==typeof t){var r=this.id[t]
return void 0!==r?this.Dataset(r):null}var l=this.__tree__[t]
return void 0===l?null:new e({"class":"dataset",__tree__:l})},e.prototype.Dimension=function(t){var n,i=[],s=this.id.length,r=function(t,e){var n=t.role
if(null!==n)for(var i in n)for(var s=null!==n[i]?n[i].length:0;s--;)if(n[i][s]===e)return i
return null}
if(null===this||"dataset"!==this["class"])return null
if(void 0===t){for(n=0;s>n;n++)i.push(this.Dimension(this.id[n]))
return i}if("number"==typeof t){var l=this.id[t]
return void 0!==l?this.Dimension(l):null}var a=this.__tree__.dimension
if(void 0===a)return null
if("object"==typeof t){if(t.hasOwnProperty("role")){for(n=0;s>n;n++){var o=this.id[n]
r(a,o)===t.role&&i.push(this.Dimension(o))}return void 0===i[0]?null:i}return null}var u=a[t]
return void 0===u?null:new e({"class":"dimension",__tree__:u,role:r(a,t)})},e.prototype.Category=function(t){if(null===this||"dimension"!==this["class"])return null
if(void 0===t){for(var n=[],i=0,s=this.id.length;s>i;i++)n.push(this.Category(this.id[i]))
return n}if("number"==typeof t){var r=this.id[t]
return void 0!==r?this.Category(r):null}var l=this.__tree__.category
if(void 0===l)return null
var a=l.index[t]
if(void 0===a)return null
var o=l.unit&&l.unit[t]||null,u=l.coordinates&&l.coordinates[t]||null,h=l.child&&l.child[t]||null,f=l.note&&l.note[t]||null
return new e({"class":"category",index:a,label:l.label[t],note:f,child:h,unit:o,coord:u})},e.prototype.Data=function(e){var n,i,s=[],r=function(t){for(var e in t)if(t.hasOwnProperty(e))return e},l=function(t,e){for(var n=[],i=t.dimension,s=i.id,l=0,a=s.length;a>l;l++){var o=s[l],u=e[o]
n.push("string"==typeof u?u:1===i.size[l]?r(i[o].category.index):null)}return n}
if(null===this||"dataset"!==this["class"])return null
if(void 0===e){for(i=this.value.length,n=0;i>n;n++)s.push(this.Data(n))
return s}if("number"==typeof e){var a=this.value[e]
return void 0!==a?{value:a,status:this.status?this.status[e]:null}:null}var o=this.__tree__,u=o.dimension.size,h=u.length
if(t(e)){if(this.length!==e.length)return null
var f=1,c=0,d=[],p=[]
for(n=0;h>n;n++)if(void 0!==e[n]){if("number"!=typeof e[n]||e[n]>=u[n])return null
f*=n>0?u[h-n]:1,c+=f*e[h-n-1]}else d.push(n),p.push(u[n])
if(d.length>1)return null
if(1===d.length){for(var v=0,g=p[0];g>v;v++){var y=[]
for(n=0;h>n;n++)y.push(n!==d[0]?e[n]:v)
s.push(this.Data(y))}return s}return{value:this.value[c],status:this.status?this.status[c]:null}}var _=l(o,e),b=[],m=o.dimension
for(i=_.length,n=0;i>n;n++)b.push(m[m.id[n]].category.index[_[n]])
return this.Data(b)},e.prototype.toTable=function(t,e){if(null===this||"dataset"!==this["class"])return null
1==arguments.length&&"function"==typeof t&&(e=t,t=null)
var n,i,s,r,l,a=this.__tree__
if(t=t||{field:"label",content:"label",vlabel:"Value",slabel:"Status",type:"array",status:!1},"function"==typeof e){n=this.toTable(t)
var o=[],u="array"!==t.type?0:1,h="object"!==t.type?n.slice(u):n.rows.slice(0)
for(l=h.length,i=0;l>i;i++){var f=e.call(this,h[i],i)
void 0!==f&&o.push(f)}return"object"===t.type?{cols:n.cols,rows:o}:("array"===t.type&&o.unshift(n[0]),o)}if("arrobj"===t.type){n=this.toTable({field:"id",content:t.content,status:t.status})
var c=[],d=n.shift()
for(l=n.length,i=0;l>i;i++){var p={}
for(s=n[i].length;s--;)p[d[s]]=n[i][s]
c.push(p)}return c}var v,g,y,_,b="id"===t.field
if("object"===t.type){var m="number"==typeof this.value[0]||null===this.value[0]?"number":"string"
v=function(t,e){var n=b&&t||e||t
z.push({id:t,label:n,type:"string"})},g=function(t,e,n){var i=b&&"value"||t||"Value",s=b&&"status"||e||"Status"
n&&z.push({id:"status",label:s,type:"string"}),z.push({id:"value",label:i,type:m})},y=function(t){B.push({v:t})},_=function(t){B.push({v:t}),V.push({c:B})}}else v=function(t,e){var n=b&&t||e||t
z.push(n)},g=function(t,e,n){var i=b&&"value"||t||"Value",s=b&&"status"||e||"Status"
n&&z.push(s),z.push(i),T.push(z)},y=function(t){B.push(t)},_=function(t){B.push(t),T.push(B)}
var w=a.dimension,O=w.id,x=O.length,S=w.size
if(x!=S.length)return!1
var k=[],P=1,D=1,j=[],J=[],N=[],T=[],z=[],V=[]
for(i=0;x>i;i++){var q=O[i],C=w[q].label
v(q,C),P*=S[i],D*=S[i]
var R=[]
for(s=0;s<S[i];s++)for(var X in w[O[i]].category.index)if(w[O[i]].category.index[X]===s){var E="id"!==t.content&&w[O[i]].category.label?w[O[i]].category.label[X]:X
R.push(E)}k.push(R),j.push(D)}for(g(t.vlabel,t.slabel,t.status),l=k.length,i=0;l>i;i++){for(var G=[],A=0,H=k[i].length;H>A;A++)for(var I=0;I<P/j[i];I++)G.push(k[i][A])
J.push(G)}for(l=J.length,i=0;l>i;i++){var L=[],M=0
for(r=0;P>r;r++)L.push(J[i][M]),M++,M===J[i].length&&(M=0)
N.push(L)}for(r=0;P>r;r++){var B=[]
l=J.length
for(var F=0;l>F;F++)y(N[F][r])
t.status&&y(this.status?this.status[r]:null),_(this.value[r])}return"object"===t.type?{cols:z,rows:V}:T},e.prototype.node=function(){return this.__tree__},e.prototype.toString=function(){return this["class"]},e.prototype.toValue=function(){return this.length},JSONstat.jsonstat=e}()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment