Skip to Content

React

Use @chirpier/charts when you want a React wrapper around the hosted Chirpier event runtime.

Install

npm install @chirpier/charts

Example

import { ChirpierChart } from "@chirpier/charts"; export function RevenueWidget() { return ( <ChirpierChart eventId="your-event-id" shareToken="your-share-token" range="1d" compare header={false} view="timeseries" variant="line" autoResize minHeight={320} /> ); }

Use bare <ChirpierChart /> markup by default. Wrap it only when your app needs host-specific layout such as a card, title, placeholder copy, or custom empty state.

Props reference

Required

PropTypeDescription
eventIdstringThe event definition ID
shareTokenstringShare token for public access

Chart state

PropTypeDefaultDescription
range"1h" | "1d" | "1w" | "1m""1h"Time range to display
aggregate"sum" | "average""sum"How values are aggregated
variant"line" | "bar""line"Chart rendering style
comparebooleanfalseShow previous-period overlay
headerbooleantrueShow the hosted event header
view"all" | "summary" | "timeseries" | "tracker""all"Which chart views to show

Tracker mode

PropTypeDefaultDescription
tracker.condition"gt" | "gte" | "lt" | "lte" | "eq""gt"Threshold comparison
tracker.thresholdnumber0Threshold value

Sizing

PropTypeDefaultDescription
autoResizebooleanfalseAuto-resize iframe based on content
resizeMode"auto" | "fixed" | "fill""auto"How the iframe dimensions are managed
widthnumber | stringFixed width
heightnumber | stringFixed height
minHeightnumber | stringMinimum height constraint
maxHeightnumber | stringMaximum height constraint
aspectRationumber | stringAspect ratio for responsive sizing

Appearance

PropTypeDefaultDescription
theme"light" | "dark" | "system""system"Color theme

Lifecycle hooks

PropTypeDescription
onRendered(event) => voidCalled when the chart finishes rendering
onResize(event) => voidCalled when the chart resizes
onError(error) => voidCalled on embed errors
onInteraction(event) => voidCalled when the user interacts with the chart

Ref methods

Use React.useRef<ChirpierChartRef>() to access imperative methods:

MethodDescription
ref.current.refresh()Reload the chart
ref.current.resize()Trigger a resize
ref.current.updateState(state)Update chart state programmatically
ref.current.updateTheme(theme)Switch color theme
ref.current.getIframe()Access the underlying iframe element

Good fit

Use this package when:

  • your app is already React-based
  • you want hosted charts without rebuilding chart logic locally
  • you want canonical Chirpier page behavior in-product

For lower-level control outside React, use Framework-Agnostic.

Last updated on