/
px-kpi.html
154 lines (136 loc) · 4.32 KB
/
px-kpi.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<!--
Copyright (c) 2018, General Electric
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!--
Relative paths assume component is being run from inside an app or another component, where dependencies are flat
siblings. When this component is run from its own repo (e.g. tests, examples), we assume the server is started with
'gulp serve' (or similar server setup) to enable correct finding of bower dependencies for local runs.
-->
<link rel="import" href="../polymer/polymer.html"/>
<link rel="import" href="css/px-kpi-styles.html">
<link rel="import" href="../px-vis-spark/px-vis-spark.html" />
<link rel="import" href="../px-icon-set/px-icon-set.html" />
<link rel="import" href="../px-icon-set/px-icon.html" />
<!--
### Associated components
[px-vis-spark](https://www.predix-ui.com/#/components/px-vis-spark/)
### Usage
<px-kpi label="Availability" value="100" uom="%" status-icon="px-nav:up" status-color="green" spark-data="..."></px-kpi>
### Styling
The following custom properties are available for styling:
Custom property | Description
----------------|-------------
`--px-kpi-text-color` | Primary text color for the KPI
`--px-kpi-secondary-text-color` | Secondary text color for the KPI
@element px-kpi
@blurb Element for displaying KPIs in a dashboard layout as a tile with one large number value.
@homepage index.html
@demo demo.html
-->
<dom-module id="px-kpi">
<template>
<style include="px-kpi-styles"></style>
<span class="caps secondary epsilon u-mt0 u-mb">{{label}}</span>
<div class="flex u-mb u--mt-">
<span class="alpha float--left u-mv0 u-mr">{{value}}</span>
<div class="flex flex--col u-pt u-pb-">
<div class="flex__item">
<px-icon id="statusIcon" icon$="{{statusIcon}}" class="u-mb-- flex__item" style$="color:{{statusColor}};"></px-icon>
<span class="epsilon">{{statusLabel}}</span>
</div>
<span class="flex--bottom secondary epsilon">{{uom}}</span>
</div>
</div>
<template is="dom-if" if="{{sparkData}}">
<px-vis-spark type="{{sparkType}}" width="300" height="50" prevent-resize="true" data="{{sparkData}}"></px-vis-spark>
</template>
</template>
</dom-module>
<script>
Polymer({
is: 'px-kpi',
properties: {
/**
* Title or label for the KPI.
*
* @property label
* @type String
*/
label: {
type: String
},
/**
* Value of KPI.
*
* @property value
* @type String
*/
value: {
type: String
},
/**
* Unit of Measure for KPI (e.g. %, USD, etc).
*
* @property uom
* @type String
*/
uom: {
type: String
},
/**
* Color to display the status icon.
*
* @property statusColor
* @type String
*/
statusColor: {
type: String
},
/**
* Icon to display for the status. See Predix UI iconography documentation for valid names.
*
* @property statusIcon
* @type String
*/
statusIcon: {
type: String
},
/**
* Supporting text to display next to the status icon (e.g. if the icon is an arrow, "12%" to indicate an increase).
*
* @property statusLabel
* @type String
*/
statusLabel: {
type: String
},
/**
* The chart type to display below the KPI. One of "line", "bar, "winLoss". Spark type is dependent on your data structure; see px-vis-spark for more information.
*
* @property sparkType
* @type String
*/
sparkType: {
type: String
},
/**
* The data to populate your chart. See px-vis and px-vis-spark for more information.
*
* @property sparkData
* @type Array
*/
sparkData: {
type: Array
}
}
});
</script>