DocumentationCharts

Full-Height Angular Charts

Every chart except the pie and donut charts supports heightFull. When it's on, height is no longer a fixed size. It becomes a minimum: the chart grows to fill its container whenever the container is taller, and keeps filling it as the container is resized.

Try It

Both charts below use the same config (height: 200) and the same container. The only difference is heightFull. Drag the slider to change the height of the containers.

360px

heightFull: false

Stays 200px tall

heightFull: true

Fills the container

Below 200px, the two charts look the same. There's no extra space to fill, so heightFull falls back to the height minimum. Both charts stay 200px tall, and the container clips them instead of squeezing them.

Fill A Flex Layout

The container doesn't need an explicit height. Any definite height works, including one set by a flex or grid layout. That covers the most common case: a card with a header on top and a chart that fills the rest of the space.

Requests Per Minute

Last 24 hours

<!-- A dashboard card: the header takes the space it needs, and the chart fills the rest. -->
<mat-card class="flex flex-col" style="height: 360px">
  <h5>Requests per minute</h5>
  <p>Last 24 hours</p>

  <div class="flex-1 min-h-0">
    <pcac-line-chart [config]="config" />
  </div>
</mat-card>

Markup

<!-- The wrapper sets the height, and the chart fills it. -->
<div style="height: 360px">
  <pcac-bar-vertical-chart [config]="config" />
</div>
const config = {
  data: [ ... ],

  // Minimum height. Used as-is when the container is shorter than this.
  height: 200,

  // Grow past 'height' to fill the container when it's taller.
  heightFull: true
} as PcacBarVerticalChartConfig;

Notes

  • Give the wrapper a definite height. Either set its height directly, or use a flex or grid layout that gives it one. If the wrapper's height is auto, there's nothing to fill, and the chart uses height.
  • height is a minimum, not a target. If the container is shorter than height, the chart stays at height. It's never drawn smaller than the height you set.
  • Resizing keeps working. Charts already redraw when their container's width changes. With heightFull on, they also watch its height, so the chart stays filled when a sidebar collapses, a tab changes, or the window is resized.
  • The pie and donut charts don't support it. On those charts, height sets the radius rather than the drawing area, so filling a tall container would quietly change the size of the pie itself. The option is ignored.