Bioinformática · katucharts.js/bio
Kaplan-Meier
type: 'kaplanmeier'Curva de supervivencia (función escalonada) con intervalos de confianza opcionales, marcas de censura, una tabla de riesgo y una línea de supervivencia mediana.
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
Kaplan-Meier
Editar · JSON
Formato de datos
{ x: time, y: survivalProb, custom?: { atRisk, ciLower, ciUpper, censored? } }
Estructura de datos
El JSON que pasas dentro del gráfico — colócalo directamente en tu series.
data: [
{ x: 0, y: 1.0 },
{ x: 6, y: 0.88 },
{ x: 12, y: 0.75 },
{ x: 18, y: 0.62 }
]Ejemplo
KatuCharts.chart('container', {
series: [{ type: 'kaplanmeier', name: 'Tratamiento A',
data: [{ x: 0, y: 1 }, { x: 6, y: 0.88 }, { x: 12, y: 0.75 }] }]
});Opciones específicas del tipo
| Opción | Descripción |
|---|---|
showConfidenceInterval | Dibuja la región sombreada del IC. |
showCensorMarks | Marcas de verificación para observaciones censuradas. |
showAtRiskTable / medianSurvivalLine | Conteos de riesgo / línea mediana. |
Variaciones
Banda de confianza y censura
Sombrea la región de IC y marca las observaciones censuradas con ticks.
KatuCharts.chart('container', {
series: [{
type: 'kaplanmeier', name: 'Tratamiento 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.
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.