KPI items
-
The
FUIKPIView
is anUIView
subclass, which enables a developer to presentKPI
information in a formatted manner consistent with the Fiori Design Language.The
FUIKPIView
takes 3 types of component items, and a caption string:metric
: the value which is being displayed. For example, in:$256k
, the metric is256
.unit
: the unit information for the metric displayed. For example, in$256k
, the units are$
andk
. Multiple unit components are permitted per metric. However, a maximum of two units should be used on each side of the metric.icon
: a 32px x 32px icon may be displayed. Icons should only be displayed to the left of a metric. Units may still be displayed to the right of the metric, when an icon is displayed.captionLabel
: optional label, displayed beneath the KPI components.
The KPI components are implemented as
FUIKPIMetricItem
,FUIKPIUnitItem
, andFUIKPIIconItem
. All implementFUIKPIViewItem
protocol. The developer should create instances of each of these components, and pass them to theitems: [FUIKPIViewItem]
property of theFUIKPIView
.Note
This API of component items is conceptually similar to that ofUIToolbar
‘sitems: [UIBarButtonItem]?
property.Color configuration:
- Call setTintColor(_:for:) to configure tint color for disabled, normal, highlighted
UIControlState
. SettingtintColor
is equivalent to call setTintColor(color, for: UIControlState.normal). IftintColor
is not set by developer,colorScheme
will be applied.- disabled: Color to be used when control is disabled.
- normal: Color to be used when control is enabled.
- highlighted: Color to be used when control is tapped on.
Initialization
Programmatically:
let kpiView = FUIKPIView(frame: CGRect())
Inside a Storyboard or xib:
- Drag and drop a
UIView
component to Interface Builder’s canvas. - Switch custom class name from
UIView
toFUIKPIView
and set module toSAPFiori
. - Create an outlet of the
FUIKPIView
to be able to access its properties.
Usage
// Do any additional setup after loading the view. let unit = FUIKPIUnitItem(string: "$") let metric = FUIKPIMetricItem(string: "294") let unit2 = FUIKPIUnitItem(string: "USD") self.kpiView.items = [unit, metric, unit2] self.kpiView.captionlabel.text = "Label example can wrap to two lines" let icon = FUIKPIIconItem(icon: #imageLiteral(resourceName: "ProfilePic")) let metric2 = FUIKPIMetricItem(string: "2") self.kpiIconView.items = [icon, metric2, unit2] self.kpiIconView.captionlabel.text = "Documents Example of Two Line Wrap"
Theming
See morefdlFUIKPIView { tint-color: @primary2; }
Declaration
Swift
open class FUIKPIView : NibDesignableControl, FUIStateTintable, FUIStateTintableImplementation, FUIKPIContainer
-
A protocol defines
See morestyle
representing an item inFUIKPIView
.Declaration
Swift
public protocol FUIKPIViewItem
-
An enum representing the different view styles that a
See moreFUIKPIView
can have.Declaration
Swift
public enum FUIKPIViewItemStyle
-
The
See moreFUIKPIMetricItem
conforms toFUIKPIViewItem
protocol for representing the value being displayed inFUIKPIView
. For example, in:$256k
, the metric is256
.Declaration
Swift
open class FUIKPIMetricItem : FUIKPIViewItem
-
The
See moreFUIKPIUnitItem
conforms toFUIKPIViewItem
protocol for representing the metric’s unit information being displayed inFUIKPIView
. For example, in$256k
, the units are$
andk
.Declaration
Swift
open class FUIKPIUnitItem : FUIKPIViewItem
-
The
See moreFUIKPIIconItem
is anUIImageView
subclass, which conforms toFUIKPIViewItem
protocol for representing a 32px x 32px icon being displayed in theFUIKPIView
.Declaration
Swift
open class FUIKPIIconItem : FUIKPIViewItem
-
The
See moreFUIKPIFractionItem
is anUILabel
subclass, which conforms toFUIKPIViewItem
protocol for representing the value being displayed inFUIKPIView
. For example, in:56/100
, the fraction is56
or100
.Declaration
Swift
open class FUIKPIFractionItem : FUIKPIViewItem
-
The
FUIKPIProgressView
is anUIView
subclass, which enables a developer to presentKPI
information in a formatted manner consistent with the Fiori Design Language.The
FUIKPIProgressView
takes 4 types of component items, and a caption string:chartSize
: KPICharts can be small (104px circle) or large (130px circle). Large is defaultmetric
: The value which is being displayed. For example, in:42%
and42/100
, the metric is42
.fraction
: The value which is being displayed when in a fraction form. For example, in: 42/100, the fraction elements are42
and100
with/
being aunit
item.unit
: the unit information for the metric displayed. For example, in42%
, the unit is%
. Multiple unit components are permitted per metric. However, a maximum of two units should be used on each side of the metric.progress
: The percentage of the KPI chart/circle that should be filled in. For example, to have half of the circle chart filled in, the progress is0.50
. Progress bar animates on load.captionLabel
: An optional label displayed directly beneath the KPI components. The label will shift to underneath the circle if sizing requires. For small charts, the caption can be up to 86px in length. Greater than that, it moves outside of the circle and can wrap to up to 2 lines of 122 px per line. For large charts, the caption inside the circle can be up to 94px. Beyond that, it moves outside the circle and wraps to up to 2 lines of 216px per line.
The KPI components are implemented as
FUIKPIMetricItem
,FUIKPIFractionItem
, orFUIKPIUnitItem
. All implementFUIKPIViewItem
protocol. The developer should create instances of each of these components, and pass them to theitems: [FUIKPIViewItem]
property of theFUIKPIProgressView
.Note
This API of component items is conceptually similar to that ofUIToolbar
‘sitems: [UIBarButtonItem]?
property.Color configuration:
- Call setTintColor(_:for:) to configure tint color for disabled, normal, highlighted
UIControlState
. SettingtintColor
is equivalent to call setTintColor(color, for: UIControlState.normal). IftintColor
is not set by developer,colorScheme
will be applied. - disabled: Color to be used when control is disabled.
- normal: Color to be used when control is enabled.
- highlighted: Color to be used when control is tapped on.
Initialization
Programmatically:
let kpiChartView = FUIKPIProgressView(frame: CGRect())
Inside a Storyboard or xib:
- Drag and drop a
UIView
component to Interface Builder’s canvas. - Switch custom class name from
UIView
toFUIKPIProgressView
and set module toSAPFiori
. - Create an outlet of the
FUIKPIProgressView
to be able to access its properties.
Usage
self.kpiChartView.chartSize = FUIKPIProgressViewSize.small let metric = FUIKPIMetricItem(string: "33") let unit = FUIKPIUnitItem(string: "%") self.kpiChartView.items = [metric, unit] self.kpiChartView.progress = Float(0.33) self.kpiChartView.captionLabelText = "Complete"
Theming
See morefdlFUIKPIProgressView { progress-tint-color: @chart1; track-tint-color: @primary5; }
Declaration
Swift
open class FUIKPIProgressView : NibDesignableControl, FUIKPIContainer, FUIStateTintable, FUIStateTintableImplementation
-
Enum to determine whether to display the large or small progress circle around the KPIView. Default:
See moreFUIKPIProgressViewSize.large
Declaration
Swift
public enum FUIKPIProgressViewSize
-
FUIKPIHeader
extendsUIView
for a tableview header displaying KPI items, of type FUIKPIView and FUIKPIProgressView. A maximum of four KPI values can be displayed in the header, hence if more than four items are provided in the items array as input to the header, only the first four are diplayed and the rest of the items are ignored. When both FUIKPIView and FUIKPIProgressView items are provided, the items are sorted such that the FUIKPIProgressViews are displayed first, followed by the FUIKPIViews. Only FUIKPIProgessViews with chartSize of ‘large'can be displayed in the header , if an FUIProgressView of charSize 'small'is supplied, it is ignored. Based on the number of KPI items that can be shown based on the screen size, a page control is used to display multiple pages in the header, as required. The kpi items in the header can be enabled or disabled. The default KPI header background is of color scheme .dark, hence to display the kpi items with the appropriate tintColor as per the fiori design guidelines for iOS, it is required that the kpi items supplied to the header have a color scheme of .dark as well. The developer can choose to supply a custom tint color for the kpis. It is important to set the colorScheme of the kpi before the call to override the tintColor, as shown below.( since setting the colorScheme resets the tintColor to the defaults, if the calls are not in order, then the custom tintColors are not displayed.)kpiView.colorScheme = .dark kpiView.setTintColor(.yellow, for: .normal)
## Regular (Landscape) Horizontal Size Class: Variations
## Compact (Portrait) Horizontal Size Class: Variations
## Example Initialization and Configuration:
In table view controller’s
viewDidLoad
function://Programmatically add a KPIHeader to tableview let kpiView1 = FUIKPIView() let kpiView1Icon = FUIKPIIconItem(icon: #imageLiteral(resourceName: "asset").withRenderingMode(.alwaysTemplate)) let kpiView1Metric = FUIKPIMetricItem(string: "5") let kpiView1Unit1 = FUIKPIUnitItem(string: "k") kpiView1.items = [kpiView1Icon, kpiView1Metric,kpiView1Unit1] kpiView1.captionlabel.text = "Orders processed" kpiView1.isEnabled = false kpiView1.colorScheme = .dark var kpiChartLarge: FUIKPIProgressView! kpiChartLarge = FUIKPIProgressView() kpiChartLarge.chartSize = FUIKPIProgressViewSize.large let fractionLarge = FUIKPIFractionItem(string: "12") let unitLarge = FUIKPIFractionItem(string: "/") let fractionLarge2 = FUIKPIFractionItem(string: "25") kpiChartLarge.items = [fractionLarge, unitLarge, fractionLarge2] kpiChartLarge.progress = Float(0.64) kpiChartLarge.captionLabelText = "Completed" kpiChartLarge.colorScheme = .dark let kpiArray = [kpiView1, kpiChartLarge] let KPIHeader = FUIKPIHeader() KPIHeader.items = kpiArray self.tableView.tableHeaderView = KPIHeader
## Note:
FUIKPIHeader
added toUITableView
as tableHeaderView is compatible withUIRefreshControl
added to the same table view. Please note that if anUIRefreshControl
object is set after adding anFUIKPIHeader
object as tableHeaderView, theUIRefreshControl
subview must be moved to the front in thetableView
; otherwise, theUIRefreshControl
object will be hidden.//set kpiHeader to tableHeaderView first self.tableView.tableHeaderView = kpiHeader //set a refresh control next self.refreshControl = UIRefreshControl() self.refreshControl?.addTarget(self, action: #selector(refreshTriggered), for: .valueChanged) self.refreshControl?.tintColor = UIColor.white //bring refresh control to the front to make it visible self.tableView.bringSubview(toFront: self.refreshControl!)
## Theming
See morefdlFUIKPIHeader_background { background-color: @backgroundGradientTop; } fdlFUIKPIHeader_kpiView { tint-color: @primary6; }
Declaration
Swift
@IBDesignable open class FUIKPIHeader : FUIDrawingView
-
Protocol indicating a component expects an optional instance of a
See moreFUIKPIAttributesProvider
Declaration
Swift
public protocol FUIKPIAttributesConsumer : AnyObject
-
Provider for
See moreFUIKPIAttributedStringBuilder
attributes. Decoupling the style definitions from the string constructor means that the same logic for building string can be shared by all controls taking array ofFUIKPIViewItem
, while each special control using the items (FUIKPIView
,FUIKPIProgressView
(small & large), AnalyticViews, etc.,) can have unique styles by supplying a custom implementation of this protocol.Declaration
Swift
public protocol FUIKPIAttributesProvider : AnyObject