-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkey_author_matrix.js
109 lines (108 loc) · 2.99 KB
/
key_author_matrix.js
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
101
102
103
104
105
106
107
108
109
const spec = {
"$schema": "https://vega.github.io/schema/vega/v3.0.json",
"autosize": "pad",
"padding": 5,
"style": "cell",
"signals": [
{
"name": "currentTid", "value": ["t0","t1","t2","t3","t5","t6"],
"bind": {"name": "Topic groups:", "input": "radio", "options": [
["t0","t1","t2","t3","t5","t6"],
["t1_s0","t1_s2","t1_s5","t1_s6"],
["t5_s2","t5_s3","t5_s5"]
]}
},
{"name": "x_step", "value": 12},
{
"name": "width",
"update": "bandspace(domain('x').length, 0.1, 0.05) * x_step"
},
{"name": "y_step", "value": 15},
{
"name": "height",
"update": "bandspace(domain('y').length, 0.1, 0.05) * y_step"
}
],
"data": [
{
"name": "source_in",
"url": "https://raw.githubusercontent.com/repmax/launchpad/master/key_author_matrix.csv",
"format": {
"type": "csv",
"parse": {"normal": "number"},
"delimiter": ","
},
"transform": [
{"type": "filter", "expr": "0 <= indexof(currentTid, datum.id_top)"},
{"type": "formula", "as": "log_normal", "expr": "log(datum.normal)"}
]
}
],
"marks": [
{
"name": "marks",
"type": "rect",
"style": ["rect"],
"from": {"data": "source_in"},
"encode": {
"update": {
"fill": {"scale": "color", "field": "log_normal"},
"x": {"scale": "x", "field": "keyword"},
"width": {"scale": "x", "band": true},
"y": {"scale": "y", "field": "topic"},
"height": {"scale": "y", "band": true}
}
}
}
],
"scales": [
{
"name": "x",
"type": "band",
"domain": {"data": "source_in", "field": "keyword", "sort": false},
"range": {"step": {"signal": "x_step"}},
"paddingInner": 0.1,
"paddingOuter": 0.05
},
{
"name": "y",
"type": "band",
"domain": {"data": "source_in", "field": "topic", "sort": false},
"range": {"step": {"signal": "y_step"}},
"paddingInner": 0.1,
"paddingOuter": 0.05
},
{
"name": "color",
"type": "sequential",
"domain": {"data": "source_in", "field": "log_normal"},
"range": "heatmap",
"nice": false,
"zero": false
}
],
"axes": [
{
"scale": "x",
"orient": "bottom",
"title": "keyword",
"labelOverlap": false,
"encode": {
"labels": {
"update": {
"angle": {"value": 310},
"align": {"value": "right"},
"baseline": {"value": "middle"}
}
}
},
"zindex": 1
},
{"scale": "y", "orient": "left", "title": "topic", "zindex": 1}
],
"legends": [{"orient": "right", "offset": 10, "fill": "color", "title": "frequency", "type": "gradient"}],
"config": {"axisY": {"minExtent": 30}}
}
draw = function () {
vegaEmbed('#vis', spec, {renderer: "svg"});
}