zavavan commited on
Commit
c2ffdce
·
verified ·
1 Parent(s): 38199ab

Update dashboard.py

Browse files
Files changed (1) hide show
  1. dashboard.py +24 -1
dashboard.py CHANGED
@@ -83,7 +83,30 @@ def create_ent_bar_charts(ents, **kwargs):
83
  def create_ontology_bar_charts(ents, **kwargs):
84
  if ents=='Drug':
85
  dictionary = topDrugOnts
86
- return hv.Bars(dictionary, hv.Dimension('Drug Ontologies'), 'Frequency').opts( framewise=True, xrotation=45,width=1200, height=600)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  elif ents=='Condition':
88
  dictionary = topConditionOnts
89
  return hv.Bars(dictionary, hv.Dimension('Condition Ontologies'), 'Frequency').opts(framewise=True, xrotation=45,width=1200, height=600)
 
83
  def create_ontology_bar_charts(ents, **kwargs):
84
  if ents=='Drug':
85
  dictionary = topDrugOnts
86
+ df = pd.DataFrame({
87
+ 'full_key': list(dictionary.keys()),
88
+ 'Drug Ontologies': [k.split('/')[-1] for k in dictionary.keys()],
89
+ 'Frequency': list(dictionary.values()),
90
+ 'url': list(dictionary.keys()) # using full keys as hyperlinks
91
+ })
92
+ # Create bar chart with label as x-axis
93
+ bars = hv.Bars(df, kdims=['Drug Ontologies'], vdims=['frequency'])
94
+ bars = bars.opts(
95
+ framewise=True,
96
+ tools=['hover'],
97
+ width=1200,
98
+ height=600,
99
+ show_legend=False,
100
+ xrotation=45,
101
+ xlabel='Label',
102
+ ylabel='Frequency',
103
+ tooltips=[
104
+ ("Label", "@label"),
105
+ ("Frequency", "@frequency"),
106
+ ("Link", "@url")
107
+ ]
108
+ )
109
+ return bars
110
  elif ents=='Condition':
111
  dictionary = topConditionOnts
112
  return hv.Bars(dictionary, hv.Dimension('Condition Ontologies'), 'Frequency').opts(framewise=True, xrotation=45,width=1200, height=600)