Pizza / Hierárquico
Sala de aula
type: 'classroom'Hemiciclo de assentos redondos — um por unidade do valor de cada categoria — dispostos em arcos concêntricos. Passar o mouse sobre um assento destaca sua categoria e esmaece as demais; clicar em um assento dispara um evento de ponto. Use o tipo 'item' com ângulos personalizados, ou 'classroom' para o hemiciclo ancorado na base.
Edite o JSON à direita e pressione Executar (ou ⌘/Ctrl + Enter) — dados, títulos, categorias e cores se atualizam ao vivo.
Ao Vivo
Sala de aula
Editar · JSON
Formato de dados
[{ name, y, color? }] · keys: ['name','y','label']
Estrutura de dados
O JSON que você passa dentro do gráfico — coloque direto na sua series.
data: [
{ name: 'Em risco', y: 3 },
{ name: 'Progredindo', y: 7 },
{ name: 'Indisponível', y: 6 }
]Exemplo
import KatuCharts from 'katucharts.js';
KatuCharts.chart('container', {
chart: { type: 'classroom' },
series: [{
cursor: 'pointer',
point: { events: { click: function () { openDetails(this.name); } } },
data: [
{ name: 'Em risco', y: 3 },
{ name: 'Progredindo', y: 7 },
{ name: 'Indisponível', y: 6 }
]
}]
});Opções específicas do tipo
| Opção | Descrição |
|---|---|
startAngle / endAngle | Amplitude do arco em graus (padrões da sala de aula -100 / 100). |
center / size / innerSize | Posição, tamanho geral e o centro vazado (ajuste automático quando size é omitido). |
rows / itemPadding | Fileiras fixas e o espaço entre assentos (fileiras automáticas se omitido). |
marker.radius | Raio fixo do assento; omita para dimensionar automaticamente (menos assentos → maiores). |
dataLabels | Rótulo por categoria, ex.: '{point.label} ({point.y})'. |
point.events.click | Clique por assento — abrir um modal ou uma página de detalhes. |
group | Renderiza cada dado como seu próprio assento, colorido e na legenda por grupo. |
Variações
Rótulos nos assentos
Mostra um rótulo curto e a contagem em cada bloco.
KatuCharts.chart('container', {
chart: { type: 'classroom' },
series: [{
keys: ['name', 'y', 'label'],
data: [['A Esquerda', 39, 'LEFT'], ['Verdes', 60, 'GRN'], ['Extrema-direita', 50, 'AFR']],
dataLabels: { enabled: true, format: '{point.label} ({point.y})' }
}]
});Assentos individuais
Um assento por aluno, agrupado e colorido por situação; passe o mouse para ver o nome e clique para abrir.
KatuCharts.chart('container', {
chart: { type: 'classroom' },
series: [{
cursor: 'pointer',
tooltip: { pointFormat: '{point.name}' },
point: { events: { click: function () { openStudent(this.name); } } },
data: [
{ name: 'Student 1', y: 1, group: 'Progredindo' },
{ name: 'Student 2', y: 1, group: 'Indisponível' }
]
}]
});Grade retangular
Remova os ângulos para uma grade de itens em linhas/colunas.
KatuCharts.chart('container', {
chart: { type: 'item' },
series: [{
layout: 'horizontal', rows: 5,
data: [
{ name: 'Satisfeito', y: 34 },
{ name: 'Neutro', y: 18 },
{ name: 'Insatisfeito', y: 10 }
]
}]
});Common errors
- Why does my sala de aula 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 sala de aula chart in JavaScript?
- Install with `npm install katucharts.js`, then call KatuCharts.chart(container, { chart: { type: 'classroom' }, series: [...] }).
- Why does my sala de aula 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.