TargetBar
Description
TargetBar measures a value against a target: a thin bar filled up to the value, a tick at the target, and a caption under it with a state on the left and a figure on the right. Use it for run rate, quota or SLA progress in KPI tables such as DataTable.
The scale runs from zero to max, 150 by default, and the tick sits at target, 100 by default. A value past its target still fills past the tick, up to the end of the bar. A value above max fills the bar completely.
For a figure with no target to judge it against, NoValue draws an empty track with no fill and no tick.
Samples
Value against target
State colors
Success, Warning, Danger and Neutral use theme variables, so they follow the active theme. Color accepts any CSS color or variable.
Custom scale and thickness
value, target and max share one unit, so the bar does not have to be a percentage. NoValue(label, valueText) takes an optional caption pair; valueText is an em dash when omitted. Thickness sets the bar height, 4px by default.
API reference
public sealed class TargetBar : ComponentBase<TargetBar, HTMLElement>A thin bar that measures a value against a target: the bar is filled up to the value, a tick marks where the target sits on the same scale, and a line under it names the state on the left and the figure on the right ("Watch ... 84%").
Remarks
The scale runs from zero to Max (150 by default), so a value that overshoots its target - 231% of a run rate - still shows how far past it went, and the tick stays put at the target (100 by default). A bar with no target to speak of is drawn as an empty track by NoValue.
- Namespace
- Tesserae
- Inheritance
- ComponentBase<TargetBar, HTMLElement> → TargetBar
Constructors
| Name | Description |
|---|---|
| TargetBar | Initializes a new instance of this class. |
public TargetBar(double value, double target = 100, double max = 150)Initializes a new instance of this class.
Parameters
- value
- What was reached, on the same scale as
target. - target
- Where the tick goes. 100 by default, for a value expressed as a percentage of its target.
- max
- The value at which the bar is full.
Methods
| Name | Description |
|---|---|
| Value | Sets what was reached. |
| Target | Sets where the tick sits on the scale. |
| Max | Sets the value at which the bar is full. |
| Label | Sets the text at the left of the line under the bar - the state the value puts the metric in. |
| ValueText | Sets the text at the right of the line under the bar - the figure itself. |
| NoValue | Draws an empty track with no fill and no tick, for a figure that has no target to be measured against. |
| Color | Colors the fill with any CSS color, or a theme variable. |
| Success | Colors the fill with the theme's success color. |
| Warning | Colors the fill with the theme's warning color. |
| Danger | Colors the fill with the theme's danger color. |
| Neutral | Colors the fill with a muted neutral. |
| Thickness | Sets how thick the bar is. 4px by default. |
| Render | Renders the component's root HTML element. |
public TargetBar Label(string text)Sets the text at the left of the line under the bar - the state the value puts the metric in.
public TargetBar ValueText(string text)Sets the text at the right of the line under the bar - the figure itself.
public TargetBar NoValue(string label = null, string valueText = "—")Draws an empty track with no fill and no tick, for a figure that has no target to be measured against.
public TargetBar Color(string color)Colors the fill with any CSS color, or a theme variable.
public TargetBar Thickness(UnitSize size)Sets how thick the bar is. 4px by default.