Skip to main content

MeterBar

Wisej.NET 4.2.0+

Three meters: storage split into segments, API calls past their warning threshold, and support seats.

The MeterBar shows how much of a capacity is in use: a label and a value text on one line, and a thin bar underneath. It is the control for quota and usage displays — storage per customer, API calls this month, seats on a plan, stock against shelf space — where the number matters as much as the bar and the color has to change once usage gets close to the limit.

Unlike the ProgressBar, which reports how far a task has got, the MeterBar reports a level, carries its own label and value text, and can split the bar into named segments. It shares its thresholds and tones with the RadialGauge, so the same reading can be drawn as a bar in one place and a ring in another.

info

For a complete list of properties, methods, and events, see the API documentation.

Features​

Value and Capacity​

Value and Maximum are in absolute units — gigabytes, calls, seats — not percentages. Maximum (100 by default) only sets the scale of the fill. Usage above it is allowed: the value text shows the real figure while the fill stops at 100 percent, which is what a quota that has been exceeded should look like.

Label and Value Text​

Label is shown on the left above the bar and the value text on the right. The value text is built from Format, a composite format where {0} is Value and {1} is Maximum; the default "{0:N0} / {1:N0}" reads "8,420 / 10,000". Assign ValueText to show something else entirely, and call ResetValueText() to go back to the formatted text.

Thresholds and Tones​

The fill is drawn in Primary until a threshold applies. Each MeterThreshold in Thresholds has an absolute boundary (From) and the MeterTone used from there up: Neutral, Primary, Success, Warning or Danger. The highest boundary the value has reached wins, and CurrentTone returns the tone in effect.

Segments​

Segments splits the filled part of the bar into named, colored portions. A MeterSegment has a Label, a Value in the meter's units and a Tone. Segments are stacked in collection order inside Value; adding them does not change Value, and whatever part of Value they do not cover is drawn in the current threshold tone.

Events and Animation​

ValueChanged is raised after every change of Value, followed by ThresholdCrossed once for every threshold the change passed, in either direction. MeterThresholdEventArgs carries the boundary From, its Tone, OldValue, NewValue and IsIncreasing. Set Animated to slide the fill to its new length, and BarHeight to make the bar thicker than its default 6 pixels.

How To​

Show a Quota with Warning Levels​

this.meterApiCalls.Label = "API calls this month";
this.meterApiCalls.Maximum = account.MonthlyCallQuota; // 10,000
this.meterApiCalls.Thresholds.Add(new MeterThreshold(8000, MeterTone.Warning));
this.meterApiCalls.Thresholds.Add(new MeterThreshold(10000, MeterTone.Danger));
this.meterApiCalls.Value = account.CallsThisMonth; // 8,420: warning

Break Usage Down into Segments​

this.meterStorage.Label = "Document storage";
this.meterStorage.Maximum = 100;
this.meterStorage.Format = "{0:N0} / {1:N0} GB";
this.meterStorage.Thresholds.Add(new MeterThreshold(80, MeterTone.Warning));

this.meterStorage.Segments.Add(new MeterSegment("Invoices", 38, MeterTone.Primary));
this.meterStorage.Segments.Add(new MeterSegment("Shipping labels", 22, MeterTone.Success));

// 82 GB in use: the remaining 22 GB is drawn in CurrentTone (Warning).
this.meterStorage.Value = 82;

Override the Value Text​

this.meterSeats.Maximum = plan.Seats;
this.meterSeats.Value = plan.AssignedSeats;
this.meterSeats.ValueText = $"{plan.Seats - plan.AssignedSeats} seats left";

// Later, to show "42 / 50" again:
this.meterSeats.ResetValueText();

React When Usage Crosses a Limit​

private void meterApiCalls_ThresholdCrossed(object sender, MeterThresholdEventArgs e)
{
if (e.IsIncreasing && e.Tone == MeterTone.Danger)
notificationService.NotifyAccountOwner(account, $"API quota of {e.From:N0} calls reached.");
}

Advanced​

JavaScript Widget​

ItemDescription
Class name"wisej.web.MeterBar"
Theme appearance"meterbar", see Themes. The "fill" component has a state per tone, and "segment" inherits it.
Child components"header" is the row holding "label" (the label) and "valueText" (the value text). "track" is the bar's background, "fill" the filled part, and "segment" each segment. See JavaScript.