Skip to main content

KPI widgets

KPI widgets are configured in the type kpiWidget or one of its subitems. They use the jquery-kpiwidget library.

The following figure shows a KPI widget:

KpiWidget_EN.png

You can provide settings both in the widget script and in the widget settings. The values set in the script overwrite the values entered in the widget settings.

Available attributes:

  • Color (color): String. Background color for the rectangle widget area, for example #A0B0C0.
  • Footer (footer): String. Text to show at the bottom of the widget, can be localized. See Localizing widget text.
  • Height (height): String. Widget rectangle height in pixels.
  • Localizations (localization): String. Localized values for string attributes. See Localizing widget text.
  • Max value for font size (maxValueForSize): String. The numeric widget value above which the font size will be reduced in order to fit the value in the line inside the rectangle, default is 100000.
  • Prefix (symbol): String. Character symbol or string to show as prefix for the numeric value.
  • Title (title): String. Text to show in the top line of the widget, can be localized. See Localizing widget text.
  • Trend (trend): String. Identifier for the trending symbol to be shown after the numeric value, valid identifiers are up, down, and flat.
  • Value (value): String. The numeric value to be shown. This attribute should normally be determined by the widget script, otherwise, a fixed number is displayed.
  • Visible (visible): Boolean. Determines whether the widget is shown (True) or not (False)

Coding example

KPI widgets are based on the jquery-kpiwidget library. The script has to return a HashMap containing the attributes which define the KPI representation.

The following code provides an example of a KPI widget script which counts the cases which have been opened during the last week.

import com.consol.cmas.common.model.ticket.*
import java.util.*
import com.consol.cmas.common.model.DateRange

TicketCriteria crt = new TicketCriteria()
def to_date = new Date()
def from_date = to_date - 7
def range = new DateRange(from_date,to_date)
crt.setCreationDateRange(range)
// crt.setStatus(TicketCriteria.Status.OPEN)
ticketcount = ticketService.getByCriteria(crt).size()

switch (ticketcount) {
case 0..25:
trendline = 'down'
break
case 26..50:
trendline = 'flat'
break
default:
trendline = 'up'
}

return[value: ticketcount as String, trend: trendline, visible: 'true']