KpiPanel
Namespace: Wisej.Web
Assembly: Wisej.Framework (4.2.0.0)
Displays one formatted metric with an optional trend, icon, accent, and compact visual.
- C#
- VB.NET
public class KpiPanel : Control
Public Class KpiPanel
Inherits Control
Assign display text to Value; the control never parses it as a number. Trend is formatted on the server using TrendFormat and the current culture. Positive trends use the success color and negative trends use the danger color independently of Tone. Sparkline updates reuse the existing client widget.
Example:
var card = new KpiPanel
{
Title = "ON-TIME DELIVERIES", Value = "96.1%", Caption = "vs. last 7 days",
Trend = 2.4m, Tone = KpiTone.Success, AccentPosition = KpiAccentPosition.Top,
Visual = KpiVisual.ProgressBar, ProgressValue = 96.1, Maximum = 100, Clickable = true
};
card.Click += (sender, e) => MessageBox.Show("Delivery details");
this.Controls.Add(card);
Constructors
KpiPanel()
Initializes an empty metric card with no visual, no accent, and card activation disabled.
Properties
AccentPosition
KpiAccentPosition: Gets or sets accent placement. The default is None. Left becomes the leading edge in right-to-left layout. (Default: None)
Caption
String: Gets or sets optional plain-text detail below the metric. The default is an empty string. (Default: "")
ChartSeries
ChartSeries: Gets or sets an observable ChartSeries used by the compact sparkline. (Default: null)
The series is shared and remains owned by the application. Line, area and bar series use their corresponding compact geometry; other series use a line of their Value samples. Null restores SparklineValues. Call Update after changing an external data source.
Example:
card.Visual = KpiVisual.Sparkline;
card.ChartSeries = revenueSeries;
Clickable
Boolean: Gets or sets whether the card surface raises Click. The default is false. (Default: False)
Setting this property also sets TabStop and Focusable to the same value. An enabled clickable card supports pointer activation, Enter, and Space. The icon remains independently interactive.
DefaultSize
Size: Gets the default card size of 270 by 160 pixels.
Focusable
Boolean: Gets or sets whether the card can receive focus. The default is false. (Default: False)
Icon
String: Gets or sets an icon image source or Wisej theme image key. Empty hides the icon button. (Default: "")
Maximum
Double: Gets or sets the positive finite progress capacity. The default is 100. (Default: 100)
Throws:
- ArgumentOutOfRangeException The capacity is nonfinite or is not positive.
NoSamplesText
String: Gets or sets the localized override for the "No samples." text. (Default: null)
The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation.
ProgressValue
Double: Gets or sets the nonnegative absolute progress amount. The default is zero. (Default: 0)
Values above Maximum are retained, but the visible bar or gauge is capped at full capacity. This does not change Value.
Throws:
- ArgumentOutOfRangeException The amount is negative or nonfinite.
SamplesSummaryText
String: Gets or sets the localized override for the "{0} samples. Latest value: {1}." text. (Default: null)
The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation. {0} is the sample count and {1} is the latest value. Used for the CLDR other category of the current UI culture. Literal braces can be written as {{ and }}.
SampleSummaryText
String: Gets or sets the localized override for the "{0} sample. Latest value: {1}." text. (Default: null)
The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation. {0} is the sample count and {1} is the latest value. Used for the CLDR one category of the current UI culture. Literal braces can be written as {{ and }}.
SparklineValues
Double[]: Gets a copy of the finite sparkline samples, or replaces them. Null clears the samples.
Samples remain in supplied order and are not trimmed. Assign a new array to update the visual; editing the supplied array or returned copy does not change the control. Update sends new data to the existing client sparkline without recreating the card.
Throws:
- ArgumentOutOfRangeException A sample is NaN or infinite.
Example:
card.Visual = KpiVisual.Sparkline;
card.SparklineValues = new double[] { 65, 72, 68, 59, 49.2 };
card.Value = "49.2%";
TabStop
Boolean: Gets or sets card tab navigation participation. The default is false. (Default: False)
Title
String: Gets or sets the plain-text metric title. The default is an empty string. (Default: "")
Tone
KpiTone: Gets or sets the semantic accent and visual color. The default is Primary. (Default: Primary)
Trend
Nullable<Decimal>: Gets or sets a signed trend, or null to hide the trend. The default is null. (Default: null)
The value is independent of Value and ProgressValue. An upward or downward marker indicates its sign; zero uses a neutral marker. Whether an increase is desirable is application-specific.
TrendFormat
String: Gets or sets the .NET numeric format for Trend. The default is "0.##". (Default: "0.##")
Formats the signed decimal using the current culture. This is a numeric format, not a composite format. Use positive and negative custom sections when the direction marker should replace a minus sign.
Throws:
- ArgumentNullException The format is null.
- FormatException The numeric format is invalid.
Example:
card.Trend = -2.4m;
card.TrendFormat = "0.0;0.0;0"; // Downward marker followed by 2.4.
Value
String: Gets or sets the already formatted metric text. The default is an empty string. (Default: "")
Example:
card.Value = (0.492).ToString("P1", System.Globalization.CultureInfo.CurrentCulture);
Visual
KpiVisual: Gets or sets the compact visual below the metric. The default is None. (Default: None)
Changing modes retains both SparklineValues and ProgressValue so the application can switch back. Gauge uses ProgressValue and Maximum with the card’s Tone; Value remains independently formatted.
Methods
Dispose(disposing)
Releases observation of an application-owned chart series.
| Parameter | Type | Description |
|---|---|---|
| disposing | Boolean | Whether managed resources are being released. |
OnIconClick(e)
Raises IconClick.
| Parameter | Type | Description |
|---|---|---|
| e | EventArgs | Event data. |
OnValueChanged(e)
Raises ValueChanged.
| Parameter | Type | Description |
|---|---|---|
| e | EventArgs | Event data. |
OnWebEvent(e)
Dispatches activation events and suppresses the standard tap event to avoid duplicate clicks.
| Parameter | Type | Description |
|---|---|---|
| e | WisejEventArgs | Client event. |
OnWebRender(config)
Serializes metric properties and wires activation events independently of delegate subscriptions.
| Parameter | Type | Description |
|---|---|---|
| config | Object | Client configuration. |
ResetSparklineValues()
Restores the default empty sparkline sample array.
Events
IconClick
EventHandler Occurs when the visible icon is activated with the pointer or keyboard.
Icon activation is independent of Clickable and does not also raise Click. Disabled cards suppress both events.
ValueChanged
EventHandler Occurs after the displayed Value changes. Assigning the same text does not raise the event.
Implements
| Name | Description |
|---|---|
| IUserData | Provides access to the UserData and Tag properties associated to the component implementing this interface. |
| IBindableComponent | Bindable components implement this interface. |
| IDropTarget | Controls that support drag & drop operations implement this interface. |
| IWisejComponent | All wisej components implement this interface. |
| IWisejControl | All wisej controls derived from the Control class must implement this interface. |
| IWisejSerializable | Allows an object to serialize itself. |