Spaces:
Sleeping
Sleeping
Update dashboard.py
Browse files- dashboard.py +7 -4
dashboard.py
CHANGED
@@ -87,12 +87,17 @@ def create_ent_bar_charts(ents, **kwargs):
|
|
87 |
# Create button widgets for each label
|
88 |
drug_buttons = []
|
89 |
condition_buttons = []
|
90 |
-
|
|
|
|
|
|
|
|
|
|
|
91 |
button = pn.widgets.Button(name=drg, width=150)
|
92 |
## Open the associated URL in a new tab when button is clicked
|
93 |
button.js_on_click(code=f'window.open("https://api-vast.jrc.service.ec.europa.eu/describe/?url=http://causaldrugskg.org/causaldrugskg/resource/{drg}", "_blank");')
|
94 |
drug_buttons.append(button)
|
95 |
-
for i, cnd in enumerate(list(
|
96 |
button = pn.widgets.Button(name=cnd, width=150)
|
97 |
## Open the associated URL in a new tab when button is clicked
|
98 |
button.js_on_click(
|
@@ -106,14 +111,12 @@ def create_ent_bar_charts(ents, **kwargs):
|
|
106 |
|
107 |
if ents=='Drug':
|
108 |
dictionary = topDrugEntities
|
109 |
-
sorted_drugs = sorted(dictionary.items(), key=lambda x: x[1], reverse=True)
|
110 |
bars = hv.Bars(sorted_drugs, hv.Dimension('Drug Entities'), 'Frequency').opts(framewise=True, xrotation=45,width=1200, height=600, fontsize={'xticks': 18, 'xlabel':18, 'ylabel':16})
|
111 |
# Combine everything into a Panel layout
|
112 |
layout = pn.Row(bars, drug_button_column)
|
113 |
return layout
|
114 |
elif ents=='Condition':
|
115 |
dictionary = topConditionEntities
|
116 |
-
sorted_conditions = sorted(dictionary.items(), key=lambda x: x[1], reverse=True)
|
117 |
bars = hv.Bars(sorted_conditions, hv.Dimension('Condition Entities'), 'Frequency').opts(framewise=True, xrotation=45,width=1200, height=600, fontsize={'xticks': 18, 'xlabel':18, 'ylabel':16})
|
118 |
layout = pn.Row(bars, condition_button_column)
|
119 |
return layout
|
|
|
87 |
# Create button widgets for each label
|
88 |
drug_buttons = []
|
89 |
condition_buttons = []
|
90 |
+
|
91 |
+
sorted_drugs = sorted(dictionary.items(), key=lambda x: x[1], reverse=True)
|
92 |
+
sorted_conditions = sorted(dictionary.items(), key=lambda x: x[1], reverse=True)
|
93 |
+
|
94 |
+
for i, drg in enumerate(list(sorted_drugs.keys())):
|
95 |
+
|
96 |
button = pn.widgets.Button(name=drg, width=150)
|
97 |
## Open the associated URL in a new tab when button is clicked
|
98 |
button.js_on_click(code=f'window.open("https://api-vast.jrc.service.ec.europa.eu/describe/?url=http://causaldrugskg.org/causaldrugskg/resource/{drg}", "_blank");')
|
99 |
drug_buttons.append(button)
|
100 |
+
for i, cnd in enumerate(list(sorted_conditions.keys())):
|
101 |
button = pn.widgets.Button(name=cnd, width=150)
|
102 |
## Open the associated URL in a new tab when button is clicked
|
103 |
button.js_on_click(
|
|
|
111 |
|
112 |
if ents=='Drug':
|
113 |
dictionary = topDrugEntities
|
|
|
114 |
bars = hv.Bars(sorted_drugs, hv.Dimension('Drug Entities'), 'Frequency').opts(framewise=True, xrotation=45,width=1200, height=600, fontsize={'xticks': 18, 'xlabel':18, 'ylabel':16})
|
115 |
# Combine everything into a Panel layout
|
116 |
layout = pn.Row(bars, drug_button_column)
|
117 |
return layout
|
118 |
elif ents=='Condition':
|
119 |
dictionary = topConditionEntities
|
|
|
120 |
bars = hv.Bars(sorted_conditions, hv.Dimension('Condition Entities'), 'Frequency').opts(framewise=True, xrotation=45,width=1200, height=600, fontsize={'xticks': 18, 'xlabel':18, 'ylabel':16})
|
121 |
layout = pn.Row(bars, condition_button_column)
|
122 |
return layout
|