Cartesiano
Linha
type: 'line'Gráfico de linha padrão conectando pontos de dados com segmentos retos. Suporta marcadores, rótulos de dados, zonas, cor negativa, interpolação por passos e estilos tracejados.
Edite o JSON à direita e pressione Executar (ou ⌘/Ctrl + Enter) — dados, títulos, categorias e cores se atualizam ao vivo.
Ao Vivo
Linha
Editar · JSON
Formato de dados
[10, 20, 30] · [[0,10],[1,20]] · [{ x: 0, y: 10 }]
Estrutura de dados
O JSON que você passa dentro do gráfico — coloque direto na sua series.
series: [
{ name: 'Online', data: [42, 48, 55, 51, 63, 71] },
{ name: 'Na Loja', data: [31, 34, 30, 37, 39, 44] }
]Exemplo
import KatuCharts from 'katucharts.js';
KatuCharts.chart('container', {
chart: { type: 'line' },
xAxis: { categories: ['Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun'] },
series: [
{ name: 'Online', data: [42, 48, 55, 51, 63, 71] },
{ name: 'Na Loja', data: [31, 34, 30, 37, 39, 44], dashStyle: 'Dash' }
]
});Opções específicas do tipo
| Opção | Descrição |
|---|---|
lineWidth | Largura do traço (padrão 2). |
dashStyle | 'Solid', 'Dash', 'Dot', 'DashDot', … |
marker | Marcadores de pontos — { symbol, radius, enabled }. |
connectNulls | Preencha lacunas de valores nulos. |
negativeColor | Cor para valores abaixo do limite. |
zones | Coloração por intervalo com base no valor. |
step | 'left' | 'center' | 'right' interpolação por passos. |
Variações
Marcadores e estilos de traço
Ative os marcadores por série e use dashStyle para diferenciar as linhas.
KatuCharts.chart('container', {
chart: { type: 'line' },
series: [
{ name: 'Online', data: [42, 48, 55, 51, 63, 71], marker: { enabled: true } },
{ name: 'Na Loja', data: [31, 34, 30, 37, 39, 44], dashStyle: 'Dash' }
]
});Linha em degraus com zonas
Interpolação em degraus com zonas por valor que recolorem a linha ao cruzar um limite.
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 linha 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 linha chart in JavaScript?
- Install with `npm install katucharts.js`, then call KatuCharts.chart(container, { chart: { type: 'line' }, series: [...] }).
- Why does my linha 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.
Opções comuns (color, visible, marker, dataLabels, animation, events, zones…) se aplicam a cada tipo — veja Configuração → series. Veja renderizado na galeria.