Skip to content

Commit c41c1dc

Browse files
update(pie-basic): highcharts — comprehensive quality review
Comprehensive review improving code quality, data choice, visual design, spec compliance, and library feature usage.
1 parent abfe67e commit c41c1dc

4 files changed

Lines changed: 61 additions & 46 deletions

File tree

Lines changed: 52 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
""" pyplots.ai
1+
"""pyplots.ai
22
pie-basic: Basic Pie Chart
3-
Library: highcharts unknown | Python 3.13.11
4-
Quality: 92/100 | Created: 2025-12-23
3+
Library: highcharts 1.10.3 | Python 3.14.0
4+
Quality: /100 | Updated: 2026-02-14
55
"""
66

77
import tempfile
@@ -17,74 +17,87 @@
1717
from selenium.webdriver.chrome.options import Options
1818

1919

20-
# Data - Market share distribution (5 categories, realistic business context)
21-
categories = ["Product A", "Product B", "Product C", "Product D", "Product E"]
22-
values = [35, 25, 20, 12, 8]
20+
# Data — Cloud infrastructure market share (5 categories, realistic business context)
21+
# No random data — fully deterministic
22+
categories = ["AWS", "Azure", "Google Cloud", "Alibaba", "Others"]
23+
values = [31, 25, 11, 4, 29]
2324

24-
# Colorblind-safe colors (Python Blue first, then complementary)
25-
colors = ["#306998", "#FFD43B", "#9467BD", "#17BECF", "#8C564B"]
25+
# Colorblind-safe palette (Python Blue first, then complementary)
26+
colors = ["#306998", "#FFD43B", "#E07B54", "#17BECF", "#9467BD"]
2627

27-
# Create chart with container specified
28+
# Chart
2829
chart = Chart(container="container")
2930
chart.options = HighchartsOptions()
3031

31-
# Chart configuration for 3600x3600 square (ideal for pie charts)
3232
chart.options.chart = {
3333
"type": "pie",
3434
"width": 3600,
3535
"height": 3600,
3636
"backgroundColor": "#ffffff",
37-
"spacingTop": 80,
38-
"spacingBottom": 80,
39-
"spacingLeft": 80,
40-
"spacingRight": 80,
37+
"spacingTop": 60,
38+
"spacingBottom": 40,
39+
"spacingLeft": 100,
40+
"spacingRight": 100,
4141
}
4242

4343
# Title
4444
chart.options.title = {
45-
"text": "pie-basic · highcharts · pyplots.ai",
46-
"style": {"fontSize": "48px", "fontWeight": "bold"},
47-
"margin": 40,
45+
"text": "Cloud Infrastructure Market Share · pie-basic · highcharts · pyplots.ai",
46+
"style": {"fontSize": "52px", "fontWeight": "bold"},
47+
"margin": 20,
48+
}
49+
50+
# Subtitle
51+
chart.options.subtitle = {
52+
"text": "Global cloud spending by provider, 2024",
53+
"style": {"fontSize": "36px", "color": "#666666"},
4854
}
4955

5056
# Colors
5157
chart.options.colors = colors
5258

53-
# Plot options for pie with percentage labels and legend
59+
# Credits
60+
chart.options.credits = {"enabled": False}
61+
62+
# Plot options
5463
chart.options.plot_options = {
5564
"pie": {
5665
"allowPointSelect": True,
5766
"cursor": "pointer",
5867
"dataLabels": {
5968
"enabled": True,
6069
"format": "<b>{point.name}</b>: {point.percentage:.1f}%",
61-
"style": {"fontSize": "32px", "textOutline": "none"},
62-
"distance": 40,
63-
"connectorWidth": 2,
70+
"style": {"fontSize": "38px", "textOutline": "none", "fontWeight": "normal"},
71+
"distance": 50,
72+
"connectorWidth": 3,
73+
"connectorColor": "#aaaaaa",
74+
"softConnector": True,
6475
},
6576
"showInLegend": True,
66-
"slicedOffset": 25,
77+
"slicedOffset": 35,
6778
"size": "70%",
68-
"center": ["40%", "50%"],
79+
"center": ["50%", "50%"],
80+
"startAngle": -20,
6981
}
7082
}
7183

72-
# Legend on the right side
84+
# Legend — bottom horizontal
7385
chart.options.legend = {
7486
"enabled": True,
75-
"align": "right",
76-
"verticalAlign": "middle",
77-
"layout": "vertical",
78-
"itemStyle": {"fontSize": "36px", "fontWeight": "normal"},
79-
"itemMarginTop": 20,
80-
"itemMarginBottom": 20,
87+
"align": "center",
88+
"verticalAlign": "bottom",
89+
"layout": "horizontal",
90+
"itemStyle": {"fontSize": "38px", "fontWeight": "normal"},
8191
"symbolRadius": 10,
82-
"symbolHeight": 20,
83-
"symbolWidth": 20,
84-
"x": -80,
92+
"symbolHeight": 22,
93+
"symbolWidth": 22,
94+
"margin": 20,
8595
}
8696

87-
# Create pie series with data - first slice (largest) is exploded for emphasis
97+
# Tooltip
98+
chart.options.tooltip = {"pointFormat": "<b>{point.percentage:.1f}%</b> market share", "style": {"fontSize": "28px"}}
99+
100+
# Series — largest slice (AWS) exploded for emphasis
88101
series = PieSeries()
89102
series.name = "Market Share"
90103
series.data = [
@@ -113,16 +126,15 @@
113126
</body>
114127
</html>"""
115128

