# Minigráfico

> Un gráfico de líneas diminuto para tendencias. Un componente nativo de Pyzed para GUIs de escritorio en Python, con vista previa, ejemplos y su API.

Source: https://albakore.github.io/pyzed/es/library/sparkline/

:::tip[En pocas palabras]
Un gráfico de líneas diminuto que muestra si algo sube o baja.
:::

Un gráfico de líneas pequeño, relleno bajo la línea por defecto, que muestra la forma de una serie.

`ui.sparkline` · Categoría: [Datos](https://albakore.github.io/pyzed/es/library/#datos) · [Referencia completa →](https://albakore.github.io/pyzed/es/reference/ui/#sparkline)

**Código:**

```python
pz.column([
    ui.sparkline([1, 4, 2, 6, 3, 7, 5, 8], width=240, height=48),
    ui.sparkline([8, 6, 7, 4, 5, 3, 2, 1], width=240, height=48, tint="error", fill=False),
], spacing=16)
```

## Cuándo usarlo

- En línea junto a un número o en una celda, cuando importa más la tendencia que los valores.

## Uso

```python
import pyzed as pz
from pyzed import ui

pz.column([
    ui.sparkline([1, 4, 2, 6, 3, 7, 5, 8], width=240, height=48),
    ui.sparkline([8, 6, 7, 4, 5, 3, 2, 1], width=240, height=48, tint="error", fill=False),
], spacing=16)
```

## Variantes

:::note[Sobre estas capturas]
Cada captura la graba pyzed mismo, fuera de pantalla a 2x, en One Dark o One Light según el tema de este sitio, y recortada al componente para que se vea a su tamaño real. El puntero pasa por encima, pulsa o escribe en él; un componente que no reacciona al puntero recorre algunos temas. Con movimiento reducido ves el primer fotograma. Abre **Código** bajo una captura para ver el fragmento que la dibuja; los nombres libres como `on_save` son tus propios callbacks.
:::

### Opciones

```python
ui.sparkline([1, 4, 2, 6, 3, 7, 5, 8], width=200, height=40)
```

```python
ui.sparkline([1, 4, 2, 6, 3, 7, 5, 8], width=200, height=40, fill=False)
```

```python
ui.sparkline([8, 6, 7, 4, 5, 3, 2, 1], width=200, height=40, tint="error")
```

```python
ui.sparkline([2, 3, 3, 5, 6, 8, 9, 12], width=200, height=40, tint="success")
```

### Tamaño

```python
ui.sparkline([3, 5, 2, 6, 4, 7], width=80, height=20)
```

```python
ui.sparkline([3, 5, 2, 6, 4, 7, 5, 9, 6, 8], width=280, height=64)
```

## Eventos

Minigráfico no tiene eventos propios: muestra lo que le das. Como todo widget, también tiene los **18 eventos comunes** (`click`, `double_click`, `right_click`, `mouse_enter`, `drag`, `key_down`, `resize`…), que se conectan con `.on(...)`: mira [Eventos](https://albakore.github.io/pyzed/es/guides/events/) y [Eventos de cada componente](https://albakore.github.io/pyzed/es/library/events/).

## Propiedades y API

### `ui.sparkline`

```python
sparkline(values, *, width=120, height=32, tint='accent', fill=True, theme=None)
```

Un gráfico de línea diminuto para tendencias.

| Propiedad | Por defecto | Descripción |
| --- | --- | --- |
| `values` | *obligatorio* | Valores. |
| `width` | `120` | Ancho: píxeles, `"fill"`, `"shrink"` o `"fill:N"` (proporción). |
| `height` | `32` | Alto: píxeles, `"fill"`, `"shrink"` o `"fill:N"` (proporción). |
| `tint` | `"accent"` | Color semántico: `"accent"`, `"error"`, `"warning"`, `"success"`, `"info"` o un token. |
| `fill` | `True` | Rellena el área bajo la línea. |
| `theme` | `None` | Tema a usar en lugar del actual (`pyzed.theme.current()`). |

[Referencia completa →](https://albakore.github.io/pyzed/es/reference/ui/#sparkline)

## Relacionados

- [Cifra](https://albakore.github.io/pyzed/es/library/stat/): Una cifra de dashboard con variación y minigráfico.
- [Gráfico de barras](https://albakore.github.io/pyzed/es/library/bar-chart/): Un gráfico de barras verticales con etiquetas.
