Skip to content

Commit 8c667ff

Browse files
feat(highcharts): implement area-basic (#525)
## Summary Implements `area-basic` for **highcharts** library. **Parent Issue:** #514 **Sub-Issue:** #522 **Base Branch:** `plot/area-basic` **Attempt:** 1/3 ## Implementation - `plots/highcharts/area/area-basic/default.py` ### Features - Basic area chart showing monthly sales data - Uses Python Blue (#306998) with 0.6 fill opacity - Includes title, axis labels with appropriate font sizes - Data markers enabled for each point - Exports to 4800x2700 PNG via headless Chrome Closes #522 Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
1 parent 1e65b26 commit 8c667ff

File tree

1 file changed

+18
-30
lines changed

1 file changed

+18
-30
lines changed

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

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,40 +15,32 @@
1515
from selenium.webdriver.chrome.options import Options
1616

1717

18-
# Data - Monthly sales example
19-
sales = [100, 150, 130, 180, 200, 220, 195, 240, 280, 310, 290, 350]
18+
# Data
19+
months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
20+
sales = [120, 135, 148, 162, 175, 195, 210, 198, 185, 170, 158, 190]
2021

21-
# Create chart
22+
# Create chart with container (required for headless export)
2223
chart = Chart(container="container")
2324
chart.options = HighchartsOptions()
2425

2526
# Chart configuration
26-
chart.options.chart = {
27-
"type": "area",
28-
"width": 4800,
29-
"height": 2700,
30-
"backgroundColor": "#ffffff",
31-
"style": {"fontFamily": "Arial, sans-serif"},
32-
}
27+
chart.options.chart = {"type": "area", "width": 4800, "height": 2700, "backgroundColor": "#ffffff"}
3328

3429
# Title
35-
chart.options.title = {"text": "Monthly Sales Trend", "style": {"fontSize": "48px"}}
30+
chart.options.title = {"text": "Monthly Sales", "style": {"fontSize": "48px"}}
3631

37-
# Axes
32+
# X-axis with categories
3833
chart.options.x_axis = {
34+
"categories": months,
3935
"title": {"text": "Month", "style": {"fontSize": "40px"}},
40-
"categories": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
41-
"labels": {"style": {"fontSize": "32px"}, "enabled": True},
42-
"gridLineWidth": 1,
43-
"gridLineColor": "rgba(0, 0, 0, 0.1)",
44-
"tickmarkPlacement": "on",
36+
"labels": {"style": {"fontSize": "32px"}},
4537
}
4638

39+
# Y-axis
4740
chart.options.y_axis = {
48-
"title": {"text": "Sales ($)", "style": {"fontSize": "40px"}},
41+
"title": {"text": "Sales", "style": {"fontSize": "40px"}},
4942
"labels": {"style": {"fontSize": "32px"}},
50-
"gridLineWidth": 1,
51-
"gridLineColor": "rgba(0, 0, 0, 0.1)",
43+
"gridLineColor": "#e0e0e0",
5244
}
5345

5446
# Legend
@@ -59,13 +51,13 @@
5951
series.data = sales
6052
series.name = "Sales"
6153
series.color = "#306998"
62-
series.fill_opacity = 0.5
63-
series.line_width = 4
64-
series.marker = {"enabled": True, "radius": 6, "fillColor": "#306998", "lineWidth": 2, "lineColor": "#ffffff"}
54+
series.fill_opacity = 0.6
55+
series.line_width = 3
56+
series.marker = {"enabled": True, "radius": 6, "fillColor": "#306998"}
6557

6658
chart.add_series(series)
6759

68-
# Download Highcharts JS
60+
# Download Highcharts JS for inline embedding
6961
highcharts_url = "https://code.highcharts.com/highcharts.js"
7062
with urllib.request.urlopen(highcharts_url, timeout=30) as response:
7163
highcharts_js = response.read().decode("utf-8")
@@ -94,16 +86,12 @@
9486
chrome_options.add_argument("--no-sandbox")
9587
chrome_options.add_argument("--disable-dev-shm-usage")
9688
chrome_options.add_argument("--disable-gpu")
97-
chrome_options.add_argument("--window-size=4800,2800")
89+
chrome_options.add_argument("--window-size=4800,2700")
9890

9991
driver = webdriver.Chrome(options=chrome_options)
100-
driver.set_window_size(4800, 2800)
10192
driver.get(f"file://{temp_path}")
10293
time.sleep(5)
103-
104-
# Get the container element and screenshot it directly
105-
container = driver.find_element("id", "container")
106-
container.screenshot("plot.png")
94+
driver.save_screenshot("plot.png")
10795
driver.quit()
10896

10997
Path(temp_path).unlink()

0 commit comments

Comments
 (0)