Spaces:
Running
Running
File size: 2,348 Bytes
5cc9296 f58c9c5 5cc9296 f58c9c5 5cc9296 |
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 |
from matplotlib.cm import get_cmap
import plotly.graph_objects as go
class NQDOverview(object):
def __init__(self, parent, results,
dial_cmap='RdYlGn'):
self.p = parent
self.results = results
self.cmap = get_cmap(dial_cmap)
def _get_color(self):
color = self.cmap(self.results['qual']['label'] / 6.0)
color = f'rgba({int(color[0]*256)}, {int(color[1]*256)}, {int(color[2]*256)}, {int(color[3]*256)})'
return color
def _build_figure(self):
color = self._get_color()
fig = go.Figure(go.Indicator(
domain = {'x': [0, 1], 'y': [0, 1]},
value = self.results['qual']['label'],
mode = "gauge+number",
title = {'text': "QuAL"},
gauge = {'axis': {'range': [None, 5], 'showticklabels': True, 'ticks': ""},
'bgcolor': 'lightgray',
'bar': {'color': color, 'thickness': 1.0}
}
),
layout=go.Layout(margin=dict(t=0, b=135))
)
return fig
def draw(self):
st = self.p
fig = self._build_figure()
cols = st.columns([7, 3])
with cols[0]:
st.plotly_chart(fig, use_container_width=True)
with cols[1]:
q1lab = self.results['q1']['label']
if q1lab == 0:
md_str = 'π₯ None'
elif q1lab == 1:
md_str = 'π Low'
elif q1lab == 2:
md_str = 'π Medium'
elif q1lab == 3:
md_str = 'π High'
cols[1].metric('Level of Detail', md_str,
help='How specific was the evaluator in describing the behavior?')
q2lab = self.results['q2i']['label']
if q2lab == 0:
md_str = 'β
Yes'
else:
md_str = 'β No'
cols[1].metric('Suggestion Given', (md_str),
help='Did the evaluator give a suggestion for improvement?')
q3lab = self.results['q3i']['label']
if q3lab == 0:
md_str = 'β
Yes'
else:
md_str = 'β No'
cols[1].metric('Suggestion Linked', md_str,
help='Is the suggestion for improvement linked to the described behavior?') |