Skip to main content

ChartPopover

The ChartPopover component defines the popover that will appear when the user selects a mark on the chart. ChartPopover must be used as a child of Area, Bar, Line, or AxisAnnotation. You should only have one popover defined per Chart visualization.

You can add interactive elements like buttons to the popover.

The ChartPopover uses the React Spectrum Dialog. Follow the React Spectrum documentation to properly setup your dialog content.

<Chart data={data} >
<Bar>
<ChartPopover>
{(datum, close) => (
<Content>
<Text>Average: {datum.average}</Text>
<ActionButton onPress={close}>Close</ActionButton>
</Content>
)}
</ChartPopover>
</Bar>
</Chart>

Props

nametypedefaultdescription
children*(datum: Datum, close: () => void) => ReactElementSets what is displayed by the popover. Supplies the datum for the value(s) that is currently selected and a close event handler. Function should return a ReactElement which will be the content of the popover.
widthnumber | 'auto'Sets the width of the popover. auto will fit the contents plus any padding.
minWidthnumber0Sets the minimum width of the popover in pixels.
maxWidthnumberSets the maximum width of the popover in pixels.
heightnumber | 'auto''auto'Sets the height of the popover. auto will fit the contents plus any padding.
minHeightnumberSets the minimum height of the popover in pixels.
maxHeightnumberSets the maximum height of the popover in pixels.
containerPaddingnumber12The placement padding that should be applied between the popover and its surrounding container.
See React Spectrum docs
onOpenChange(isOpen: boolean) => voidHandler that is called when the popover's open state changes.