dvilasuero HF staff commited on
Commit
05f090f
1 Parent(s): b6f8835

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -51
app.py CHANGED
@@ -63,56 +63,6 @@ def get_user_annotations_dictionary(
63
  return output
64
 
65
 
66
- def gauge_chart() -> alt.Chart:
67
- # Assuming obtain_source_target_datasets() returns a tuple where the first item is the dataset
68
- source_dataset, _ = obtain_source_target_datasets()
69
- total_records = int(os.getenv("TARGET_RECORDS")) # This should be the total number of records you want to annotate.
70
- annotated_records = len(source_dataset) # This is the number of records already annotated.
71
- pending_records = total_records - annotated_records # Calculate the pending records.
72
-
73
- # Prepare data for the gauge chart
74
- gauge_data = pd.DataFrame({
75
- 'category': ['Annotated', 'Remaining'],
76
- 'value': [annotated_records, pending_records]
77
- })
78
-
79
- # The background of the gauge
80
- base = alt.Chart(pd.DataFrame({'value': [total_records], 'category': ['Total']})).mark_bar(
81
- color='#e0e0e0', size=40
82
- ).encode(
83
- alt.X('value:Q', scale=alt.Scale(domain=[0, total_records]), title='Record Count'),
84
- alt.Y('category:N', axis=alt.Axis(title=''))
85
- )
86
-
87
- # The value part of the gauge
88
- value_bar = alt.Chart(gauge_data).mark_bar(size=40).encode(
89
- alt.X('value:Q'),
90
- alt.Y('category:N', axis=alt.Axis(title='')),
91
- alt.Color('category:N', scale=alt.Scale(domain=['Annotated', 'Remaining'], range=['#28a745', '#dcdcdc']))
92
- )
93
-
94
- # Combine the bars to create a gauge effect
95
- chart = alt.layer(base, value_bar).properties(
96
- title='Progress Towards Goal',
97
- width=700,
98
- height=100
99
- )
100
-
101
- # Add a text label for the current value
102
- text = alt.Chart(pd.DataFrame({'value': [annotated_records + pending_records/2], 'text': [f'{annotated_records} / {total_records}']})).mark_text(
103
- align='center', baseline='middle', fontSize=16, fontWeight='bold', dy=-30
104
- ).encode(
105
- x='value:Q',
106
- text='text:N'
107
- )
108
-
109
- return (chart + text)
110
-
111
-
112
- import altair as alt
113
- import pandas as pd
114
- import os
115
-
116
 
117
  def donut_chart() -> alt.Chart:
118
  """
@@ -227,7 +177,7 @@ def main() -> None:
227
  )
228
  plot = gr.Plot(label="Plot")
229
  demo.load(
230
- gauge_chart,
231
  inputs=[],
232
  outputs=[plot],
233
  )
 
63
  return output
64
 
65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
 
67
  def donut_chart() -> alt.Chart:
68
  """
 
177
  )
178
  plot = gr.Plot(label="Plot")
179
  demo.load(
180
+ donut_chart,
181
  inputs=[],
182
  outputs=[plot],
183
  )