docs/api-reference/widgets/stats-widget.md
import {StatsWidgetDemo} from '@site/src/doc-demos/widgets'; import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';
<StatsWidgetDemo />Displays performance and debugging statistics from deck.gl, luma.gl, or custom probe.gl stats objects in a collapsible widget. When collapsed, it shows the current FPS in a compact button UI.
<Tabs groupId="language"> <TabItem value="js" label="JavaScript">import {Deck} from '@deck.gl/core';
import {_StatsWidget as StatsWidget} from '@deck.gl/widgets';
import '@deck.gl/widgets/stylesheet.css';
new Deck({
widgets: [
new StatsWidget({initialExpanded: true})
]
});
import {Deck} from '@deck.gl/core';
import {_StatsWidget as StatsWidget} from '@deck.gl/widgets';
import '@deck.gl/widgets/stylesheet.css';
new Deck({
widgets: [
new StatsWidget({initialExpanded: true})
]
});
import React from 'react';
import DeckGL, {_StatsWidget as StatsWidget} from '@deck.gl/react';
import '@deck.gl/widgets/stylesheet.css';
function App() {
return (
<DeckGL>
<StatsWidget initialExpanded />
</DeckGL>
);
}
import React, {useState} from 'react';
import DeckGL, {_StatsWidget as StatsWidget} from '@deck.gl/react';
import '@deck.gl/widgets/stylesheet.css';
function App() {
const [expanded, setExpanded] = useState(true);
return (
<DeckGL>
<StatsWidget
expanded={expanded}
onExpandedChange={setExpanded}
/>
</DeckGL>
);
}
import {_StatsWidget as StatsWidget, type StatsWidgetProps} from '@deck.gl/widgets';
new StatsWidget({} satisfies StatsWidgetProps);
StatsWidgetProps {#statswidgetprops}The StatsWidget accepts the generic WidgetProps and:
Type of stats to display. One of 'deck', 'luma', 'device', or 'custom'.
'deck'A Stats instance to display when using type: 'custom'.
Title shown in the widget header.
'Stats'If true, the UI is expanded at start.
falseNumber of frames to wait between refresh.
1Custom formatters for stat values.
Whether to reset particular stats after each update.
Controlled expanded state. When provided, the widget is in controlled mode and initialExpanded is ignored.
Callback when the expanded state changes (user clicks header). In controlled mode, use this to update the expanded prop.
'count' - Display raw count value'averageTime' - Format as average time in ms/s'totalTime' - Format as total time in ms/s'fps' - Format as frames per second'memory' - Format as memory in MBframesPerUpdate'deck': deck.gl rendering statistics'luma': luma.gl WebGL statistics'device': GPU device statistics'custom': User-provided stats object