116-
# Write temp HTML and take screenshot
129+
# Write temp HTML and save interactive version
117130
with tempfile.NamedTemporaryFile(mode="w", suffix=".html", delete=False, encoding="utf-8") as f:
118131
f.write(html_content)
119132
temp_path = f.name
120133

121-
# Also save the HTML for interactive version
122134
with open("plot.html", "w", encoding="utf-8") as f:
123135
f.write(html_content)
124136

125-
# Setup Chrome for screenshot
137+
# Screenshot via headless Chrome
126138
chrome_options = Options()
127139
chrome_options.add_argument("--headless")
128140
chrome_options.add_argument("--no-sandbox")
@@ -132,14 +144,14 @@
132144

133145
driver = webdriver.Chrome(options=chrome_options)
134146
driver.get(f"file://{temp_path}")
135-
time.sleep(5) # Wait for chart to render
147+
time.sleep(5)
136148
driver.save_screenshot("plot_raw.png")
137149
driver.quit()
138150

139-
# Crop to exact 3600x3600 dimensions
151+
# Crop to exact 3600x3600
140152
img = Image.open("plot_raw.png")
141153
img_cropped = img.crop((0, 0, 3600, 3600))
142154
img_cropped.save("plot.png")
143155
Path("plot_raw.png").unlink()
144156

145-
Path(temp_path).unlink() # Clean up temp file
157+
Path(temp_path).unlink()

plots/pie-basic/metadata/highcharts.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
library: highcharts
22
specification_id: pie-basic
33
created: '2025-12-23T00:36:27Z'
4-
updated: '2025-12-23T00:40:57Z'
5-
generated_by: claude-opus-4-5-20251101
4+
updated: '2026-02-14T14:40:21+00:00'
5+
generated_by: claude-opus-4-6
66
workflow_run: 20447778270
77
issue: 0
8-
python_version: 3.13.11
9-
library_version: unknown
8+
python_version: '3.14.0'
9+
library_version: 1.10.3
1010
preview_url: https://storage.googleapis.com/pyplots-images/plots/pie-basic/highcharts/plot.png
1111
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/pie-basic/highcharts/plot_thumb.png
1212
preview_html: https://storage.googleapis.com/pyplots-images/plots/pie-basic/highcharts/plot.html
13-
quality_score: 92
13+
quality_score: null
1414
impl_tags:
1515
dependencies:
1616
- pillow

plots/pie-basic/specification.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ A pie chart showing proportions of categorical data as slices of a circle. Each
1616
- `category` (string) - category labels
1717
- `value` (numeric) - values for each category
1818
- Size: 3-8 categories (too many becomes unreadable)
19+
- Values must be positive and sum to a meaningful whole
20+
- Example: Market share of 5-6 tech companies
1921

2022
## Notes
2123

2224
- Include percentage labels on slices
2325
- Use distinct colors for each category
2426
- Add a legend for category identification
25-
- Consider slight explosion for emphasis on key slice
27+
- Slightly explode the largest or smallest slice for emphasis

plots/pie-basic/specification.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ tags:
2323
features:
2424
- basic
2525
- proportional
26+
- comparison

0 commit comments

Comments
 (0)