emsesc commited on
Commit
77e9502
·
1 Parent(s): 7007406

add formatting and fix bug

Browse files
app.py CHANGED
@@ -119,32 +119,80 @@ slider2.update_layout(font_family="Inter")
119
  # App layout
120
  app.layout = html.Div(
121
  [
122
- html.Div(children='Visualizing the Open Model Ecosystem', style={'fontSize': 28, 'fontWeight': 'bold', 'marginBottom': 10}),
123
- html.Div(children='An interactive dashboard to explore trends in open models on Hugging Face', style={'fontSize': 16, 'marginBottom': 20}),
124
- html.Hr(),
125
- dcc.Tabs([
126
- dcc.Tab(label='Model Market Share', children=[
127
- html.Div([
128
- dcc.Graph(id='stacked-area-chart'),
129
- dcc.Graph(figure=slider, id='time-slider-stacked'),
130
- ]),
131
- html.Div([
132
- dcc.Graph(id='world-map-with-slider'),
133
- dcc.Graph(id='leaderboard'),
134
- dcc.Graph(figure=slider2, id='time-slider'),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
  ])
136
- ]),
137
- dcc.Tab(label='Model Characteristics', children=[
138
- dcc.Graph(id='language-concentration-chart'),
139
- html.Div([
140
- dcc.Dropdown(['Language Concentration', 'Architecture', 'License', 'Method'], 'Language Concentration', id='dropdown'),
141
- ]),
142
- ]),
143
- ])
 
 
144
  ],
145
- style={'fontFamily': 'Inter'}
146
  )
147
 
 
 
 
 
 
 
 
 
 
 
 
 
148
  # On dropdown change, update graph
