Skip to content

Commit 1e65b26

Browse files
feat(altair): implement area-basic (#524)
## Summary Implements `area-basic` for **altair** library. **Parent Issue:** #514 **Sub-Issue:** #519 **Base Branch:** `plot/area-basic` **Attempt:** 1/3 ## Implementation - `plots/altair/area/area-basic/default.py` ### Changes from initial template: - Used spec example data with proper month names (Jan-Dec) as ordinal values - Adjusted opacity to 0.7 for better visual clarity - Added `sort=None` to preserve month order - Configured proper axis labels and font sizes per style guide Closes #519 Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
1 parent bd7dca8 commit 1e65b26

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

plots/altair/area/area-basic/default.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@
1010
# Data
1111
data = pd.DataFrame(
1212
{
13-
"month": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
14-
"sales": [100, 150, 130, 180, 200, 220, 195, 240, 260, 230, 280, 310],
13+
"month": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
14+
"sales": [120, 135, 148, 162, 175, 195, 210, 198, 185, 170, 158, 190],
1515
}
1616
)
1717

1818
# Create chart with area and line
1919
chart = (
2020
alt.Chart(data)
21-
.mark_area(opacity=0.5, color="#306998", line={"color": "#306998", "strokeWidth": 2})
21+
.mark_area(opacity=0.7, color="#306998", line={"color": "#306998", "strokeWidth": 2})
2222
.encode(
23-
x=alt.X("month:Q", title="Month", axis=alt.Axis(labelFontSize=16, titleFontSize=20)),
23+
x=alt.X("month:O", title="Month", sort=None, axis=alt.Axis(labelFontSize=16, titleFontSize=20)),
2424
y=alt.Y("sales:Q", title="Sales", axis=alt.Axis(labelFontSize=16, titleFontSize=20)),
2525
)
26-
.properties(width=1600, height=900, title=alt.TitleParams(text="Basic Area Chart", fontSize=20))
26+
.properties(width=1600, height=900, title=alt.TitleParams(text="Monthly Sales", fontSize=20))
2727
.configure_view(strokeWidth=0)
2828
.configure_axis(grid=True, gridOpacity=0.3)
2929
)

0 commit comments

Comments
 (0)