semvec/pypi-packages huggingface dataset:
survival-curve 0.0.7
Reusable React-based UI for Dash apps that computes and plots a Kaplan-Meier curve entirely using raw event and time-to-event data passed from Dash app. It eliminatevival analysis libraries, making it lightweight and frontend-driven.
License: MIT

# SurvivalCurve Dash Component

Dash component built with React to render **Kaplan–Meier survival curves** with enhanced interactivity and styling options. This component is ideal for visualizing survival analysis data directly within Dash applications.

## Features

- Plot Kaplan–Meier survival curves from preprocessed data.
- Support for multiple curves with different group labels.
- Interactive tooltips and hover effects.
- Customizable colors and dimensions.
- Fully integrated with Dash callback system.

## Installation

```bash
pip install survival-curve
````

## Install requirements

```bash
pip install dash
pip install lifelines
```

## Usage

Here’s how to use the `SurvivalCurve` component in your Dash app:

```python
import dash
from dash import html, Dash
import survival_curve as sc
from survival_curve.survival_stats import compute_survival_stats

# Example data
time = [your time values list here]
event = [your event values list here]
group = [you rgroup values list here]

stats = compute_survival_stats(time ,event, group)

app = Dash(__name__)

app.layout = html.Div([
    sc.SurvivalCurve(
        id='km-example',
        time=time,
        event=event,
        group=group,
        showCIs=True,
        colors=['blue', 'green', 'red'],
        showStatistics=True,
        logrankP=stats["logrank_p"],
        coxP=stats["cox_p"],
        hazardRatio=stats["hazard_ratio"],
        layout={
            'title': 'Kaplan-Meier Survival Curve Example',
            'xaxis': {'title': 'Time'},
            'yaxis': {'title': 'Survival Probability'}
        },
        title="Kaplan-Meier curves",
        config={'responsive': True}
    )
])

if __name__ == '__main__':
    app.run(debug=True)

```

## Plot Example

![Survival Example](https://github.com/XLlobet/survival-curve/blob/main/survival.png?raw=true)

## License

MIT License. See `LICENSE` file for details.