Fix stock display layout: Increase width and fix chart data processing

This commit is contained in:
ChuckBuilds
2025-04-11 13:17:12 -05:00
parent 50abd3057f
commit 8663ca6234

View File

@@ -515,7 +515,7 @@ class StockManager:
PIL Image of the stock display PIL Image of the stock display
""" """
# Create a wider image for scrolling # Create a wider image for scrolling
width = self.display_manager.matrix.width * 2 width = self.display_manager.matrix.width * 3 # Increased from 2x to 3x for more space
height = self.display_manager.matrix.height height = self.display_manager.matrix.height
image = Image.new('RGB', (width, height), color=(0, 0, 0)) image = Image.new('RGB', (width, height), color=(0, 0, 0))
draw = ImageDraw.Draw(image) draw = ImageDraw.Draw(image)
@@ -573,9 +573,12 @@ class StockManager:
draw.text((change_x, change_y), change_text, font=small_font, fill=change_color) draw.text((change_x, change_y), change_text, font=small_font, fill=change_color)
# Draw mini chart on the right # Draw mini chart on the right
if symbol in self.stock_data and 'chart_data' in self.stock_data[symbol]: if symbol in self.stock_data and 'price_history' in self.stock_data[symbol]:
chart_data = self.stock_data[symbol]['chart_data'] price_history = self.stock_data[symbol]['price_history']
if len(chart_data) >= 2: # Need at least 2 points to draw a line if len(price_history) >= 2: # Need at least 2 points to draw a line
# Extract prices from price history
chart_data = [p['price'] for p in price_history]
# Calculate chart dimensions # Calculate chart dimensions
chart_width = width // 4 chart_width = width // 4
chart_height = height // 2 chart_height = height // 2