cjc0013 commited on
Commit
e7a04a6
·
verified ·
1 Parent(s): c188bdf

Improve Space typography readability

Browse files
Files changed (2) hide show
  1. app.py +125 -14
  2. space_bundle_manifest.json +3 -3
app.py CHANGED
@@ -16,6 +16,32 @@ DATASET = DATA / "dataset_bundle"
16
  MANIFEST = json.loads((DATA / "public_release_manifest.json").read_text(encoding="utf-8"))
17
  CLAIM_BOUNDARY = json.loads((AUDIT / "claim_boundary.json").read_text(encoding="utf-8"))
18
  SOURCE_GAPS = json.loads((AUDIT / "source_gap_report.json").read_text(encoding="utf-8"))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
 
21
  def read_jsonl_gz(name: str, limit: int | None = None) -> pd.DataFrame:
@@ -103,7 +129,7 @@ def return_chart():
103
  margin=dict(l=40, r=20, t=60, b=50),
104
  legend_title_text="Date basis",
105
  )
106
- return fig
107
 
108
 
109
  def filing_delay_chart():
@@ -122,7 +148,7 @@ def filing_delay_chart():
122
  showlegend=False,
123
  margin=dict(l=40, r=20, t=60, b=50),
124
  )
125
- return fig
126
 
127
 
128
  def trade_type_chart():
@@ -137,7 +163,7 @@ def trade_type_chart():
137
  yaxis_title="Rows",
138
  margin=dict(l=40, r=20, t=60, b=50),
139
  )
140
- return fig
141
 
142
 
143
  def top_ticker_chart():
@@ -152,7 +178,7 @@ def top_ticker_chart():
152
  margin=dict(l=80, r=20, t=60, b=50),
153
  coloraxis_showscale=False,
154
  )
155
- return fig
156
 
157
 
158
  def wealth_senators() -> list[str]:
@@ -163,7 +189,7 @@ def wealth_senators() -> list[str]:
163
  def wealth_chart(senator_id: str):
164
  frame = WEALTH[WEALTH["senator_id"] == senator_id].sort_values("report_year_num")
165
  if frame.empty:
166
- return go.Figure()
167
  fig = go.Figure()
168
  fig.add_trace(
169
  go.Scatter(
@@ -203,7 +229,7 @@ def wealth_chart(senator_id: str):
203
  yaxis_title="Net-worth interval dollars",
204
  margin=dict(l=70, r=20, t=60, b=50),
205
  )
206
- return fig
207
 
208
 
209
  def wealth_table(senator_id: str) -> pd.DataFrame:
@@ -265,14 +291,99 @@ def file_inventory() -> pd.DataFrame:
265
 
266
 
267
  CSS = """
268
- :root { --accent: #1b6b63; --ink: #1f2933; --muted: #637083; --warn: #9a5a00; }
269
- .gradio-container { max-width: 1180px !important; margin: auto; color: var(--ink); }
270
- .metrics { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin: 12px 0 16px; }
271
- .metric { border: 1px solid #d8dee8; border-radius: 8px; padding: 12px; background: #ffffff; }
272
- .metric-value { font-size: 1.35rem; font-weight: 750; color: var(--accent); line-height: 1.2; overflow-wrap: anywhere; }
273
- .metric-label { font-size: .82rem; color: var(--muted); margin-top: 4px; }
274
- .boundary { border-left: 5px solid var(--warn); background: #fff7e8; padding: 12px 14px; border-radius: 6px; margin: 12px 0 18px; }
275
- .small-note { color: var(--muted); font-size: .94rem; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
276
  @media (max-width: 900px) { .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
277
  """
278
 
 
16
  MANIFEST = json.loads((DATA / "public_release_manifest.json").read_text(encoding="utf-8"))
17
  CLAIM_BOUNDARY = json.loads((AUDIT / "claim_boundary.json").read_text(encoding="utf-8"))
18
  SOURCE_GAPS = json.loads((AUDIT / "source_gap_report.json").read_text(encoding="utf-8"))
19
+ FONT_FAMILY = "Inter, Segoe UI, Roboto, Helvetica Neue, Arial, sans-serif"
20
+
21
+
22
+ def style_figure(fig):
23
+ fig.update_layout(
24
+ template="plotly_white",
25
+ font=dict(family=FONT_FAMILY, size=14, color="#1f2933"),
26
+ title_font=dict(family=FONT_FAMILY, size=18, color="#0f172a"),
27
+ legend=dict(font=dict(family=FONT_FAMILY, size=13, color="#334155")),
28
+ hoverlabel=dict(font_size=13, font_family=FONT_FAMILY),
29
+ paper_bgcolor="#ffffff",
30
+ plot_bgcolor="#ffffff",
31
+ )
32
+ fig.update_xaxes(
33
+ title_font=dict(family=FONT_FAMILY, size=14, color="#334155"),
34
+ tickfont=dict(family=FONT_FAMILY, size=13, color="#334155"),
35
+ gridcolor="#e7edf5",
36
+ linecolor="#cbd5e1",
37
+ )
38
+ fig.update_yaxes(
39
+ title_font=dict(family=FONT_FAMILY, size=14, color="#334155"),
40
+ tickfont=dict(family=FONT_FAMILY, size=13, color="#334155"),
41
+ gridcolor="#e7edf5",
42
+ linecolor="#cbd5e1",
43
+ )
44
+ return fig
45
 
46
 
47
  def read_jsonl_gz(name: str, limit: int | None = None) -> pd.DataFrame:
 
129
  margin=dict(l=40, r=20, t=60, b=50),
130
  legend_title_text="Date basis",
131
  )
