Linha do Tempo
type: 'timeline'Marcadores de evento sequenciais dispostos ao longo de uma linha; cada ponto é um marco com nome, um rótulo curto e uma descrição opcional exibida na dica. Horizontal por padrão, vertical quando chart.inverted é definido.
Edite o JSON à direita e pressione Executar (ou ⌘/Ctrl + Enter) — dados, títulos, categorias e cores se atualizam ao vivo.
Formato de dados
Estrutura de dados
O JSON que você passa dentro do gráfico — coloque direto na sua series.
data: [
{ name: 'Founded', label: '2019', description: 'First prototype shipped.' },
{ name: 'Series A', label: '2022', description: '$15M raised; team of 40.' },
{ name: 'v1.0', label: '2024', description: 'General availability launch.' }
]Exemplo
import KatuCharts from 'katucharts.js';
KatuCharts.chart('container', {
chart: { type: 'timeline' },
series: [{
data: [
{ name: 'Founded', label: '2019', description: 'First prototype shipped.' },
{ name: 'Series A', label: '2022', description: '$15M raised; team of 40.' },
{ name: 'v1.0', label: '2024', description: 'General availability launch.' }
]
}]
});Opções específicas do tipo
| Opção | Descrição |
|---|---|
dataLabels.format | Modelo de rótulo por ponto, ex.: '<b>{point.name}</b><br>{point.label}'. |
dataLabels.alternate | Alterna os rótulos nos dois lados da linha (padrão true). |
dataLabels.distance | Distância entre o marcador e seu rótulo (padrão 22). |
chart.inverted | Dispõe a linha do tempo na vertical em vez de horizontal. |
marker | Marcador por ponto — { symbol, radius, lineColor, lineWidth }. |
colorByPoint | Colore cada marcador a partir da paleta (padrão true). |
Variações
Vertical (invertido)
Defina chart.inverted para dispor a linha do tempo na vertical — ideal para colunas estreitas e históricos de formação.
KatuCharts.chart('container', {
chart: { type: 'timeline', inverted: true },
series: [{
data: [
{ name: "Bachelor's", label: '2006 – 2008', description: 'Computer Networks — FAZ, Brazil' },
{ name: "Master's", label: '2014 – 2016', description: 'Computer Science — UFPA, Brazil' },
{ name: 'Doctorate', label: '2018 – 2022', description: 'Artificial Intelligence — USP, Brazil' }
]
}]
});Descrições na dica
Dê uma descrição a cada ponto e ela aparece na dica ao passar o mouse, mantendo os rótulos curtos.
KatuCharts.chart('container', {
chart: { type: 'timeline' },
tooltip: { pointFormat: '{point.description}' },
series: [{
data: [
{ name: 'Founded', label: '2019', description: 'First prototype shipped.' },
{ name: 'Series A', label: '2022', description: '$15M raised; team of 40.' },
{ name: 'v1.0', label: '2024', description: 'General availability launch.' }
]
}]
});Rótulos de um lado só
Defina dataLabels.alternate como false para manter todos os rótulos do mesmo lado da linha.
KatuCharts.chart('container', {
chart: { type: 'timeline' },
series: [{
dataLabels: { alternate: false },
data: [
{ name: 'v1.0', label: 'Jan' },
{ name: 'v1.5', label: 'Abr' },
{ name: 'v2.0', label: 'Ago' },
{ name: 'v2.4', label: 'Nov' }
]
}]
});Rótulos simples (marcadores redondos)
Defina dataLabels.borderWidth como 0 para remover a caixa e deixar marcadores redondos maiores conduzirem a linha do tempo.
KatuCharts.chart('container', {
chart: { type: 'timeline' },
series: [{
marker: { radius: 9 },
dataLabels: { borderWidth: 0 },
data: [
{ name: 'Discovery', label: 'T1' },
{ name: 'Design', label: 'T2' },
{ name: 'Build', label: 'T3' },
{ name: 'Launch', label: 'T4' }
]
}]
});Common errors
- Why does my linha do tempo 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 do tempo chart in JavaScript?
- Install with `npm install katucharts.js`, then call KatuCharts.chart(container, { chart: { type: 'timeline' }, series: [...] }).
- Why does my linha do tempo 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.