Skip to content

Commit 8de3746

Browse files
committed
feat: adjust cardinality bar sizing for better spacing
1 parent 72dc296 commit 8de3746

4 files changed

Lines changed: 17 additions & 7 deletions

File tree

altair_upset/components.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def create_vertical_set_bars(
165165
y=alt.Y(
166166
"sum(count):Q",
167167
axis=alt.Axis(grid=False, tickCount=3, domain=False),
168-
scale=alt.Scale(zero=True),
168+
scale=alt.Scale(zero=True, padding=0, nice=False),
169169
title="Set Size",
170170
)
171171
)
@@ -253,6 +253,7 @@ def create_horizontal_cardinality_bar(
253253
x=alt.X(
254254
"max(count):Q",
255255
axis=alt.Axis(grid=False, tickCount=3, orient=x_axis_orient),
256+
scale=alt.Scale(zero=True, padding=0, nice=False),
256257
title="Intersection Size",
257258
),
258259
color=brush_color,

altair_upset/config.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
31
def upsetaltair_top_level_configuration(
42
base, legend_orient="top-left", legend_symbol_size=30
53
):

altair_upset/upset.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ def UpSetVertical(
562562
if cardinality_bar_width is None:
563563
cardinality_bar_width = int(width * 0.15) # 15% of total width
564564
set_bar_height = height * height_ratio
565-
matrix_height = height - set_bar_height
565+
matrix_height = height - set_bar_height # Use full available height
566566
matrix_width = width - cardinality_bar_width
567567

568568
# Setup styles
@@ -578,8 +578,7 @@ def UpSetVertical(
578578

579579
# Automatic bar size for cardinality bars
580580
num_intersections = max(1, len(data["intersection_id"].unique().tolist()))
581-
# Use 80% of available space per intersection for better visibility
582-
cardinality_bar_size = min(50, (matrix_height / num_intersections) * 0.8)
581+
cardinality_bar_size = min(30, (matrix_height / num_intersections) - 5)
583582

584583
# Tooltip configuration for cardinality bars
585584
tooltip = [

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@
122122
"tickCount": 3
123123
},
124124
"field": "count",
125+
"scale": {
126+
"nice": false,
127+
"padding": 0,
128+
"zero": true
129+
},
125130
"title": "Intersection Size",
126131
"type": "quantitative"
127132
},
@@ -284,6 +289,11 @@
284289
"tickCount": 3
285290
},
286291
"field": "count",
292+
"scale": {
293+
"nice": false,
294+
"padding": 0,
295+
"zero": true
296+
},
287297
"title": "Intersection Size",
288298
"type": "quantitative"
289299
},
@@ -305,7 +315,7 @@
305315
},
306316
"mark": {
307317
"color": "#3A3A3A",
308-
"size": 36.0,
318+
"size": 30,
309319
"type": "bar"
310320
},
311321
"name": "view_1",
@@ -1192,6 +1202,8 @@
11921202
},
11931203
"field": "count",
11941204
"scale": {
1205+
"nice": false,
1206+
"padding": 0,
11951207
"zero": true
11961208
},
11971209
"title": "Set Size",

0 commit comments

Comments
 (0)