Skip to content

Commit 4c1c9e8

Browse files
update(candlestick-basic): highcharts — comprehensive quality review
Comprehensive quality review of highcharts implementation for candlestick-basic.
1 parent f543569 commit 4c1c9e8

2 files changed

Lines changed: 38 additions & 56 deletions

File tree

Lines changed: 33 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
""" pyplots.ai
22
candlestick-basic: Basic Candlestick 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.3
4+
Quality: /100 | Updated: 2026-02-24
55
"""
66

77
import json
@@ -19,11 +19,9 @@
1919
# Data - 30 trading days of simulated stock prices
2020
np.random.seed(42)
2121

22-
# Start price and generate OHLC data
2322
start_price = 150.0
2423
n_days = 30
2524

26-
# Generate realistic stock movements
2725
opens = [start_price]
2826
highs = []
2927
lows = []
@@ -34,9 +32,8 @@
3432
if i > 0:
3533
opens.append(open_price)
3634

37-
# Daily volatility
3835
daily_range = abs(np.random.randn() * 2) + 1
39-
direction = np.random.choice([-1, 1], p=[0.45, 0.55]) # Slight bullish bias
36+
direction = np.random.choice([-1, 1], p=[0.45, 0.55])
4037

4138
close_price = open_price + direction * np.random.rand() * daily_range
4239
high_price = max(open_price, close_price) + abs(np.random.randn() * 0.5)
@@ -53,63 +50,53 @@
5350
dates = []
5451
current_date = start_date
5552
while len(dates) < n_days:
56-
if current_date.weekday() < 5: # Monday to Friday
53+
if current_date.weekday() < 5:
5754
dates.append(current_date)
5855
current_date += timedelta(days=1)
5956

6057
# Format data for Highcharts: [timestamp, open, high, low, close]
6158
ohlc_data = []
6259
for i in range(n_days):
63-
timestamp = int(dates[i].timestamp() * 1000) # JavaScript timestamp in ms
60+
timestamp = int(dates[i].timestamp() * 1000)
6461
ohlc_data.append([timestamp, opens[i], highs[i], lows[i], closes[i]])
6562

