Cartesiano
Área
type: 'area'Área rellena bajo una línea. Compatible con apilamiento normal y porcentual, color de relleno negativo y hover por área.
Edita el JSON a la derecha y presiona Ejecutar (o ⌘/Ctrl + Intro) — los datos, títulos, categorías y colores se actualizan en vivo.
En Vivo
Área
Editar · JSON
Formato de datos
igual que línea
Estructura de datos
El JSON que pasas dentro del gráfico — colócalo directamente en tu series.
series: [
{ name: 'Free', data: [120, 260, 410, 600] }
]Ejemplo
import KatuCharts from 'katucharts.js';
KatuCharts.chart('container', {
chart: { type: 'area' },
series: [{ name: 'Free', data: [120, 260, 410, 600], fillOpacity: 0.3 }]
});Opciones específicas del tipo
| Opción | Descripción |
|---|---|
fillOpacity | Opacidad del relleno de área (predeterminado 0,75). |
fillColor | Anula el color de relleno. |
negativeFillColor | Relleno por debajo del umbral. |
stacking | 'normal' o 'percent'. |
trackByArea | El hover se activa en el área, no solo en la línea. |
Variaciones
Apilado porcentual
Apila las series al 100% para comparar la composición a lo largo del tiempo.
KatuCharts.chart('container', {
chart: { type: 'area' },
plotOptions: { area: { stacking: 'percent' } },
series: [
{ name: 'Escritorio', data: [450, 520, 480, 610, 580] },
{ name: 'Móvil', data: [280, 350, 420, 510, 620] }
]
});Relleno por umbral negativo
Rellena por debajo de un umbral con un negativeColor distinto.
KatuCharts.chart('container', {
chart: { type: 'area' },
series: [{
data: [-12, -6, 4, 10, -3, 14, 22, 18],
threshold: 0,
negativeColor: '#B43417'
}]
});Relleno degradado
Desvanece el relleno del área con un linearGradient vertical pasado en fillColor.
KatuCharts.chart('container', {
chart: { type: 'area' },
series: [{
name: 'Usuarios',
data: [320, 410, 380, 520, 610, 700, 540],
fillColor: {
linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
stops: [[0, 'rgba(45,133,116,0.4)'], [1, 'rgba(45,133,116,0)']]
}
}]
});Common errors
- Why does my área chart render as a line chart?
- The chart type was not registered. KatuCharts logs "KatuCharts: unknown series type "<type>", falling back to line" and draws a line chart rather than throwing. Import the module the type belongs to — for example `import 'katucharts.js/bio';` — before creating the chart.
- Why do I get "Cannot read properties of null (reading 'appendChild')"?
- The container element does not exist when the chart is created. Create the chart after the element is in the DOM: in React that means inside useEffect, not during render.
- Why is the chart rendering with zero height?
- The container has no height. A div with no content collapses to zero. Give it a height in CSS, or pass `chart: { height: 400 }` in the options.
FAQ
- How do I create a área chart in JavaScript?
- Install with `npm install katucharts.js`, then call KatuCharts.chart(container, { chart: { type: 'area' }, series: [...] }).
- Why does my área chart render as a line chart?
- The chart type was not registered. KatuCharts logs "KatuCharts: unknown series type "<type>", falling back to line" and draws a line chart rather than throwing. Import the module the type belongs to — for example `import 'katucharts.js/bio';` — before creating the chart.
- Why do I get "Cannot read properties of null (reading 'appendChild')"?
- The container element does not exist when the chart is created. Create the chart after the element is in the DOM: in React that means inside useEffect, not during render.
- Why is the chart rendering with zero height?
- The container has no height. A div with no content collapses to zero. Give it a height in CSS, or pass `chart: { height: 400 }` in the options.
Las opciones comunes (color, visible, marker, dataLabels, animation, events, zones…) se aplican a todos los tipos — véase Configuración → series. Míralo renderizado en la galería.