Skip to content

CompositionChart

Nucleotide/amino acid composition pie chart with GC content donut.

Demo

Usage

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

<CompositionChart data={compositionData} width={300} height={300} />

Data Type — CompositionData

FieldTypeRequiredDescription
countsRecord<string, number>yese.g. { A: 100, T: 95, G: 110, C: 105 }
alphabetAlphabetno'dna' | 'rna' | 'protein'
gcnumbernoGC content (0–1)
lengthnumbernoTotal sequence length

Props

PropTypeDefaultDescription
dataCompositionDataPrimary data prop
widthnumberSVG width
heightnumberSVG height

Example — Constructing Data

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

const data: CompositionData = {
  counts: { A: 58, T: 42, G: 55, C: 48 },
  alphabet: 'dna',
  gc: 0.507,
  length: 203,
};

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