Skip to content

Commit 9e45cfb

Browse files
feat(highcharts): implement area-basic
1 parent 6541fd1 commit 9e45cfb

1 file changed

Lines changed: 22 additions & 20 deletions

File tree

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

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
from selenium.webdriver.chrome.options import Options
1616

1717

18-
# Data - Monthly sales data
19-
sales = [100, 150, 130, 180, 200, 220, 195, 240, 260, 245, 280, 310]
18+
# Data
19+
months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
20+
sales = [100, 150, 130, 180, 200, 220, 195, 240, 260, 230, 270, 310]
2021

2122
# Create chart
2223
chart = Chart(container="container")
@@ -26,38 +27,39 @@
2627
chart.options.chart = {"type": "area", "width": 4800, "height": 2700, "backgroundColor": "#ffffff"}
2728

2829
# Title
29-
chart.options.title = {"text": "Basic Area Chart", "style": {"fontSize": "48px"}}
30+
chart.options.title = {"text": "Monthly Sales Overview", "style": {"fontSize": "48px"}}
3031

3132
# Axes
3233
chart.options.x_axis = {
33-
"title": {"text": "Month", "style": {"fontSize": "40px"}},
34-
"categories": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
35-
"labels": {"style": {"fontSize": "32px"}},
36-
"gridLineWidth": 1,
37-
"gridLineColor": "rgba(0, 0, 0, 0.1)",
34+
"categories": months,
35+
"title": {"text": "Month", "style": {"fontSize": "36px"}},
36+
"labels": {"style": {"fontSize": "28px"}},
3837
}
3938

4039
chart.options.y_axis = {
41-
"title": {"text": "Sales", "style": {"fontSize": "40px"}},
42-
"labels": {"style": {"fontSize": "32px"}},
40+
"title": {"text": "Sales ($)", "style": {"fontSize": "36px"}},
41+
"labels": {"style": {"fontSize": "28px"}},
42+
"gridLineColor": "#e0e0e0",
4343
"gridLineWidth": 1,
44-
"gridLineColor": "rgba(0, 0, 0, 0.1)",
4544
}
4645

47-
# Legend styling
48-
chart.options.legend = {"itemStyle": {"fontSize": "32px"}}
49-
50-
# Area series
46+
# Add series
5147
series = AreaSeries()
5248
series.data = sales
53-
series.name = "Monthly Sales"
54-
series.color = "#306998" # Python Blue
49+
series.name = "Sales"
50+
series.color = "#306998"
5551
series.fill_opacity = 0.5
5652
series.line_width = 4
5753

5854
chart.add_series(series)
5955

60-
# Download Highcharts JS for inline embedding
56+
# Legend
57+
chart.options.legend = {"enabled": False}
58+
59+
# Credits
60+
chart.options.credits = {"enabled": False}
61+
62+
# Download Highcharts JS
6163
highcharts_url = "https://code.highcharts.com/highcharts.js"
6264
with urllib.request.urlopen(highcharts_url, timeout=30) as response:
6365
highcharts_js = response.read().decode("utf-8")
@@ -90,8 +92,8 @@
9092

9193
driver = webdriver.Chrome(options=chrome_options)
9294
driver.get(f"file://{temp_path}")
93-
time.sleep(5) # Wait for chart to render
95+
time.sleep(5)
9496
driver.save_screenshot("plot.png")
9597
driver.quit()
9698

97-
Path(temp_path).unlink() # Clean up temp file
99+
Path(temp_path).unlink()

0 commit comments

Comments
 (0)