Cartesiano

Línea

type: 'line'

Gráfico de línea estándar que conecta puntos de datos con segmentos rectos. Compatible con marcadores, etiquetas de datos, zonas, color negativo e interpolación por pasos.

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
Línea
Editar · JSON

Formato de datos

[10, 20, 30] · [[0,10],[1,20]] · [{ x: 0, y: 10 }]

Estructura de datos

El JSON que pasas dentro del gráfico — colócalo directamente en tu series.

series: [
  { name: 'En Línea', data: [42, 48, 55, 51, 63, 71] },
  { name: 'En Tienda', data: [31, 34, 30, 37, 39, 44] }
]

Ejemplo

import KatuCharts from 'katucharts.js';

KatuCharts.chart('container', {
  chart: { type: 'line' },
  xAxis: { categories: ['Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun'] },
  series: [
    { name: 'En Línea', data: [42, 48, 55, 51, 63, 71] },
    { name: 'En Tienda', data: [31, 34, 30, 37, 39, 44], dashStyle: 'Dash' }
  ]
});

Opciones específicas del tipo

OpciónDescripción
lineWidthAncho de trazo (predeterminado 2).
dashStyle'Solid', 'Dash', 'Dot', 'DashDot', …
markerMarcadores de puntos — { symbol, radius, enabled }.
connectNullsCubre espacios de valores nulos.
negativeColorColor para valores por debajo del umbral.
zonesColoración por rango según el valor.
stepinterpolación por pasos 'left' | 'center' | 'right'.

Variaciones

Marcadores y estilos de trazo

Activa los marcadores por serie y usa dashStyle para distinguir las líneas.

KatuCharts.chart('container', {
  chart: { type: 'line' },
  series: [
    { name: 'En Línea', data: [42, 48, 55, 51, 63, 71], marker: { enabled: true } },
    { name: 'En Tienda', data: [31, 34, 30, 37, 39, 44], dashStyle: 'Dash' }
  ]
});

Línea escalonada con zonas

Interpolación escalonada con zonas por valor que recolorean la línea al cruzar un umbral.

KatuCharts.chart('container', {
  chart: { type: 'line' },
  series: [{
    data: [-6, -2, 4, 9, 16, 22], step: 'center',
    dataLabels: { enabled: true, format: '{point.y}°' },
    zones: [{ value: 0, color: '#2F6B5E' }, { color: '#B43417' }]
  }]
});

Common errors

Why does my línea 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 línea chart in JavaScript?
Install with `npm install katucharts.js`, then call KatuCharts.chart(container, { chart: { type: 'line' }, series: [...] }).
Why does my línea 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.