Bioinformática · katucharts.js/bio

Kaplan-Meier

type: 'kaplanmeier'

Curva de sobrevida (função de passo) com intervalos de confiança opcionais, marcas de censura, uma tabela de risco e uma linha de sobrevida mediana.

Edite o JSON à direita e pressione Executar (ou ⌘/Ctrl + Enter) — dados, títulos, categorias e cores se atualizam ao vivo.

Ao Vivo
Kaplan-Meier
Editar · JSON

Formato de dados

{ x: time, y: survivalProb, custom?: { atRisk, ciLower, ciUpper, censored? } }

Estrutura de dados

O JSON que você passa dentro do gráfico — coloque direto na sua series.

data: [
  { x: 0, y: 1.0 },
  { x: 6, y: 0.88 },
  { x: 12, y: 0.75 },
  { x: 18, y: 0.62 }
]

Exemplo

KatuCharts.chart('container', {
  series: [{ type: 'kaplanmeier', name: 'Tratamento A',
    data: [{ x: 0, y: 1 }, { x: 6, y: 0.88 }, { x: 12, y: 0.75 }] }]
});

Opções específicas do tipo

OpçãoDescrição
showConfidenceIntervalDesenhe a região IC sombreada.
showCensorMarksMarcas de tick para observações censuradas.
showAtRiskTable / medianSurvivalLineContagens de risco / linha mediana.

Variações

Banda de confiança e censura

Sombreie a região de IC e marque as observações censuradas com ticks.

KatuCharts.chart('container', {
  series: [{
    type: 'kaplanmeier', name: 'Tratamento A',
    showConfidenceInterval: true,
    showCensorMarks: true,
    data: [
      { x: 0, y: 1 },
      { x: 6, y: 0.88, custom: { ciLower: 0.8, ciUpper: 0.95, censored: true } }
    ]
  }]
});

Common errors

Why does my kaplan-meier 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 kaplan-meier chart in JavaScript?
Install with `npm install katucharts.js`, import the module with `import 'katucharts.js/bio';`, then call KatuCharts.chart(container, { chart: { type: 'kaplanmeier' }, series: [...] }).
Does KatuCharts compute the Kaplan-Meier curve, or do I supply it?
You supply it. Pass the estimate as step points { x: time, y: survival probability }, computed with your statistics tool (for example R's survival::survfit). Add custom.ciLower and custom.ciUpper for the confidence band and custom.censored: true for censoring marks.
Is the number-at-risk table included?
It is opt-in. Set showAtRiskTable: true on the series and give each point a custom.atRisk count; the counts are drawn under the plot.
Which Kaplan-Meier options are available?
showConfidenceInterval and showCensorMarks (both on by default), confidenceIntervalOpacity, censorMarkSize, medianSurvivalLine and showAtRiskTable.
Why does my kaplan-meier 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.
Opções comuns (color, visible, marker, dataLabels, animation, events, zones…) se aplicam a cada tipo — veja Configuração → series. Veja renderizado na galeria.