Spaces:
Running
Running
Multiline closed dataset header (#20)
Browse files- Split the closed dataset headers into 2 lines (640f29f51ac965b1806eae61f780328669d57913)
- app/backend/data_page.py +1 -1
- app/backend/multi_header_util.py +19 -1
app/backend/data_page.py
CHANGED
@@ -225,7 +225,7 @@ def table_area(group_name, grid_state, data_engine=None, df=None):
|
|
225 |
".custom-header-style": {
|
226 |
"text-overflow": "clip",
|
227 |
"overflow": "visible",
|
228 |
-
"white-space": "
|
229 |
"height": "auto",
|
230 |
"font-family": 'Arial',
|
231 |
"font-size": "14px",
|
|
|
225 |
".custom-header-style": {
|
226 |
"text-overflow": "clip",
|
227 |
"overflow": "visible",
|
228 |
+
"white-space": "pre-line",
|
229 |
"height": "auto",
|
230 |
"font-family": 'Arial',
|
231 |
"font-size": "14px",
|
app/backend/multi_header_util.py
CHANGED
@@ -26,6 +26,24 @@ def get_dataset_url_name(field_name):
|
|
26 |
return field_name
|
27 |
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
def mutil_header_options(column_list: list, avg_column: str, is_section: bool):
|
30 |
"""
|
31 |
get mutil_header_options - 优化版本,减少组件实例化
|
@@ -62,7 +80,7 @@ def mutil_header_options(column_list: list, avg_column: str, is_section: bool):
|
|
62 |
'cellClass': 'custom-cell-style',
|
63 |
'autoHeaderHeight': True,
|
64 |
'children': [
|
65 |
-
{'headerName': column
|
66 |
'field': column,
|
67 |
|
68 |
"headerComponentParams": {
|
|
|
26 |
return field_name
|
27 |
|
28 |
|
29 |
+
def format_closed_dataset_header(column_name):
|
30 |
+
"""
|
31 |
+
Format closed dataset header to display in two lines
|
32 |
+
:param column_name: Original column name like "ClosedDataset 2 (German Legal Sentences)"
|
33 |
+
:return: Formatted header with line break
|
34 |
+
"""
|
35 |
+
if column_name.startswith("ClosedDataset ") and "(" in column_name:
|
36 |
+
# Split "ClosedDataset N (description)" into "ClosedDataset N" and "(description)"
|
37 |
+
parts = column_name.split("(", 1)
|
38 |
+
if len(parts) == 2:
|
39 |
+
dataset_part = parts[0].strip() # "ClosedDataset N"
|
40 |
+
description_part = "(" + parts[1] # "(description)"
|
41 |
+
return f"{dataset_part}\n{description_part}"
|
42 |
+
|
43 |
+
# Return original if it doesn't match the pattern
|
44 |
+
return column_name.replace('_', '')
|
45 |
+
|
46 |
+
|
47 |
def mutil_header_options(column_list: list, avg_column: str, is_section: bool):
|
48 |
"""
|
49 |
get mutil_header_options - 优化版本,减少组件实例化
|
|
|
80 |
'cellClass': 'custom-cell-style',
|
81 |
'autoHeaderHeight': True,
|
82 |
'children': [
|
83 |
+
{'headerName': format_closed_dataset_header(column),
|
84 |
'field': column,
|
85 |
|
86 |
"headerComponentParams": {
|