import { Component } from '@angular/core';
import { WrMeterGroup } from 'ngwr/charts/meter-group';
@Component({ imports: [WrMeterGroup] })
export class MyComponent {}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.
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"
/>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;
}| Name | Description | Type | Default |
|---|---|---|---|
WrMeterSegment | One segment of the bar. | interface | — |
labelrequired | Label shown in the legend. | string | — |
valuerequired | Portion of the sum of all segments. | number | — |
color | CSS color for the slice and legend swatch. | string | palette |
API
| Name | Description | Type | Default |
|---|---|---|---|
ariaLabel | Accessible name — the role needs one. Falls back to meterGroup.label. | string | null | null |
segments | The 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[] | [] |
max | Explicit total. When 0 (default), max = sum(values). | number | 0 |
showLegend | Show the labelled legend under the bar. | boolean | true |
showValues | Show each segment's value in the legend, next to its label. | boolean | true |
tooltip | Show 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. | boolean | true |
valueFormat | Writes 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) | null | null |
Dependencies
| Built on | Popover |
|---|
See also
Component Donut ChartParts of a whole as a ring or a pie.Component ProgressA bar that shows how far a task has got.Component Bar ChartVertical bars for one series of values.Guide ColorsThe --wr-color-* tokens, and which one to use for fills, text and borders.Component PopoverShow a template, or a text tooltip, next to its trigger.