KpiPanel
Wisej.NET 4.2.0+
The KpiPanel is the metric card at the top of a dashboard: a title, one headline number, an optional trend and caption, an icon, a colored accent and, underneath, a small visual — a sparkline, a progress bar or a gauge. One card shows one key figure; a row of them, in a FlowLayoutPanel or a TableLayoutPanel, is the summary line of a dashboard.
The card is a composition of the other data visualization controls: its sparkline is a Sparkline and its gauge a RadialGauge, laid out and themed together so a dashboard does not have to assemble labels, panels and charts by hand for every figure. When the figure needs a real chart, place a ChartView next to the cards.
For a complete list of properties, methods, and events, see the API documentation.
Features
Metric, Title and Caption
Value is a string, not a number: the card shows it exactly as given and never parses it, so the application formats the figure the way it wants it read — "$402K", "96.1%", "37". Title sits above it and Caption below, for the comparison or the period ("vs. last month"). Value is the card's default binding property, and ValueChanged is raised when its text changes.
Trend
Trend is a signed decimal, or null to hide it. It is shown next to the value with an upward or downward marker, in the success color when positive and the danger color when negative, whatever the card's Tone; zero gets a neutral marker. TrendFormat is the numeric format used for it ("0.##" by default). Whether a rising figure is good news is up to the application: for open tickets, it is not.
Compact Visual
Visual selects what is drawn under the metric:
| Visual | Draws | Reads from |
|---|---|---|
None | Nothing (the default). | |
Sparkline | A small trend chart. | SparklineValues, or the ChartSeries assigned to the card. |
ProgressBar | A thin bar. | ProgressValue against Maximum. |
Gauge | A small ring gauge. | ProgressValue against Maximum. |
The visual's numbers are independent of Value, so the headline can read "96.1%" while the bar is driven by the raw counts. Switching Visual keeps both the sparkline samples and the progress value, so the application can switch back and forth.
Assigning a ChartSeries lets a card share its data with a ChartView on the same page: line, area and bar series keep their geometry in the sparkline, other types are drawn as a line of their values. The series stays owned by the application; call Update() on the card after its external data source has changed.
Tone, Accent and Icon
Tone colors the accent, the icon and the visual: Neutral, Primary (the default), Success, Warning or Danger. AccentPosition draws a colored strip at the Top or Left edge of the card, or none; in right-to-left layouts the left accent moves to the leading edge. Icon takes an image source or a theme image key and shows it as a button in the card's header.
Click and Icon Click
Set Clickable to make the whole card raise Click, for a drill-down into the detail behind the figure. The icon raises IconClick instead, independently of Clickable and without raising Click as well, so the card and its icon can lead to two different places. The icon responds to the keyboard, and so does the card, with Enter or Space, once it can take focus (it is not Focusable by default). A disabled card raises neither event.
How To
Show a Metric with a Progress Bar
this.kpiDeliveries.Title = "ON-TIME DELIVERIES";
this.kpiDeliveries.Value = stats.OnTimeRate.ToString("P1"); // "96.1%"
this.kpiDeliveries.Caption = "vs. last 7 days";
this.kpiDeliveries.Trend = 2.4m;
this.kpiDeliveries.Tone = KpiTone.Success;
this.kpiDeliveries.AccentPosition = KpiAccentPosition.Top;
this.kpiDeliveries.Visual = KpiVisual.ProgressBar;
this.kpiDeliveries.Maximum = stats.ShipmentsTotal;
this.kpiDeliveries.ProgressValue = stats.ShipmentsOnTime;
Add a Revenue Trend
var lastTen = revenueService.GetMonthlyRevenue(10); // List<decimal>, oldest first
this.kpiRevenue.Title = "MONTHLY REVENUE";
this.kpiRevenue.Value = lastTen.Last().ToString("C0");
this.kpiRevenue.Trend = Math.Round((lastTen[9] - lastTen[8]) / lastTen[8] * 100, 1);
this.kpiRevenue.TrendFormat = "0.0";
this.kpiRevenue.Caption = "vs. last month";
this.kpiRevenue.Visual = KpiVisual.Sparkline;
this.kpiRevenue.SparklineValues = lastTen.Select(v => (double)v).ToArray();
Drill Down from a Card
this.kpiTickets.Clickable = true;
this.kpiTickets.Icon = "Images/ticket.svg";
this.kpiTickets.Click += (s, e) => new OpenTicketsView().Show();
this.kpiTickets.IconClick += (s, e) => new TicketSlaReport().ShowDialog();
Keep a Card Current
Value is bindable, so a card can follow a field of a record through a BindingSource. Use ValueChanged to react when the figure changes.
this.kpiOpenOrders.DataBindings.Add("Value", this.dashboardBindingSource, "OpenOrdersText");
this.kpiOpenOrders.ValueChanged += (s, e) =>
this.kpiOpenOrders.Tone = dashboard.OpenOrders > 1000 ? KpiTone.Warning : KpiTone.Primary;
Advanced
JavaScript Widget
| Item | Description |
|---|---|
| Class name | "wisej.web.KpiPanel" |
| Theme appearance | "kpipanel", see Themes. Its "accent-top-…", "accent-left-…" and "accent-right-…" states, one per tone, draw the accent; the "icon" and "fill" components have a state per tone, and "trend" has "positive", "negative" and "zero" states. |
| Child components | "body" holds the card's content. "header" holds "title" and "icon" (a button); "metric" holds "value" and "trend"; "caption" is the detail line. The visual is "sparkline" (a wisej.web.Sparkline), "gauge" (a wisej.web.RadialGauge) or "progress" with its "fill". See JavaScript. |