ComponentDisplayUpdated in v15

Meter Group

One bar split into labelled parts, with a legend.

Installation

Import the class, and @use the entry point in your global styles: without it the component renders unstyled.

import { Component } from '@angular/core';
import { WrMeterGroup } from 'ngwr/charts/meter-group';

@Component({ imports: [WrMeterGroup] })
export class MyComponent {}

Disk usage

Each segment takes its share of the sum, or of max when set.

<wr-meter-group
  [segments]="[
    { label: 'Used', value: 60 },
    { label: 'Reserved', value: 25, color: 'var(--wr-color-warning)' }
  ]"
  [max]="100"
/>
  • System32
  • Apps88
  • Documents24
  • Free112

Tooltip

[tooltip]="false" falls back to the browser title.

<wr-meter-group [segments]="diskUsage" [tooltip]="false" />

Types

interface WrMeterSegment {
  label: string;
  value: number;
  color?: string;
}
NameDescriptionTypeDefault
WrMeterSegmentOne segment of the bar.interface—
labelrequiredLabel shown in the legend.string—
valuerequiredPortion of the sum of all segments.number—
colorCSS color for the slice and legend swatch.stringpalette

API

NameDescriptionTypeDefault
ariaLabelAccessible name — the role needs one. Falls back to meterGroup.label.string | nullnull
segmentsThe parts of the bar, in order. Values are summed and each segment is drawn as its share of that total, so they need not add up to anything in particular.readonly WrMeterSegment[][]
maxExplicit total. When 0 (default), max = sum(values).number0
showLegendShow the labelled legend under the bar.booleantrue
showValuesShow each segment's value in the legend, next to its label.booleantrue
tooltipShow a tooltip with the segment's label and value on hover. It replaces the band's title, which is written only while this is off — or the browser would open a second copy a moment later.booleantrue
valueFormatWrites every value in the legend and the tooltip, and the total the bar announces as aria-valuetext. null uses Intl.NumberFormat in LOCALE_ID. aria-valuenow stays a number.((value: number) => string) | nullnull

Dependencies

Built onPopover

See also