132
+ return style_figure(fig)
133
 
134
 
135
  def filing_delay_chart():
 
148
  showlegend=False,
149
  margin=dict(l=40, r=20, t=60, b=50),
150
  )
151
+ return style_figure(fig)
152
 
153
 
154
  def trade_type_chart():
 
163
  yaxis_title="Rows",
164
  margin=dict(l=40, r=20, t=60, b=50),
165
  )
166
+ return style_figure(fig)
167
 
168
 
169
  def top_ticker_chart():
 
178
  margin=dict(l=80, r=20, t=60, b=50),
179
  coloraxis_showscale=False,
180
  )
181
+ return style_figure(fig)
182
 
183
 
184
  def wealth_senators() -> list[str]:
 
189
  def wealth_chart(senator_id: str):
190
  frame = WEALTH[WEALTH["senator_id"] == senator_id].sort_values("report_year_num")
191
  if frame.empty:
192
+ return style_figure(go.Figure())
193
  fig = go.Figure()
194
  fig.add_trace(
195
  go.Scatter(
 
229
  yaxis_title="Net-worth interval dollars",
230
  margin=dict(l=70, r=20, t=60, b=50),
231
  )
232
+ return style_figure(fig)
233
 
234
 
235
  def wealth_table(senator_id: str) -> pd.DataFrame:
 
291
 
292
 
293
  CSS = """
294
+ :root {
295
+ --accent: #1b6b63;
296
+ --ink: #172033;
297
+ --muted: #475569;
298
+ --warn: #8a4b00;
299
+ --line: #cbd5e1;
300
+ --soft: #f8fafc;
301
+ --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
302
+ }
303
+ .gradio-container,
304
+ .gradio-container * {
305
+ font-family: var(--font) !important;
306
+ text-rendering: optimizeLegibility;
307
+ -webkit-font-smoothing: antialiased;
308
+ -moz-osx-font-smoothing: grayscale;
309
+ letter-spacing: 0;
310
+ }
311
+ .gradio-container {
312
+ max-width: 1180px !important;
313
+ margin: auto;
314
+ color: var(--ink);
315
+ font-size: 16px;
316
+ line-height: 1.48;
317
+ }
318
+ .gradio-container h1,
319
+ .gradio-container .prose h1,
320
+ .gradio-container .markdown h1 {
321
+ color: #0f172a !important;
322
+ font-size: 2rem !important;
323
+ line-height: 1.15 !important;
324
+ font-weight: 800 !important;
325
+ margin: 10px 0 8px !important;
326
+ }
327
+ .gradio-container p,
328
+ .gradio-container li,
329
+ .gradio-container .prose {
330
+ color: #334155 !important;
331
+ font-size: 1rem !important;
332
+ line-height: 1.58 !important;
333
+ }
334
+ .gradio-container label,
335
+ .gradio-container .label-wrap,
336
+ .gradio-container .label-wrap span,
337
+ .gradio-container button[role="tab"] {
338
+ color: #0f172a !important;
339
+ font-size: 1rem !important;
340
+ font-weight: 650 !important;
341
+ }
342
+ .gradio-container button[role="tab"][aria-selected="true"] {
343
+ color: var(--accent) !important;
344
+ font-weight: 800 !important;
345
+ }
346
+ .gradio-container input,
347
+ .gradio-container textarea,
348
+ .gradio-container select {
349
+ color: #111827 !important;
350
+ font-size: 1rem !important;
351
+ }
352
+ .metrics { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin: 14px 0 18px; }
353
+ .metric { border: 1px solid var(--line); border-radius: 8px; padding: 13px 14px; background: #ffffff; }
354
+ .metric-value { font-size: 1.45rem; font-weight: 800; color: var(--accent); line-height: 1.18; overflow-wrap: anywhere; }
355
+ .metric-label { font-size: .92rem; color: var(--muted); font-weight: 650; margin-top: 5px; }
356
+ .boundary {
357
+ border-left: 5px solid var(--warn);
358
+ background: #fff7e8;
359
+ color: #3f2a00;
360
+ padding: 13px 15px;
361
+ border-radius: 6px;
362
+ margin: 12px 0 20px;
363
+ font-size: 1rem;
364
+ line-height: 1.55;
365
+ }
366
+ .boundary strong { color: #2f1d00; font-weight: 800; }
367
+ .small-note { color: var(--muted); font-size: .98rem; }
368
+ .gradio-container table,
369
+ .gradio-container th,
370
+ .gradio-container td {
371
+ color: #111827 !important;
372
+ font-size: .94rem !important;
373
+ line-height: 1.45 !important;
374
+ }
375
+ .gradio-container th {
376
+ background: #eef4f8 !important;
377
+ color: #0f172a !important;
378
+ font-weight: 750 !important;
379
+ }
380
+ .gradio-container td {
381
+ background: #ffffff !important;
382
+ }
383
+ .gradio-container .dataframe,
384
+ .gradio-container .table-wrap {
385
+ border-color: var(--line) !important;
386
+ }
387
  @media (max-width: 900px) { .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
388
  """
389
 
space_bundle_manifest.json CHANGED
@@ -8,8 +8,8 @@
8
  "files": [
9
  {
10
  "path": "app.py",
11
- "sha256": "5f735e68eb1b110bd6eee57f64778b345973fd0ed68d190ee234d59b2488fa51",
12
- "byte_count": 14069
13
  },
14
  {
15
  "path": "data/audit/claim_boundary.json",
@@ -107,5 +107,5 @@
107
  "byte_count": 47
108
  }
109
  ],
110
- "manifest_hash": "6c62dc74250b237008975bbf783f728ccb266c8d1001e0e31ec63defb9b0244e"
111
  }
 
8
  "files": [
9
  {
10
  "path": "app.py",
11
+ "sha256": "95b3e4f476a8708cbf5892ab0b788b176224373631492978b9bf9f72a5adac20",
12
+ "byte_count": 17143
13
  },
14
  {
15
  "path": "data/audit/claim_boundary.json",
 
107
  "byte_count": 47
108
  }
109
  ],
110
+ "manifest_hash": "0b3c002cb32fe8dfd5f891d084ad18701d28ebb250e71b4f5606f85ce2172660"
111
  }