toggle-components-library 1.24.0 → 1.24.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/toggle-components-library.common.js +228 -85
- package/dist/toggle-components-library.common.js.map +1 -1
- package/dist/toggle-components-library.umd.js +228 -85
- package/dist/toggle-components-library.umd.js.map +1 -1
- package/dist/toggle-components-library.umd.min.js +1 -1
- package/dist/toggle-components-library.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/src/components/metrics/ToggleMetricBarChart.vue +21 -2
- package/src/components/metrics/ToggleMetricFunnelChart.vue +3 -0
- package/src/components/metrics/ToggleMetricPieChart.vue +16 -0
- package/src/components/metrics/ToggleMetricSingleMetric.vue +34 -10
- package/src/components/metrics/ToggleMetricSparkLine.vue +59 -4
- package/src/components/mixins/mixins.js +2 -2
package/package.json
CHANGED
|
@@ -14,28 +14,47 @@ export default {
|
|
|
14
14
|
mixins:[charts],
|
|
15
15
|
|
|
16
16
|
props: {
|
|
17
|
+
/**
|
|
18
|
+
* Used to overwrite the default colors
|
|
19
|
+
*/
|
|
17
20
|
colors: {
|
|
18
|
-
type: [
|
|
21
|
+
type: [Array]
|
|
19
22
|
},
|
|
23
|
+
/*
|
|
24
|
+
* Component's height
|
|
25
|
+
*/
|
|
20
26
|
height: {
|
|
21
27
|
type: String,
|
|
22
28
|
default: "100%"
|
|
23
29
|
},
|
|
30
|
+
/*
|
|
31
|
+
* Component's values
|
|
32
|
+
*/
|
|
24
33
|
values: {
|
|
25
34
|
type: [Array],
|
|
26
35
|
required: true
|
|
27
36
|
},
|
|
37
|
+
/*
|
|
38
|
+
* Component's labels
|
|
39
|
+
*/
|
|
28
40
|
label: {
|
|
29
41
|
type: String,
|
|
30
42
|
required: true
|
|
31
43
|
},
|
|
44
|
+
/*
|
|
45
|
+
* Component's categories
|
|
46
|
+
*/
|
|
32
47
|
categories: {
|
|
33
|
-
type: [
|
|
48
|
+
type: [Array],
|
|
34
49
|
required: true
|
|
35
50
|
}
|
|
36
51
|
},
|
|
37
52
|
|
|
38
53
|
computed: {
|
|
54
|
+
/**
|
|
55
|
+
* define the pie chart options
|
|
56
|
+
* @return Object
|
|
57
|
+
*/
|
|
39
58
|
chartOptions() {
|
|
40
59
|
return {
|
|
41
60
|
plotOptions: {
|
|
@@ -14,23 +14,39 @@ export default {
|
|
|
14
14
|
mixins:[charts],
|
|
15
15
|
|
|
16
16
|
props: {
|
|
17
|
+
/**
|
|
18
|
+
* Used to overwrite the default colors
|
|
19
|
+
*/
|
|
17
20
|
colors: {
|
|
18
21
|
type: [String]
|
|
19
22
|
},
|
|
23
|
+
/**
|
|
24
|
+
* Component's values
|
|
25
|
+
*/
|
|
20
26
|
values: {
|
|
21
27
|
type: Array,
|
|
22
28
|
required: true
|
|
23
29
|
},
|
|
30
|
+
/**
|
|
31
|
+
* Component's main label
|
|
32
|
+
*/
|
|
24
33
|
label: {
|
|
25
34
|
type: String,
|
|
26
35
|
required: true
|
|
27
36
|
},
|
|
37
|
+
/**
|
|
38
|
+
* Component's label for each value
|
|
39
|
+
*/
|
|
28
40
|
labels: {
|
|
29
41
|
type: Array,
|
|
30
42
|
required: true
|
|
31
43
|
}
|
|
32
44
|
},
|
|
33
45
|
computed: {
|
|
46
|
+
/**
|
|
47
|
+
* define the pie chart options
|
|
48
|
+
* @return Object
|
|
49
|
+
*/
|
|
34
50
|
chartOptions() {
|
|
35
51
|
return {
|
|
36
52
|
labels: this.labels,
|
|
@@ -13,52 +13,76 @@ import { mixins } from '../mixins/mixins'
|
|
|
13
13
|
export default {
|
|
14
14
|
mixins:[mixins],
|
|
15
15
|
props: {
|
|
16
|
+
/**
|
|
17
|
+
* Component's name
|
|
18
|
+
*/
|
|
16
19
|
name: {
|
|
17
20
|
type: String,
|
|
18
21
|
default: "ToggleMetricSingleMetric"
|
|
19
22
|
},
|
|
23
|
+
/**
|
|
24
|
+
* Type of the value, this will affect on the format shown
|
|
25
|
+
*/
|
|
20
26
|
type : {
|
|
21
27
|
type: String,
|
|
22
28
|
validator: function (value) {
|
|
23
29
|
return ['text', 'number', 'percentage', 'currency'].indexOf(value) !== -1
|
|
24
30
|
}
|
|
25
31
|
},
|
|
32
|
+
/**
|
|
33
|
+
* Component's value
|
|
34
|
+
*/
|
|
26
35
|
value: {
|
|
27
36
|
type: [String, Number],
|
|
28
37
|
required: true
|
|
29
38
|
},
|
|
39
|
+
/**
|
|
40
|
+
* Component's label
|
|
41
|
+
*/
|
|
30
42
|
label: {
|
|
31
43
|
type: String,
|
|
32
44
|
default: ""
|
|
33
45
|
},
|
|
46
|
+
/**
|
|
47
|
+
* Currency Code
|
|
48
|
+
*/
|
|
34
49
|
currencyCode:{
|
|
35
50
|
type:String,
|
|
36
51
|
required:false,
|
|
37
52
|
default:'GBP'
|
|
38
53
|
},
|
|
54
|
+
/**
|
|
55
|
+
* Currency locale
|
|
56
|
+
*/
|
|
39
57
|
currencyLocale:{
|
|
40
58
|
type:String,
|
|
41
59
|
required:false,
|
|
42
60
|
default:'en-GB'
|
|
43
61
|
},
|
|
62
|
+
/**
|
|
63
|
+
* Currency denomination
|
|
64
|
+
*/
|
|
44
65
|
currencyDenomination: {
|
|
45
66
|
type: Number,
|
|
46
67
|
default: 100
|
|
47
68
|
}
|
|
48
69
|
},
|
|
49
70
|
computed: {
|
|
71
|
+
/**
|
|
72
|
+
* Formats the value to be shown
|
|
73
|
+
* @return String
|
|
74
|
+
*/
|
|
75
|
+
metricValue() {
|
|
76
|
+
switch (this.type) {
|
|
77
|
+
case 'currency':
|
|
78
|
+
return (this.value/this.currencyDenomination).toLocaleString(this.currencyLocale, {style: 'currency', currency: this.currencyCode});
|
|
79
|
+
case'percentage':
|
|
80
|
+
return `${this.value} %`
|
|
81
|
+
default:
|
|
82
|
+
return this.value.toLocaleString();
|
|
50
83
|
|
|
51
|
-
|
|
52
|
-
switch (this.type) {
|
|
53
|
-
case 'currency':
|
|
54
|
-
return (this.value/this.currencyDenomination).toLocaleString(this.currencyLocale, {style: 'currency', currency: this.currencyCode});
|
|
55
|
-
case'percentage':
|
|
56
|
-
return `${this.value} %`
|
|
57
|
-
default:
|
|
58
|
-
return this.value.toLocaleString();
|
|
59
|
-
|
|
84
|
+
}
|
|
60
85
|
}
|
|
61
|
-
}
|
|
62
86
|
|
|
63
87
|
|
|
64
88
|
}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
<ToggleMetricSingleMetric :value="singleMetricVal" :label="label" :type="type" :currencyCode="currencyCode" :currencyLocale="currencyLocale" :currencyDenomination="currencyDenomination"/>
|
|
10
10
|
|
|
11
|
-
<apexchart type="line" :height="height" :width="width" :options="chartOptions" :series="sparkLineVal" ref="
|
|
11
|
+
<apexchart type="line" :height="height" :width="width" :options="chartOptions" :series="sparkLineVal" ref="sparkLineRef">
|
|
12
12
|
</apexchart>
|
|
13
13
|
</div>
|
|
14
14
|
</template>
|
|
@@ -27,54 +27,90 @@ Vue.component('apexchart', VueApexCharts);
|
|
|
27
27
|
export default {
|
|
28
28
|
mixins:[charts],
|
|
29
29
|
props: {
|
|
30
|
+
/**
|
|
31
|
+
* Component's name
|
|
32
|
+
*/
|
|
30
33
|
name: {
|
|
31
34
|
type: String,
|
|
32
35
|
default: "ToggleMetricSingleMetric"
|
|
33
36
|
},
|
|
37
|
+
/**
|
|
38
|
+
* The line chart height
|
|
39
|
+
*/
|
|
34
40
|
height : {
|
|
35
41
|
type: String,
|
|
36
42
|
default: "25%"
|
|
37
43
|
},
|
|
44
|
+
/**
|
|
45
|
+
* The line chart width
|
|
46
|
+
*/
|
|
38
47
|
width : {
|
|
39
48
|
type: String,
|
|
40
49
|
default: "25%"
|
|
41
50
|
},
|
|
51
|
+
/**
|
|
52
|
+
* Type of the value, this will affect on the format shown for the single value
|
|
53
|
+
*/
|
|
42
54
|
type : {
|
|
43
55
|
type: String,
|
|
44
56
|
validator: function (value) {
|
|
45
57
|
return ['text', 'number', 'percentage', 'currency'].indexOf(value) !== -1
|
|
46
58
|
}
|
|
47
59
|
},
|
|
60
|
+
/**
|
|
61
|
+
* single metric component value
|
|
62
|
+
*/
|
|
48
63
|
singleMetricVal: {
|
|
49
64
|
type: [String, Number],
|
|
50
65
|
required: true
|
|
51
66
|
},
|
|
67
|
+
/**
|
|
68
|
+
* spark line component value
|
|
69
|
+
*/
|
|
52
70
|
sparkLineVal: {
|
|
53
71
|
type: Array,
|
|
54
72
|
required: true
|
|
55
73
|
},
|
|
74
|
+
/**
|
|
75
|
+
* Component's label
|
|
76
|
+
*/
|
|
56
77
|
label: {
|
|
57
78
|
type: String,
|
|
58
79
|
required: true
|
|
59
80
|
},
|
|
81
|
+
/**
|
|
82
|
+
* Currency Code
|
|
83
|
+
*/
|
|
60
84
|
currencyCode:{
|
|
61
85
|
type:String,
|
|
62
86
|
required:false,
|
|
63
87
|
default:'GBP'
|
|
64
88
|
},
|
|
89
|
+
/**
|
|
90
|
+
* Currency locale
|
|
91
|
+
*/
|
|
65
92
|
currencyLocale:{
|
|
66
93
|
type:String,
|
|
67
94
|
required:false,
|
|
68
95
|
default:'en-GB'
|
|
69
96
|
},
|
|
97
|
+
/**
|
|
98
|
+
* Currency denomination
|
|
99
|
+
*/
|
|
70
100
|
currencyDenomination: {
|
|
71
101
|
type: Number,
|
|
72
102
|
default: 100
|
|
73
103
|
},
|
|
104
|
+
/**
|
|
105
|
+
* Percentage base used to calculate the trend impact
|
|
106
|
+
*/
|
|
74
107
|
trend_impact_percentage :{
|
|
75
108
|
type: Number,
|
|
76
109
|
default: 5
|
|
77
110
|
},
|
|
111
|
+
/**
|
|
112
|
+
* This prop will inverse the trend impact
|
|
113
|
+
*/
|
|
78
114
|
inverse_trend_impact: {
|
|
79
115
|
type: Boolean,
|
|
80
116
|
default: false
|
|
@@ -119,13 +155,20 @@ export default {
|
|
|
119
155
|
this.updateTrend();
|
|
120
156
|
},
|
|
121
157
|
computed: {
|
|
122
|
-
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Defines the badge class from the trending impact
|
|
161
|
+
* @return String
|
|
162
|
+
*/
|
|
123
163
|
trendImpactClass() {
|
|
124
164
|
return this.getTrendImpact() === 1 ? 'confirm'
|
|
125
165
|
: this.getTrendImpact() === -1 ? 'abort'
|
|
126
166
|
: 'warning'
|
|
127
167
|
},
|
|
128
|
-
|
|
168
|
+
/**
|
|
169
|
+
* Defines the badge title from the trending impact
|
|
170
|
+
* @return String
|
|
171
|
+
*/
|
|
129
172
|
trendImpactLabel() {
|
|
130
173
|
return this.getTrendImpact() === 1 ? 'Trending up'
|
|
131
174
|
: this.getTrendImpact() === -1 ? 'Going down'
|
|
@@ -133,6 +176,10 @@ export default {
|
|
|
133
176
|
}
|
|
134
177
|
},
|
|
135
178
|
methods: {
|
|
179
|
+
/**
|
|
180
|
+
* Gets the trend impact from mixing method
|
|
181
|
+
* @return Integer
|
|
182
|
+
*/
|
|
136
183
|
getTrendImpact() {
|
|
137
184
|
|
|
138
185
|
// if the value is an object, map to array
|
|
@@ -143,6 +190,10 @@ export default {
|
|
|
143
190
|
return this.inverse_trend_impact === true ? result = result *-1 : result;
|
|
144
191
|
},
|
|
145
192
|
|
|
193
|
+
/**
|
|
194
|
+
* Gets trend impact and udpates the chart with respective color
|
|
195
|
+
* @return Void
|
|
196
|
+
*/
|
|
146
197
|
updateTrend() {
|
|
147
198
|
this.trendImpact = this.getTrendImpact();
|
|
148
199
|
|
|
@@ -159,8 +210,12 @@ export default {
|
|
|
159
210
|
}
|
|
160
211
|
},
|
|
161
212
|
|
|
213
|
+
/**
|
|
214
|
+
* Updates the spark line chart component colors
|
|
215
|
+
* @return Void
|
|
216
|
+
*/
|
|
162
217
|
updateChart(colors) {
|
|
163
|
-
this.$refs.
|
|
218
|
+
this.$refs.sparkLineRef.updateOptions({ colors: colors });
|
|
164
219
|
}
|
|
165
220
|
}
|
|
166
221
|
}
|
|
@@ -107,7 +107,7 @@ export const charts = {
|
|
|
107
107
|
data: function() {
|
|
108
108
|
return {
|
|
109
109
|
|
|
110
|
-
|
|
110
|
+
defcolors: [
|
|
111
111
|
'#FF9494','#FFCA8A','#FCFF9D','#B2FFA2','#81F4FF','#85B4FF','#A898FF'
|
|
112
112
|
]
|
|
113
113
|
}
|
|
@@ -152,7 +152,7 @@ export const charts = {
|
|
|
152
152
|
|
|
153
153
|
//return an array of default colors
|
|
154
154
|
getDefaultColors() {
|
|
155
|
-
return this.$data.
|
|
155
|
+
return this.$data.defcolors;
|
|
156
156
|
},
|
|
157
157
|
|
|
158
158
|
//return a specific color
|