File size: 1,194 Bytes
2bc88b5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import io
from PIL import Image, ImageDraw, ImageFont

def create_placeholder_image():
    """Cria uma imagem placeholder simples com texto"""
    # Cores profissionais
    bg_color = (248, 250, 252)  # Slate-50
    text_color = (100, 116, 139)  # Slate-500
    
    img = Image.new('RGB', (800, 600), color=bg_color)
    draw = ImageDraw.Draw(img)
    
    # Carregar fonte
    try:
        font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 48)
    except:
        font = ImageFont.load_default()
    
    # Texto centralizado
    text = "Waiting for plot..."
    bbox = draw.textbbox((0, 0), text, font=font)
    text_width = bbox[2] - bbox[0]
    text_height = bbox[3] - bbox[1]
    
    x = (800 - text_width) // 2
    y = (600 - text_height) // 2
    
    draw.text((x, y), text, fill=text_color, font=font)
    
    return img

last_chart_image = None
PLACEHOLDER_IMAGE = create_placeholder_image()

def get_current_chart():
    """Retorna o gráfico atual ou placeholder"""
    global last_chart_image
    return last_chart_image if last_chart_image is not None else PLACEHOLDER_IMAGE