Skip to content

Commit b3e658f

Browse files
committed
fix: remove white space and balance layout with invisible spacer
- Replace text spacer with truly invisible point mark - Disable axes on spacer with axis=None - Top row (set bars + spacer) now matches bottom row width - Maintains horizontal alignment while balancing visual layout
1 parent e6bc632 commit b3e658f

2 files changed

Lines changed: 17 additions & 17 deletions

File tree

altair_upset/upset.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -642,22 +642,18 @@ def UpSetVertical(
642642
.properties(width=cardinality_bar_width, height=matrix_height)
643643
)
644644

645-
# Create empty spacer for top-right area
645+
# Create invisible spacer for top-right to balance layout
646646
spacer = (
647-
alt.Chart(pd.DataFrame({"x": [0]}))
648-
.mark_text()
649-
.encode(text=alt.value(""))
647+
alt.Chart(pd.DataFrame({"x": [0], "y": [0]}))
648+
.mark_point(opacity=0, size=0)
649+
.encode(x=alt.X("x:Q", axis=None), y=alt.Y("y:Q", axis=None))
650650
.properties(width=cardinality_bar_width, height=set_bar_height)
651651
)
652652

653653
# Combine components vertically with cardinality bars
654654
upsetaltair = (
655655
alt.vconcat(
656-
alt.hconcat(
657-
set_bar_chart,
658-
spacer,
659-
spacing=0,
660-
).resolve_scale(x="shared"),
656+
alt.hconcat(set_bar_chart, spacer, spacing=0),
661657
alt.hconcat(
662658
matrix_view,
663659
cardinality_bar_chart,

tests/__snapshots__/test_advanced_features/test_upset_vertical_snapshot[vega_spec].json

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,22 @@
8989
"hconcat": [
9090
{
9191
"encoding": {
92-
"text": {
93-
"value": ""
92+
"x": {
93+
"axis": null,
94+
"field": "x",
95+
"type": "quantitative"
96+
},
97+
"y": {
98+
"axis": null,
99+
"field": "y",
100+
"type": "quantitative"
94101
}
95102
},
96103
"height": 240.0,
97104
"mark": {
98-
"type": "text"
105+
"opacity": 0,
106+
"size": 0,
107+
"type": "point"
99108
},
100109
"name": "view_3",
101110
"width": 120
@@ -561,11 +570,6 @@
561570
"width": 680
562571
}
563572
],
564-
"resolve": {
565-
"scale": {
566-
"x": "shared"
567-
}
568-
},
569573
"spacing": 0
570574
},
571575
{

0 commit comments

Comments
 (0)