PanelExtensionContext
type PanelExtensionContext = object;
The PanelExtensionContext exposes properties and methods for writing a custom panel. The
context has methods to subscribe for messages, receive updates, configure your panel's settings,
and render your panel to the UI.
The initPanel function used in
registerPanel accepts a PanelExtensionContext
argument. This argument contains properties and methods for accessing panel data and rendering UI
updates. The initPanel function also returns an optional cleanup function to run when the
extension panelElement unmounts.
See the Creating a custom panel guide for more details.
Properties
panelElement
readonly panelElement: HTMLDivElement;
The root element for the panel. Add your panel elements as children under this element.
initialState
readonly initialState: unknown;
Initial panel state
layout
readonly layout: LayoutActions;
Actions the panel may perform related to the user's current layout. See LayoutActions for details.
dataSourceProfile?
readonly optional dataSourceProfile: string;
Identifies the semantics of the data being played back, such as which topics or parameters are semantically meaningful or normalization conventions to use. This typically maps to a shorthand identifier for a robotics framework such as "ros1", "ros2", or "ulog". See the MCAP profiles concept at https://mcap.dev/spec/registry#profiles.
onRender()?
optional onRender: (renderState, done) => void;
Set this property to a function during your panel's initialization.
Foxglove will run context.onRender whenever your panel needs to re-render during playback.
The function accepts renderState and a done callback as its arguments. Render events occur
frequently (60hz, 30hz, etc).
Note: Your onRender function must call done after rendering to indicate that the
panel is ready to render the next set of data. The exact placement of this done invocation
will vary between frameworks and different extensions' logic.
context.onRender = (renderState, done) => {
// Render your UI updates with fields from RenderState
// Call done when you've rendered all the UI for this renderState.
// If your UI framework delays rendering, call done when rendering has actually happened.
done();
};
Parameters
| Parameter | Type |
|---|---|
renderState | Immutable<RenderState> |
done | () => void |
Returns
void
subscribeMessageRange()?
optional subscribeMessageRange: (args) => () => void;
Subscribe to receive the entire time range of messages for a given topic for the current data source.
See SubscribeMessageRangeArgs for more information on behavior.
Note: This will not read messages for live sources, like foxglove_bridge, rosbridge, or ROS 1
native connections. For those messages you will still need to use context.subscribe() and
watch("currentFrame").
Parameters
| Parameter | Type |
|---|---|
args | SubscribeMessageRangeArgs |
Returns
A function that will unsubscribe from the topic, cancel the active async iterator, and prevent onNewRangeIterator from being called again.
(): void;
Returns
void
UNSTABLE_subscribeMessageRange()?
optional UNSTABLE_subscribeMessageRange: (args) => () => void;
Parameters
| Parameter | Type |
|---|---|
args | SubscribeMessageRangeArgs |
Returns
(): void;
Returns
void
Deprecated
Renamed to subscribeMessageRange. Please use that method instead.