66-
# Chart options for Highcharts Stock candlestick
67-
# Using colorblind-safe palette: Python Blue for bullish, warm amber for bearish
63+
# Chart options
6864
chart_options = {
6965
"chart": {
7066
"type": "candlestick",
7167
"width": 4800,
7268
"height": 2700,
7369
"backgroundColor": "#ffffff",
74-
"marginBottom": 220,
75-
"marginLeft": 250,
76-
"marginRight": 80,
77-
"marginTop": 150,
70+
"marginBottom": 200,
71+
"marginLeft": 240,
72+
"marginRight": 100,
73+
"marginTop": 140,
7874
"style": {"fontFamily": "Arial, sans-serif"},
7975
},
8076
"title": {
81-
"text": "Stock Price Movement · candlestick-basic · highcharts · pyplots.ai",
82-
"style": {"fontSize": "72px", "fontWeight": "bold", "color": "#333333"},
83-
"y": 60,
77+
"text": "Stock Price Movement \u00b7 candlestick-basic \u00b7 highcharts \u00b7 pyplots.ai",
78+
"style": {"fontSize": "68px", "fontWeight": "bold", "color": "#2c2c2c"},
79+
"y": 55,
8480
},
8581
"xAxis": {
8682
"type": "datetime",
87-
"title": {"text": "Date", "style": {"fontSize": "52px", "color": "#333333"}, "margin": 30},
88-
"labels": {
89-
"style": {"fontSize": "36px", "color": "#333333"},
90-
"format": "{value:%b %d}",
91-
"y": 45,
92-
"step": 2, # Show every 2nd label to prevent overlap
93-
},
94-
"gridLineWidth": 1,
95-
"gridLineColor": "rgba(0, 0, 0, 0.15)",
96-
"gridLineDashStyle": "Dash",
97-
"lineWidth": 3,
83+
"title": {"text": "Date", "style": {"fontSize": "48px", "color": "#333333"}, "margin": 25},
84+
"labels": {"style": {"fontSize": "36px", "color": "#555555"}, "format": "{value:%b %d}", "y": 40, "step": 2},
85+
"gridLineWidth": 0,
86+
"lineWidth": 2,
9887
"lineColor": "#333333",
99-
"tickWidth": 3,
100-
"tickColor": "#333333",
101-
"tickLength": 15,
88+
"tickWidth": 0,
10289
},
10390
"yAxis": {
104-
"title": {"text": "Price (USD)", "style": {"fontSize": "52px", "color": "#333333"}, "margin": 30},
105-
"labels": {"style": {"fontSize": "36px", "color": "#333333"}, "format": "${value:.0f}", "x": -15},
91+
"title": {"text": "Price (USD)", "style": {"fontSize": "48px", "color": "#333333"}, "margin": 25},
92+
"labels": {"style": {"fontSize": "36px", "color": "#555555"}, "format": "${value:.0f}", "x": -15},
10693
"gridLineWidth": 1,
107-
"gridLineColor": "rgba(0, 0, 0, 0.15)",
108-
"gridLineDashStyle": "Dash",
109-
"lineWidth": 3,
94+
"gridLineColor": "rgba(0, 0, 0, 0.20)",
95+
"lineWidth": 2,
11096
"lineColor": "#333333",
111-
"opposite": False, # Keep Y-axis on left side only
112-
"tickInterval": 1, # Show labels at $1 intervals
97+
"opposite": False,
98+
"tickWidth": 0,
99+
"tickInterval": 2,
113100
},
114101
"legend": {"enabled": False},
115102
"tooltip": {
@@ -123,13 +110,12 @@
123110
},
124111
"plotOptions": {
125112
"candlestick": {
126-
# Colorblind-safe: Python Blue for bullish, warm amber for bearish
127-
"color": "#E67E22", # Warm amber for bearish (close < open)
128-
"upColor": "#306998", # Python Blue for bullish (close > open)
129-
"lineColor": "#C0392B", # Darker line for bearish wicks
130-
"upLineColor": "#1A3A5C", # Darker blue for bullish wicks
131-
"lineWidth": 4, # Wick line width - visible at large size
132-
"pointWidth": 70, # Candle body width
113+
"color": "#E67E22",
114+
"upColor": "#306998",
115+
"lineColor": "#C0392B",
116+
"upLineColor": "#1A3A5C",
117+
"lineWidth": 4,
118+
"pointWidth": 70,
133119
}
134120
},
135121
"rangeSelector": {"enabled": False},
@@ -144,10 +130,9 @@
144130
with urllib.request.urlopen(highstock_url, timeout=30) as response:
145131
highstock_js = response.read().decode("utf-8")
146132

147-
# Generate chart options JSON
148133
chart_options_json = json.dumps(chart_options)
149134

150-
# Generate HTML with inline scripts
135+
# Render
151136
html_content = f"""<!DOCTYPE html>
152137
<html>
153138
<head>
@@ -164,16 +149,14 @@
164149
</body>
165150
</html>"""
166151

167-
# Write temp HTML file
168152
with tempfile.NamedTemporaryFile(mode="w", suffix=".html", delete=False, encoding="utf-8") as f:
169153
f.write(html_content)
170154
temp_path = f.name
171155

172-
# Also save the HTML for interactive viewing
173156
with open("plot.html", "w", encoding="utf-8") as f:
174157
f.write(html_content)
175158

176-
# Take screenshot with headless Chrome
159+
# Screenshot
177160
chrome_options = Options()
178161
chrome_options.add_argument("--headless")
179162
chrome_options.add_argument("--no-sandbox")
@@ -187,5 +170,4 @@
187170
driver.save_screenshot("plot.png")
188171
driver.quit()
189172

190-
# Clean up temp file
191173
Path(temp_path).unlink()

plots/candlestick-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: candlestick-basic
33
created: '2025-12-23T10:02:49Z'
4-
updated: '2025-12-23T10:05:12Z'
5-
generated_by: claude-opus-4-5-20251101
4+
updated: '2026-02-24T20:50:21+00:00'
5+
generated_by: claude-opus-4-6
66
workflow_run: 20457533754
77
issue: 0
8-
python_version: 3.13.11
9-
library_version: unknown
8+
python_version: "3.14.3"
9+
library_version: "1.10.3"
1010
preview_url: https://storage.googleapis.com/pyplots-images/plots/candlestick-basic/highcharts/plot.png
1111
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/candlestick-basic/highcharts/plot_thumb.png
1212
preview_html: https://storage.googleapis.com/pyplots-images/plots/candlestick-basic/highcharts/plot.html
13-
quality_score: 92
13+
quality_score: null
1414
impl_tags:
1515
dependencies:
1616
- selenium

0 commit comments

Comments
 (0)