Improve chart visibility: Added checks and increased line width

This commit is contained in:
ChuckBuilds
2025-04-11 12:33:55 -05:00
parent 15eb63a634
commit caccf129f1

View File

@@ -357,7 +357,7 @@ class StockManager:
# Draw mini chart on the right # Draw mini chart on the right
chart_width = 30 # Increased from 20 to 30 chart_width = 30 # Increased from 20 to 30
chart_height = 32 # Increased from 32 to match text height chart_height = 32 # Increased from 32 to match text height
chart_x = scroll_width - chart_width - 5 # Shift one width to the right (using scroll_width instead of width) chart_x = scroll_width - chart_width - 5 # Shift one width to the right
chart_y = 0 # Align with top of display chart_y = 0 # Align with top of display
# Draw chart background # Draw chart background
@@ -366,9 +366,10 @@ class StockManager:
# Get price history for chart # Get price history for chart
price_history = data.get('price_history', []) price_history = data.get('price_history', [])
if len(price_history) >= 2: # Need at least 2 points to draw a line if price_history and len(price_history) >= 2: # Need at least 2 points to draw a line
# Extract prices from price history # Extract prices from price history
prices = [p['price'] for p in price_history] prices = [p['price'] for p in price_history]
if prices: # Make sure we have prices
# Calculate price range with padding to avoid flat lines # Calculate price range with padding to avoid flat lines
min_price = min(prices) * 0.99 # 1% padding below min_price = min(prices) * 0.99 # 1% padding below
max_price = max(prices) * 1.01 # 1% padding above max_price = max(prices) * 1.01 # 1% padding above
@@ -387,9 +388,9 @@ class StockManager:
y = chart_y + chart_height - 1 - int((price - min_price) * (chart_height - 2) / price_range) y = chart_y + chart_height - 1 - int((price - min_price) * (chart_height - 2) / price_range)
points.append((x, y)) points.append((x, y))
# Draw the line # Draw the line with increased width for visibility
if len(points) >= 2: if len(points) >= 2:
draw.line(points, fill=color, width=1) draw.line(points, fill=color, width=2) # Increased line width
# Crop to show only the visible portion based on scroll position # Crop to show only the visible portion based on scroll position
visible_image = image.crop((scroll_position, 0, scroll_position + width, height)) visible_image = image.crop((scroll_position, 0, scroll_position + width, height))