Skip to content

WaterfallPlot

Waterfall bar chart showing ranked contributions (e.g., tumor response, enrichment scores).

Demo

Usage

svelte
<script>
  import { WaterfallPlot } from '@molbiohive/hatchlings';
</script>

<WaterfallPlot data={waterfallData} width={500} height={350} />

Data Type — WaterfallData

FieldTypeRequiredDescription
barsWaterfallBar[]yesBar data

WaterfallBar

FieldTypeDescription
labelstringBar label
valuenumberBar value
categorystringOptional grouping
colorstringBar color

Props

PropTypeDefaultDescription
dataWaterfallDataPrimary data prop
widthnumberSVG width
heightnumberSVG height
sortDescendingbooleanSort bars

Example — Constructing Data

ts
import type { WaterfallData } from '@molbiohive/hatchlings';

const data: WaterfallData = {
  bars: [
    { label: 'Patient 1', value: -45, category: 'responder', color: '#4dc3ff' },
    { label: 'Patient 2', value: -38, category: 'responder', color: '#4dc3ff' },
    { label: 'Patient 3', value: -30, category: 'responder', color: '#4dc3ff' },
    { label: 'Patient 4', value: -22, category: 'partial', color: '#58b56a' },
    { label: 'Patient 5', value: -15, category: 'partial', color: '#58b56a' },
    { label: 'Patient 6', value: -8, category: 'stable', color: '#d9953a' },
    { label: 'Patient 7', value: 2, category: 'stable', color: '#d9953a' },
    { label: 'Patient 8', value: 12, category: 'progression', color: '#d45858' },
    { label: 'Patient 9', value: 25, category: 'progression', color: '#d45858' },
    { label: 'Patient 10', value: 40, category: 'progression', color: '#d45858' },
  ],
};

This is the data powering the demo above. See docs/data/charts.ts for the full source.