Spaces:
Sleeping
Sleeping
Update dashboard.py
Browse files- dashboard.py +26 -17
dashboard.py
CHANGED
@@ -85,24 +85,33 @@ def create_type_bar_charts(entRelsButton, **kwargs):
|
|
85 |
def create_type_pie_charts(entRelsButton, **kwargs):
|
86 |
if entRelsButton == 'Entity':
|
87 |
dictionary = entityTypesFreqMap
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
|
|
|
|
|
|
|
|
|
|
96 |
elif entRelsButton == 'Relation':
|
97 |
dictionary = relationTypesFreqMap
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
|
|
|
|
|
|
|
|
106 |
|
107 |
|
108 |
def create_ent_bar_charts(ents, **kwargs):
|
@@ -356,7 +365,7 @@ def CreatePage3():
|
|
356 |
return pn.Column(
|
357 |
pn.pane.Markdown("## Entity/Relation Types "),
|
358 |
entRelsButton,
|
359 |
-
pn.bind(
|
360 |
align="center",
|
361 |
)
|
362 |
|
|
|
85 |
def create_type_pie_charts(entRelsButton, **kwargs):
|
86 |
if entRelsButton == 'Entity':
|
87 |
dictionary = entityTypesFreqMap
|
88 |
+
data = pd.Series(dictionary).reset_index(name='Frequency').rename(columns={'index': 'Entity'})
|
89 |
+
data['angle'] = data['Frequency']/data['Frequency'].sum() * 2*pi
|
90 |
+
data['color'] = Category20c[len(x)]
|
91 |
+
p = figure(height=350, title="Pie Chart", toolbar_location=None,
|
92 |
+
tools="hover", tooltips="@Entity: @Frequency", x_range=(-0.5, 1.0))
|
93 |
+
p.wedge(x=0, y=1, radius=0.4,start_angle=cumsum('angle', include_zero=True), end_angle=cumsum('angle'),
|
94 |
+
line_color="white", fill_color='color', legend_field='Entity', source=data)
|
95 |
+
p.axis.axis_label = None
|
96 |
+
p.axis.visible = False
|
97 |
+
p.grid.grid_line_color = None
|
98 |
+
|
99 |
+
return p
|
100 |
+
|
101 |
elif entRelsButton == 'Relation':
|
102 |
dictionary = relationTypesFreqMap
|
103 |
+
data = pd.Series(dictionary).reset_index(name='Frequency').rename(columns={'index': 'Relation'})
|
104 |
+
data['angle'] = data['Frequency']/data['Frequency'].sum() * 2*pi
|
105 |
+
data['color'] = Category20c[len(x)]
|
106 |
+
p = figure(height=350, title="Pie Chart", toolbar_location=None,
|
107 |
+
tools="hover", tooltips="@Entity: @Frequency", x_range=(-0.5, 1.0))
|
108 |
+
p.wedge(x=0, y=1, radius=0.4,start_angle=cumsum('angle', include_zero=True), end_angle=cumsum('angle'),
|
109 |
+
line_color="white", fill_color='color', legend_field='Relation', source=data)
|
110 |
+
p.axis.axis_label = None
|
111 |
+
p.axis.visible = False
|
112 |
+
p.grid.grid_line_color = None
|
113 |
+
|
114 |
+
return p
|
115 |
|
116 |
|
117 |
def create_ent_bar_charts(ents, **kwargs):
|
|
|
365 |
return pn.Column(
|
366 |
pn.pane.Markdown("## Entity/Relation Types "),
|
367 |
entRelsButton,
|
368 |
+
pn.bind(create_type_pie_charts, entRelsButton),
|
369 |
align="center",
|
370 |
)
|
371 |
|