zavavan commited on
Commit
5274a68
·
verified ·
1 Parent(s): dfd12fd

Update dashboard.py

Browse files
Files changed (1) hide show
  1. 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
- return hv.Pie(dictionary, kdims='Entity Types', vdims='Frequency').opts(
89
- cmap='Category20',
90
- labels='Frequency',
91
- legend_position='right',
92
- width=600,
93
- height=600,
94
- fontsize={'labels': 12, 'legend': 10}
95
- )
 
 
 
 
 
96
  elif entRelsButton == 'Relation':
97
  dictionary = relationTypesFreqMap
98
- return hv.Pie(dictionary, kdims='Relation Types', vdims='Frequency').opts(
99
- cmap='Category20',
100
- labels='Frequency',
101
- legend_position='right',
102
- width=600,
103
- height=600,
104
- fontsize={'labels': 12, 'legend': 10}
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(create_type_bar_charts, entRelsButton),
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