forked from yannikism/map-of-knowledge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmarkup.py
200 lines (180 loc) · 4.9 KB
/
markup.py
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
import dash
import dash_core_components as dcc
import dash_html_components as html
import dash_bootstrap_components as dbc
import dash_cytoscape as cyto
stylesheet = [
{
'selector': 'node',
'style': {
'background-color': '#BFD7B5',
'label': 'data(label)'
}
},
{
'selector': '[id = "0"]',
'style': {
'background-color': 'red',
'line-color': 'red'
}
},
{
'selector': 'edge',
'style': {
# The default curve style does not work with certain arrows
'curve-style': 'bezier'
}
},
{
'selector': 'edge',
'style': {
'target-arrow-color': 'lightblue',
'target-arrow-shape': 'vee',
'line-color': 'lightblue'
}
}
]
placeholder = "Enter your search here!"
controls = dbc.Card(
[
# search term
dbc.FormGroup(
[
dbc.Label("Search Term"),
dcc.Dropdown(id="search-dropdown", placeholder=placeholder, value='')
]
),
# depth
dbc.FormGroup(
[
dbc.Label("Depth "),
dbc.Input(id='depth', type='number', placeholder='Set a depth', value='2')
]
),
# max count
dbc.FormGroup(
[
dbc.Label("Number of Branches"),
dbc.Input(id='max-count', type='number', placeholder='Set an initial value', value='3')
]
),
# language
dbc.FormGroup(
[
dbc.Label("Language"),
dcc.Dropdown(
id='language-dropdown',
options=[
{'label': 'english',
'value': 'en'},
{'label': 'french',
'value': 'fr'},
{'label': 'german',
'value': 'de'}
], value='en', placeholder='Select a language'
),
]
),
# layout
dbc.FormGroup(
[
dbc.Label("Layout"),
dcc.Dropdown(
id='layout-dropdown',
options=[
#{'label': 'random',
# 'value': 'random'},
{'label': 'grid',
'value': 'grid'},
{'label': 'circle',
'value': 'circle'},
{'label': 'concentric',
'value': 'concentric'},
{'label': 'breadthfirst',
'value': 'breadthfirst'},
{'label': 'cose',
'value': 'cose'}
], value='cose',
),
]
),
# start button
dbc.FormGroup(
[
dbc.Button("Start", id="start-button", outline=True, color="primary", size="lg", className="mr-2", n_clicks=0),
dbc.Button("Increase Depth", id="add-depth", outline=True, color="primary", size="sm", className="mr-2", n_clicks=0)
]
),
],
body=True,
)
graph = dbc.Card(
dbc.FormGroup([
cyto.Cytoscape(
id='cytoscape',
elements=[],
style={
'height': '425px',
'width': '100%'},
stylesheet=stylesheet
),
html.P(id='status', children='status')
])
)
info_button = html.Div(
[
dbc.Button(
"Info",
id="info-button",
outline=True,
size="lg",
className="mb-3",
color="info",
n_clicks=0,
),
dbc.Collapse(
dbc.Card(dbc.CardBody("Enter a search Term and click 'Start'. Hovering over an article displays the summary down below. Clicking on an article starts a new search with the chosen article as your search term. The number of branches is the connections of each article")),
id="info-text",
is_open=False,
),
]
)
hover_text = dbc.Card(
dbc.FormGroup([
html.P(id="hover_text")
])
)
app = dash.Dash(external_stylesheets=[dbc.themes.BOOTSTRAP])
server = app.server
app.title='MoK'
app.layout = html.Div([
dbc.Container([
dbc.Row([
dbc.Col(html.H1("Map of Knowledge")),
dbc.Col(html.Div(info_button), align="end", width=4),
]),
dbc.Row([
dbc.Col(html.H5("Have fun with the progam!")),
]),
html.Hr(),
dbc.Row([
dbc.Col(controls, md=4),
dbc.Col(graph, md=8, align="top"),
],
),
dbc.Row([
dbc.Col(hover_text, md=12, align="center")
],
),
]),# fluid=True),
html.Div([
dcc.Interval(
id='interval-component',
interval=1*1000, # in milliseconds
n_intervals=0
)
]),
html.P(id='elli'),
html.P(id="ello"),
html.P(id="alli")
])