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:
You can set attributes both in the widget script and in the page customization. The values set in the script overwrite the values entered in the page customization.
Available attributes:
- color
String. Background color for the rectangle widget area, for example #A0B0C0. - footer
String. Text to show at the bottom of the widget, can be localized. See Localizing widget text. - height
String. Widget rectangle height in pixels. - localization
String. Localized values for string attributes. See Localizing widget text. - 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. - symbol
String. Character symbol or string to show as prefix for the numeric value. - title
String. Text to show in the top line of the widget, can be localized. See Localizing widget text. - trend
String. Identifier for the trending symbol to be shown after the numeric value, valid identifiers are up, down, and flat. - value
String. The numeric value to be shown. This attribute should normally by determined by the widget script, otherwise, a fixed number is displayed. - 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:
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']
Code example 44: Script for a KPI widget which counts the cases which have been opened during the last week