Skip to content

Commit ee8995c

Browse files
fix(altair): address review feedback for lollipop-basic
Attempt 1/3 - fixes based on AI review
1 parent c070970 commit ee8995c

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

  • plots/lollipop-basic/implementations/python

plots/lollipop-basic/implementations/python/altair.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
""" anyplot.ai
1+
"""anyplot.ai
22
lollipop-basic: Basic Lollipop Chart
33
Library: altair 6.2.2 | Python 3.13.14
44
Quality: 87/100 | Updated: 2026-07-01
@@ -55,7 +55,7 @@
5555
alt.Chart(df)
5656
.mark_rule(strokeWidth=4)
5757
.encode(
58-
x=alt.X("category:N", sort="-y", title="Category", axis=alt.Axis(labelAngle=-35)),
58+
x=alt.X("category:N", sort="-y", title="Category", axis=alt.Axis(labelAngle=-45, labelFontSize=9)),
5959
y=alt.Y("value:Q", title="Sales (USD)", axis=alt.Axis(format="$,.0f")),
6060
color=alt.value(BRAND),
6161
opacity=alt.condition(selection, alt.value(1.0), alt.value(0.3)),
@@ -77,11 +77,24 @@
7777
)
7878
)
7979

80+
# Value annotation on top performer to anchor the narrative (DE-03)
81+
annotation_df = df[df["category"] == "Electronics"].copy()
82+
annotation = (
83+
alt.Chart(annotation_df)
84+
.mark_text(dy=-18, fontSize=10, fontWeight="bold")
85+
.encode(
86+
x=alt.X("category:N", sort="-y"),
87+
y=alt.Y("value:Q"),
88+
text=alt.Text("value:Q", format="$,.0f"),
89+
color=alt.value(INK),
90+
)
91+
)
92+
8093
# Title: n=73 chars → fontsize = round(16 × 67/73) = 15
8194
TITLE = "Product Sales by Category · lollipop-basic · python · altair · anyplot.ai"
8295

8396
chart = (
84-
(stems + dots)
97+
(stems + dots + annotation)
8598
.properties(
8699
width=620,
87100
height=320,
@@ -91,6 +104,7 @@
91104
.configure_view(fill=PAGE_BG, stroke=None)
92105
.configure_axis(
93106
domainColor=INK_SOFT,
107+
domainOpacity=0,
94108
domainWidth=1,
95109
tickColor=INK_SOFT,
96110
gridColor=INK,

0 commit comments

Comments
 (0)