Skip to content

TimeSeriesPlot

Multi-line time series chart with event markers and dual Y-axes.

Demo

Usage

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

<TimeSeriesPlot data={timeSeriesData} width={600} height={350} />

Data Type — TimeSeriesData

FieldTypeRequiredDescription
seriesTimeSeriesLine[]yesData series
eventsTimeSeriesEvent[]noEvent markers
xLabelstringnoX-axis label

Props

PropTypeDefaultDescription
dataTimeSeriesDataPrimary data prop
widthnumber600SVG width
heightnumber350SVG height

Example — Constructing Data

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

const data: TimeSeriesData = {
  series: [{
    name: 'OD600',
    x: Array.from({ length: 25 }, (_, i) => i),
    y: Array.from({ length: 25 }, (_, i) => {
      const growth = 0.05 * Math.exp(0.3 * Math.min(i, 12)) /
        (1 + (0.05 / 2.0) * (Math.exp(0.3 * Math.min(i, 12)) - 1));
      return growth + Math.sin(i * 0.5) * 0.02;
    }),
    unit: 'OD600',
  }],
  events: [
    { time: 5, label: 'IPTG induction', color: '#d45858' },
  ],
  xLabel: 'Time (hr)',
};

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