149
  @app.callback(
150
  Output('language-concentration-chart', 'figure'),
@@ -175,7 +223,7 @@ def update_map(relayout_data):
175
  return updated_fig
176
  else:
177
  return fig6
178
-
179
  @app.callback(
180
  Output('leaderboard', 'figure'),
181
  [Input('time-slider', 'relayoutData')]
@@ -194,7 +242,7 @@ def update_leaderboard(relayout_data):
194
 
195
  @app.callback(
196
  Output('stacked-area-chart', 'figure'),
197
- [Input('time-slider-stacked', 'relayoutData')]
198
  )
199
  def update_stacked_area(relayout_data):
200
  if relayout_data and 'xaxis.range[0]' in relayout_data and 'xaxis.range[1]' in relayout_data:
 
119
  # App layout
120
  app.layout = html.Div(
121
  [
122
+ html.Div(
123
+ [
124
+ html.Div(children='Visualizing the Open Model Ecosystem', style={'fontSize': 28, 'fontWeight': 'bold', 'marginBottom': 6}),
125
+ html.Div(children='An interactive dashboard to explore trends in open models on Hugging Face', style={'fontSize': 16, 'marginBottom': 12}),
126
+ html.Hr(style={'marginTop': 8, 'marginBottom': 8}),
127
+ ],
128
+ style={'textAlign': 'center'}
129
+ ),
130
+ html.Div(
131
+ [
132
+ dcc.Tabs([
133
+ dcc.Tab(label='Model Market Share', children=[
134
+ html.Div([
135
+ html.Div(children='Select time range to update all graphs below:', style={'fontSize': 16, 'marginBottom': 6, 'marginTop': 10}),
136
+ dcc.Graph(figure=slider2, id='time-slider', style={'height': '100px'}),
137
+ html.Div(
138
+ id='output-container-range-slider',
139
+ style={
140
+ 'textAlign': 'center',
141
+ 'fontSize': 20,
142
+ 'marginBottom': 15,
143
+ 'marginTop': 30,
144
+ 'backgroundColor': 'white',
145
+ 'borderRadius': '12px',
146
+ 'boxShadow': '0 2px 12px rgba(0,0,0,0.10)',
147
+ 'padding': '18px',
148
+ 'display': 'inline-block',
149
+ }
150
+ ),
151
+ ], style={'marginBottom': 12, 'justifyContent': 'center', 'textAlign': 'center'}),
152
+ html.Div([
153
+ dcc.Graph(id='stacked-area-chart'),
154
+ ], style={'marginBottom': 12}),
155
+ html.Div([
156
+ html.Div(
157
+ dcc.Graph(id='world-map-with-slider'),
158
+ style={'display': 'flex', 'justifyContent': 'center'}
159
+ ),
160
+ dcc.Graph(id='leaderboard'),
161
+ ], style={'marginBottom': 12})
162
+ ]),
163
+ dcc.Tab(label='Model Characteristics', children=[
164
+ dcc.Graph(id='language-concentration-chart'),
165
+ html.Div([
166
+ dcc.Dropdown(['Language Concentration', 'Architecture', 'License', 'Method'], 'Language Concentration', id='dropdown'),
167
+ ], style={'marginTop': 6}),
168
+ ]),
169
  ])
170
+ ],
171
+ style={
172
+ 'backgroundColor': 'white',
173
+ 'borderRadius': '18px',
174
+ 'boxShadow': '0 4px 24px rgba(0,0,0,0.10)',
175
+ 'padding': '32px',
176
+ 'margin': '32px auto',
177
+ 'maxWidth': '1250px',
178
+ }
179
+ )
180
  ],
181
+ style={'fontFamily': 'Inter', 'backgroundColor': '#f7f7fa', 'minHeight': '100vh'}
182
  )
183
 
184
+ @app.callback(
185
+ Output('output-container-range-slider', 'children'),
186
+ [Input('time-slider', 'relayoutData')]
187
+ )
188
+ def update_output(relayout_data):
189
+ if relayout_data and 'xaxis.range[0]' in relayout_data and 'xaxis.range[1]' in relayout_data:
190
+ start_time = pd.to_datetime(relayout_data['xaxis.range[0]']).strftime('%Y-%m-%d')
191
+ end_time = pd.to_datetime(relayout_data['xaxis.range[1]']).strftime('%Y-%m-%d')
192
+ return f'Selected time range: {start_time} to {end_time}'
193
+ else:
194
+ return 'Selected time range: All data'
195
+
196
  # On dropdown change, update graph
197
  @app.callback(
198
  Output('language-concentration-chart', 'figure'),
 
223
  return updated_fig
224
  else:
225
  return fig6
226
+
227
  @app.callback(
228
  Output('leaderboard', 'figure'),
229
  [Input('time-slider', 'relayoutData')]
 
242
 
243
  @app.callback(
244
  Output('stacked-area-chart', 'figure'),
245
+ [Input('time-slider', 'relayoutData')]
246
  )
247
  def update_stacked_area(relayout_data):
248
  if relayout_data and 'xaxis.range[0]' in relayout_data and 'xaxis.range[1]' in relayout_data:
graphs/__pycache__/model_market_share.cpython-39.pyc CHANGED
Binary files a/graphs/__pycache__/model_market_share.cpython-39.pyc and b/graphs/__pycache__/model_market_share.cpython-39.pyc differ
 
graphs/model_market_share.py CHANGED
@@ -364,7 +364,7 @@ def create_plotly_world_map(
364
  # Update layout
365
  fig.update_layout(
366
  title=dict(
367
- text=f"Model Downloads by Country - Time Range Analysis<br><sub>Select time range below to update map</sub>",
368
  x=0.5,
369
  font=dict(size=20, family="Inter, system-ui, sans-serif", color="#212529"),
370
  ),
@@ -388,6 +388,11 @@ def create_plotly_world_map(
388
  bgcolor="#ffffff",
389
  )
390
 
 
 
 
 
 
391
  return fig
392
 
393
  def create_plotly_range_slider(df):
@@ -557,7 +562,7 @@ def create_leaderboard(country_df, developer_df, model_df, start_time=None, end_
557
  fig.update_layout(
558
  height=400,
559
  showlegend=False,
560
- title_text=f"Leaderboards ({start_time} → {end_time})"
561
  )
562
 
563
  return fig
 
364
  # Update layout
365
  fig.update_layout(
366
  title=dict(
367
+ text="Model Downloads by Country",
368
  x=0.5,
369
  font=dict(size=20, family="Inter, system-ui, sans-serif", color="#212529"),
370
  ),
 
388
  bgcolor="#ffffff",
389
  )
390
 
391
+ # Remove excessive whitespace below the map by adjusting subplot row heights and margins
392
+ fig.update_layout(
393
+ margin=dict(l=0, r=120, t=100, b=20), # Reduce bottom margin
394
+ height=600, # Reduce overall figure height
395
+ )
396
  return fig
397
 
398
  def create_plotly_range_slider(df):
 
562
  fig.update_layout(
563
  height=400,
564
  showlegend=False,
565
+ title_text="Leaderboards"
566
  )
567
 
568
  return fig