生物信息学 · katucharts.js/bio

Kaplan-Meier生存曲线

type: 'kaplanmeier'

生存曲线(阶跃函数),可选置信区间、删失标记、风险表和中位生存线。

编辑右侧的JSON并按Run(或⌘/Ctrl + Enter)——数据、标题、类别和颜色全部实时更新。

实时
Kaplan-Meier生存曲线
编辑 · JSON

数据格式

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

数据结构

传入图表的 JSON——可直接放进你的 series。

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

示例

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

类型特定选项

选项描述
showConfidenceInterval绘制CI阴影区域。
showCensorMarks删失观察的刻度线。
showAtRiskTable / medianSurvivalLine风险计数 / 中位线。

变体

置信区间带与删失

为置信区间区域着色,并用刻度标记删失观测。

KatuCharts.chart('container', {
  series: [{
    type: 'kaplanmeier', name: '处理 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.
通用选项(color、visible、marker、dataLabels、animation、events、zones…)适用于每个类型——请参阅配置→series。在图库中查看其渲染。