Skip to Content

Reference

Sizing

Choose a fixed box or an embed that grows with its content, and follow its height.

sizing-mode on <dbn-dashboard> or <dbn-metric> sets where the height comes from:

sizing-mode and dbn-height-change require plugin {{PLUGIN_VERSION}} or later.

ValueHeightWho scrolls
fixedThe box your page gives the element. This is the default.The embed
autoThe height of the content. The element ignores a height you set on it.Your page

An empty or unknown value means fixed. The width always comes from your page.

In auto mode the element sends dbn-height-change once after the first layout, then each time its height changes. event.detail.height is the height in CSS px, rounded up. The event bubbles and leaves the shadow root.

<dbn-dashboard
  token="GUEST_TOKEN"
  dashboard-id="DASHBOARD_ID"
  sizing-mode="auto"
></dbn-dashboard>
<script>
  document
    .querySelector('dbn-dashboard')
    .addEventListener('dbn-height-change', (event) => {
      console.log('embed height', event.detail.height);
    });
</script>

If the embed runs in an iframe, send the height to the parent page and set the iframe height there:

// In the page inside the iframe
document.querySelector('dbn-dashboard').addEventListener('dbn-height-change', (event) => {
  window.parent.postMessage({ type: 'dbn-height', height: event.detail.height }, 'https://app.example.com');
});

// In the parent page
const frame = document.querySelector('#analytics-frame');
window.addEventListener('message', (event) => {
  if (!frame || event.source !== frame.contentWindow) return;
  if (event.origin !== 'https://embed.example.com' || event.data?.type !== 'dbn-height') return;
  const { height } = event.data;
  if (typeof height !== 'number' || !Number.isFinite(height) || height < 0) return;
  frame.style.height = `${height}px`;
});

Put the embed in a flex layout

In a column flex layout, flex: 1 alone makes the embed as tall as the whole dashboard, so it spills past the rows below it. A flex item is never shorter than its content unless you say so. Add min-height: 0:

.app-main {
  display: flex;
  flex-direction: column;
  height: 100vh;            /* or any set height */
}
.app-main dbn-dashboard {
  flex: 1;
  min-height: 0;            /* the embed takes the free space and scrolls inside */
}

If the embed is inside your own wrapper, put flex: 1; min-height: 0 on the wrapper, and display: block; height: 100% on <dbn-dashboard>.

With sizing-mode="auto" the embed is as tall as its content and your page scrolls. Put the scroll on the parent: overflow-y: auto on .app-main.

The flex CSS also works for embeds that use fixed sizing on older plugins. It adjusts when a header or banner changes height.

The metric builder

sizing-mode does not size the metric builder. It opens over your page, fills the window and scrolls inside. With the shouldFitFullScreen option it fills the embed box instead.

If you already set options.metricEditorPreviewHeight, you can keep it when upgrading to {{PLUGIN_VERSION}}. Its optional minHeight and maxHeight accept CSS lengths such as 360px and 600px. The bounds apply to the Chart and Table preview in the dashboard SDK and React metric builder, in both legacy and v2. Omit both to use the builder’s default sizing.

Minimum and maximum height for embeds and cards

Use the host layout to size the embed. Inside a card, the chart keeps its space and the title, filters and legend give way first. Not supported, and why has the sizing choices for embeds and cards.