toggle-components-library 1.23.7 → 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/img/funnel.7fa095c3.svg +11 -0
- package/dist/toggle-components-library.common.js +1244 -104
- package/dist/toggle-components-library.common.js.map +1 -1
- package/dist/toggle-components-library.css +1 -1
- package/dist/toggle-components-library.umd.js +1244 -104
- package/dist/toggle-components-library.umd.js.map +1 -1
- package/dist/toggle-components-library.umd.min.js +16 -3
- package/dist/toggle-components-library.umd.min.js.map +1 -1
- package/package.json +12 -10
- package/src/assets/img/funnel.svg +11 -0
- package/src/components/metrics/ToggleMetricBarChart.vue +128 -0
- package/src/components/metrics/ToggleMetricFunnelChart.vue +54 -0
- package/src/components/metrics/ToggleMetricPieChart.vue +90 -0
- package/src/components/metrics/ToggleMetricSingleMetric.vue +92 -0
- package/src/components/metrics/ToggleMetricSparkLine.vue +223 -0
- package/src/components/mixins/mixins.js +76 -0
- package/src/index.js +12 -1
- package/src/sass/includes/_as_badges.scss +4 -0
- package/src/sass/includes/_as_loaders.scss +1 -1
- package/src/sass/includes/_as_metrics.scss +102 -0
- package/src/sass/includes/_as_variables.scss +19 -0
- package/src/sass/main.scss +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "toggle-components-library",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.24.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"scripts": {
|
|
6
6
|
"serve": "vue-cli-service serve",
|
|
@@ -24,25 +24,27 @@
|
|
|
24
24
|
"*.js"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"
|
|
27
|
+
"apexcharts": "^3.35.5",
|
|
28
|
+
"core-js": "^3.25.0",
|
|
28
29
|
"countries-list": "^2.6.1",
|
|
29
30
|
"date-fns": "^1.30.1",
|
|
30
31
|
"storybook-vue-router": "^1.0.7",
|
|
31
|
-
"vue": "^2.
|
|
32
|
+
"vue": "^2.7.10",
|
|
32
33
|
"vue-airbnb-style-datepicker": "^2.7.1",
|
|
34
|
+
"vue-apexcharts": "^1.6.2",
|
|
33
35
|
"vue-color": "^2.7.1",
|
|
34
36
|
"vue-moment": "^4.1.0",
|
|
35
37
|
"vue-multiselect": "^2.0.8",
|
|
36
|
-
"vue-router": "^3.4
|
|
38
|
+
"vue-router": "^3.6.4",
|
|
37
39
|
"vue2-dropzone": "^3.6.0",
|
|
38
40
|
"vuedraggable": "^2.24.3",
|
|
39
41
|
"webfontloader": "^1.6.28"
|
|
40
42
|
},
|
|
41
43
|
"devDependencies": {
|
|
42
|
-
"@babel/core": "^7.
|
|
43
|
-
"@storybook/addon-actions": "^6.
|
|
44
|
-
"@storybook/addon-docs": "^6.
|
|
45
|
-
"@storybook/vue": "^6.
|
|
44
|
+
"@babel/core": "^7.18.13",
|
|
45
|
+
"@storybook/addon-actions": "^6.5.10",
|
|
46
|
+
"@storybook/addon-docs": "^6.5.10",
|
|
47
|
+
"@storybook/vue": "^6.5.10",
|
|
46
48
|
"@vue/cli-plugin-babel": "^4.5.3",
|
|
47
49
|
"@vue/cli-plugin-eslint": "^4.5.3",
|
|
48
50
|
"@vue/cli-service": "^4.5.3",
|
|
@@ -53,9 +55,9 @@
|
|
|
53
55
|
"eslint-plugin-vue": "^6.2.2",
|
|
54
56
|
"react": "^16.13.1",
|
|
55
57
|
"react-is": "^16.13.1",
|
|
56
|
-
"sass": "^1.
|
|
58
|
+
"sass": "^1.54.5",
|
|
57
59
|
"sass-loader": "^8.0.2",
|
|
58
|
-
"vue-template-compiler": "^2.
|
|
60
|
+
"vue-template-compiler": "^2.7.10"
|
|
59
61
|
},
|
|
60
62
|
"eslintConfig": {
|
|
61
63
|
"root": true,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1070.503" height="166.653" viewBox="0 0 1070.503 166.653">
|
|
2
|
+
<defs>
|
|
3
|
+
<linearGradient id="linear-gradient" x1="0.993" y1="0.5" x2="0" y2="0.5" gradientUnits="objectBoundingBox">
|
|
4
|
+
<stop offset="0" stop-color="#f7f7f7"/>
|
|
5
|
+
<stop offset="1" stop-color="#dce9f7"/>
|
|
6
|
+
</linearGradient>
|
|
7
|
+
</defs>
|
|
8
|
+
<g id="Group_222" data-name="Group 222" transform="translate(-182.585 -931.326)">
|
|
9
|
+
<path id="Union_1" data-name="Union 1" d="M0,166.653V0H84.287C169.914,0,342.83,37.691,448.053,37.691H625.967c132,0,148.131,20.785,269.689,20.785s174.859-.288,174.846,0c-.027.233-.012,16.421,0,22.1h0s0,.359,0,.993c0,.607,0,.952,0,.952h0c-.01,5.848-.025,22.889,0,23.137.014.3-53.289,0-174.846,0S757.971,127.34,625.967,127.34H448.053c-105.223,0-278.139,39.313-363.766,39.313Zm0,0ZM0,0Z" transform="translate(182.586 931.326)" fill="url(#linear-gradient)"/>
|
|
10
|
+
</g>
|
|
11
|
+
</svg>
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<h3 class="toggle-metric metric-label">{{label}}</h3>
|
|
4
|
+
<apexchart type="bar" :height="height" :options="chartOptions" :series="values"></apexchart>
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script>
|
|
10
|
+
import {charts} from "../mixins/mixins";
|
|
11
|
+
|
|
12
|
+
export default {
|
|
13
|
+
|
|
14
|
+
mixins:[charts],
|
|
15
|
+
|
|
16
|
+
props: {
|
|
17
|
+
/**
|
|
18
|
+
* Used to overwrite the default colors
|
|
19
|
+
*/
|
|
20
|
+
colors: {
|
|
21
|
+
type: [Array]
|
|
22
|
+
},
|
|
23
|
+
/*
|
|
24
|
+
* Component's height
|
|
25
|
+
*/
|
|
26
|
+
height: {
|
|
27
|
+
type: String,
|
|
28
|
+
default: "100%"
|
|
29
|
+
},
|
|
30
|
+
/*
|
|
31
|
+
* Component's values
|
|
32
|
+
*/
|
|
33
|
+
values: {
|
|
34
|
+
type: [Array],
|
|
35
|
+
required: true
|
|
36
|
+
},
|
|
37
|
+
/*
|
|
38
|
+
* Component's labels
|
|
39
|
+
*/
|
|
40
|
+
label: {
|
|
41
|
+
type: String,
|
|
42
|
+
required: true
|
|
43
|
+
},
|
|
44
|
+
/*
|
|
45
|
+
* Component's categories
|
|
46
|
+
*/
|
|
47
|
+
categories: {
|
|
48
|
+
type: [Array],
|
|
49
|
+
required: true
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
computed: {
|
|
54
|
+
/**
|
|
55
|
+
* define the pie chart options
|
|
56
|
+
* @return Object
|
|
57
|
+
*/
|
|
58
|
+
chartOptions() {
|
|
59
|
+
return {
|
|
60
|
+
plotOptions: {
|
|
61
|
+
bar: {
|
|
62
|
+
borderRadius: 5,
|
|
63
|
+
columnWidth: '60%',
|
|
64
|
+
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
},
|
|
68
|
+
chart: {
|
|
69
|
+
toolbar: {
|
|
70
|
+
show: false
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
grid: {
|
|
74
|
+
|
|
75
|
+
show: false,
|
|
76
|
+
},
|
|
77
|
+
dataLabels: {
|
|
78
|
+
enabled: false,
|
|
79
|
+
},
|
|
80
|
+
xaxis: {
|
|
81
|
+
categories: this.categories,
|
|
82
|
+
labels: {
|
|
83
|
+
style: {
|
|
84
|
+
padding: '20px',
|
|
85
|
+
fontSize: '1rem',
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
},
|
|
90
|
+
yaxis: {
|
|
91
|
+
|
|
92
|
+
show: true,
|
|
93
|
+
labels: {
|
|
94
|
+
show: false
|
|
95
|
+
},
|
|
96
|
+
axisBorder: {
|
|
97
|
+
show: true,
|
|
98
|
+
color: this.getColor('gray'),
|
|
99
|
+
width: 3
|
|
100
|
+
},
|
|
101
|
+
axisTicks: {
|
|
102
|
+
show: false
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
|
|
106
|
+
colors: this.colors ? this.colors : this.getDefaultColors(),
|
|
107
|
+
legend: {
|
|
108
|
+
horizontalAlign: 'left',
|
|
109
|
+
offsetX: -12,
|
|
110
|
+
showForSingleSeries: true,
|
|
111
|
+
markers: {
|
|
112
|
+
width: 50,
|
|
113
|
+
radius: 5,
|
|
114
|
+
offsetY: 3
|
|
115
|
+
},
|
|
116
|
+
|
|
117
|
+
itemMargin: {
|
|
118
|
+
horizontal: 5,
|
|
119
|
+
vertical: 0
|
|
120
|
+
},
|
|
121
|
+
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
};
|
|
128
|
+
</script>
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="toggle-metric-funnel-container">
|
|
3
|
+
|
|
4
|
+
<div class="funnel-grid-svg"></div>
|
|
5
|
+
|
|
6
|
+
<div class="funnel-spark-line funnel-grid-1">
|
|
7
|
+
<slot name="sparkLine1"></slot>
|
|
8
|
+
</div>
|
|
9
|
+
<div class="funnel-spark-line funnel-grid-2">
|
|
10
|
+
<slot name="sparkLine2"></slot>
|
|
11
|
+
</div>
|
|
12
|
+
<div class="funnel-spark-line funnel-grid-3">
|
|
13
|
+
<slot name="sparkLine3"></slot>
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
<div class="funnel-single-metric funnel-grid-4">
|
|
17
|
+
<div class="funnel-single-metric-container">
|
|
18
|
+
<slot name="funnel1" class="funnel-single-metric"></slot>
|
|
19
|
+
</div>
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
<div class="funnel-single-metric funnel-grid-5">
|
|
23
|
+
<div class="funnel-single-metric-container">
|
|
24
|
+
<slot name="funnel2" class="funnel-single-metric"></slot>
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
27
|
+
|
|
28
|
+
<div class="funnel-single-metric funnel-grid-6">
|
|
29
|
+
<div class="funnel-single-metric-container">
|
|
30
|
+
<slot name="funnel3" class="funnel-single-metric"></slot>
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
|
|
34
|
+
</div>
|
|
35
|
+
</template>
|
|
36
|
+
|
|
37
|
+
<script>
|
|
38
|
+
|
|
39
|
+
import { mixins } from '../mixins/mixins'
|
|
40
|
+
|
|
41
|
+
export default {
|
|
42
|
+
mixins:[mixins],
|
|
43
|
+
props: {
|
|
44
|
+
/*
|
|
45
|
+
* Component's name
|
|
46
|
+
*/
|
|
47
|
+
name: {
|
|
48
|
+
type: String,
|
|
49
|
+
default: "ToggleMetricFunnelChart"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
</script>
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<h3 class="toggle-metric metric-label">{{label}}</h3>
|
|
4
|
+
<apexchart type="pie" :options="chartOptions" :series="values"></apexchart>
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script>
|
|
10
|
+
|
|
11
|
+
import {charts} from "../mixins/mixins";
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
|
+
mixins:[charts],
|
|
15
|
+
|
|
16
|
+
props: {
|
|
17
|
+
/**
|
|
18
|
+
* Used to overwrite the default colors
|
|
19
|
+
*/
|
|
20
|
+
colors: {
|
|
21
|
+
type: [String]
|
|
22
|
+
},
|
|
23
|
+
/**
|
|
24
|
+
* Component's values
|
|
25
|
+
*/
|
|
26
|
+
values: {
|
|
27
|
+
type: Array,
|
|
28
|
+
required: true
|
|
29
|
+
},
|
|
30
|
+
/**
|
|
31
|
+
* Component's main label
|
|
32
|
+
*/
|
|
33
|
+
label: {
|
|
34
|
+
type: String,
|
|
35
|
+
required: true
|
|
36
|
+
},
|
|
37
|
+
/**
|
|
38
|
+
* Component's label for each value
|
|
39
|
+
*/
|
|
40
|
+
labels: {
|
|
41
|
+
type: Array,
|
|
42
|
+
required: true
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
computed: {
|
|
46
|
+
/**
|
|
47
|
+
* define the pie chart options
|
|
48
|
+
* @return Object
|
|
49
|
+
*/
|
|
50
|
+
chartOptions() {
|
|
51
|
+
return {
|
|
52
|
+
labels: this.labels,
|
|
53
|
+
plotOptions: {
|
|
54
|
+
pie: {
|
|
55
|
+
customScale: 0.7,
|
|
56
|
+
dataLabels: {
|
|
57
|
+
offset: 125
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
colors: this.colors ? this.colors : this.getDefaultColors(),
|
|
62
|
+
dataLabels: {
|
|
63
|
+
enabledOnSeries: true,
|
|
64
|
+
formatter: function (val, {seriesIndex, w}) {
|
|
65
|
+
return `${w.globals.labels[seriesIndex]} ${val}%`
|
|
66
|
+
},
|
|
67
|
+
style: {
|
|
68
|
+
colors: [this.getColor('black')],
|
|
69
|
+
fontSize: '2rem',
|
|
70
|
+
},
|
|
71
|
+
background: {
|
|
72
|
+
enabled: false,
|
|
73
|
+
},
|
|
74
|
+
dropShadow: {
|
|
75
|
+
enabled: false,
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
legend: {
|
|
80
|
+
show: false,
|
|
81
|
+
},
|
|
82
|
+
tooltip: {
|
|
83
|
+
enabled: false
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
};
|
|
90
|
+
</script>
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<h3 class="toggle-metric metric-label">{{label}}</h3>
|
|
4
|
+
<h1 class="toggle-metric metric-value">{{metricValue}}</h1>
|
|
5
|
+
</div>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script>
|
|
9
|
+
|
|
10
|
+
import { mixins } from '../mixins/mixins'
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
|
+
mixins:[mixins],
|
|
15
|
+
props: {
|
|
16
|
+
/**
|
|
17
|
+
* Component's name
|
|
18
|
+
*/
|
|
19
|
+
name: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: "ToggleMetricSingleMetric"
|
|
22
|
+
},
|
|
23
|
+
/**
|
|
24
|
+
* Type of the value, this will affect on the format shown
|
|
25
|
+
*/
|
|
26
|
+
type : {
|
|
27
|
+
type: String,
|
|
28
|
+
validator: function (value) {
|
|
29
|
+
return ['text', 'number', 'percentage', 'currency'].indexOf(value) !== -1
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
/**
|
|
33
|
+
* Component's value
|
|
34
|
+
*/
|
|
35
|
+
value: {
|
|
36
|
+
type: [String, Number],
|
|
37
|
+
required: true
|
|
38
|
+
},
|
|
39
|
+
/**
|
|
40
|
+
* Component's label
|
|
41
|
+
*/
|
|
42
|
+
label: {
|
|
43
|
+
type: String,
|
|
44
|
+
default: ""
|
|
45
|
+
},
|
|
46
|
+
/**
|
|
47
|
+
* Currency Code
|
|
48
|
+
*/
|
|
49
|
+
currencyCode:{
|
|
50
|
+
type:String,
|
|
51
|
+
required:false,
|
|
52
|
+
default:'GBP'
|
|
53
|
+
},
|
|
54
|
+
/**
|
|
55
|
+
* Currency locale
|
|
56
|
+
*/
|
|
57
|
+
currencyLocale:{
|
|
58
|
+
type:String,
|
|
59
|
+
required:false,
|
|
60
|
+
default:'en-GB'
|
|
61
|
+
},
|
|
62
|
+
/**
|
|
63
|
+
* Currency denomination
|
|
64
|
+
*/
|
|
65
|
+
currencyDenomination: {
|
|
66
|
+
type: Number,
|
|
67
|
+
default: 100
|
|
68
|
+
}
|
|
69
|
+
},
|
|
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();
|
|
83
|
+
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
</script>
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<ToggleBadge style="margin-bottom: 10px"
|
|
4
|
+
:badgeStyle="trendImpactClass"
|
|
5
|
+
>
|
|
6
|
+
{{trendImpactLabel}}
|
|
7
|
+
</ToggleBadge>
|
|
8
|
+
|
|
9
|
+
<ToggleMetricSingleMetric :value="singleMetricVal" :label="label" :type="type" :currencyCode="currencyCode" :currencyLocale="currencyLocale" :currencyDenomination="currencyDenomination"/>
|
|
10
|
+
|
|
11
|
+
<apexchart type="line" :height="height" :width="width" :options="chartOptions" :series="sparkLineVal" ref="sparkLineRef">
|
|
12
|
+
</apexchart>
|
|
13
|
+
</div>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script>
|
|
17
|
+
|
|
18
|
+
import Vue from "vue";
|
|
19
|
+
import {charts} from "../mixins/mixins";
|
|
20
|
+
import ToggleMetricSingleMetric from './ToggleMetricSingleMetric.vue';
|
|
21
|
+
import ToggleBadge from '../badges/ToggleBadge.vue';
|
|
22
|
+
import VueApexCharts from 'vue-apexcharts'
|
|
23
|
+
|
|
24
|
+
Vue.use(VueApexCharts);
|
|
25
|
+
Vue.component('apexchart', VueApexCharts);
|
|
26
|
+
|
|
27
|
+
export default {
|
|
28
|
+
mixins:[charts],
|
|
29
|
+
props: {
|
|
30
|
+
/**
|
|
31
|
+
* Component's name
|
|
32
|
+
*/
|
|
33
|
+
name: {
|
|
34
|
+
type: String,
|
|
35
|
+
default: "ToggleMetricSingleMetric"
|
|
36
|
+
},
|
|
37
|
+
/**
|
|
38
|
+
* The line chart height
|
|
39
|
+
*/
|
|
40
|
+
height : {
|
|
41
|
+
type: String,
|
|
42
|
+
default: "25%"
|
|
43
|
+
},
|
|
44
|
+
/**
|
|
45
|
+
* The line chart width
|
|
46
|
+
*/
|
|
47
|
+
width : {
|
|
48
|
+
type: String,
|
|
49
|
+
default: "25%"
|
|
50
|
+
},
|
|
51
|
+
/**
|
|
52
|
+
* Type of the value, this will affect on the format shown for the single value
|
|
53
|
+
*/
|
|
54
|
+
type : {
|
|
55
|
+
type: String,
|
|
56
|
+
validator: function (value) {
|
|
57
|
+
return ['text', 'number', 'percentage', 'currency'].indexOf(value) !== -1
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
/**
|
|
61
|
+
* single metric component value
|
|
62
|
+
*/
|
|
63
|
+
singleMetricVal: {
|
|
64
|
+
type: [String, Number],
|
|
65
|
+
required: true
|
|
66
|
+
},
|
|
67
|
+
/**
|
|
68
|
+
* spark line component value
|
|
69
|
+
*/
|
|
70
|
+
sparkLineVal: {
|
|
71
|
+
type: Array,
|
|
72
|
+
required: true
|
|
73
|
+
},
|
|
74
|
+
/**
|
|
75
|
+
* Component's label
|
|
76
|
+
*/
|
|
77
|
+
label: {
|
|
78
|
+
type: String,
|
|
79
|
+
required: true
|
|
80
|
+
},
|
|
81
|
+
/**
|
|
82
|
+
* Currency Code
|
|
83
|
+
*/
|
|
84
|
+
currencyCode:{
|
|
85
|
+
type:String,
|
|
86
|
+
required:false,
|
|
87
|
+
default:'GBP'
|
|
88
|
+
},
|
|
89
|
+
/**
|
|
90
|
+
* Currency locale
|
|
91
|
+
*/
|
|
92
|
+
currencyLocale:{
|
|
93
|
+
type:String,
|
|
94
|
+
required:false,
|
|
95
|
+
default:'en-GB'
|
|
96
|
+
},
|
|
97
|
+
/**
|
|
98
|
+
* Currency denomination
|
|
99
|
+
*/
|
|
100
|
+
currencyDenomination: {
|
|
101
|
+
type: Number,
|
|
102
|
+
default: 100
|
|
103
|
+
},
|
|
104
|
+
/**
|
|
105
|
+
* Percentage base used to calculate the trend impact
|
|
106
|
+
*/
|
|
107
|
+
trend_impact_percentage :{
|
|
108
|
+
type: Number,
|
|
109
|
+
default: 5
|
|
110
|
+
},
|
|
111
|
+
/**
|
|
112
|
+
* This prop will inverse the trend impact
|
|
113
|
+
*/
|
|
114
|
+
inverse_trend_impact: {
|
|
115
|
+
type: Boolean,
|
|
116
|
+
default: false
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
components: {
|
|
121
|
+
ToggleMetricSingleMetric,
|
|
122
|
+
ToggleBadge
|
|
123
|
+
},
|
|
124
|
+
|
|
125
|
+
data : function(){
|
|
126
|
+
return {
|
|
127
|
+
trendImpact: 0,
|
|
128
|
+
chartOptions: {
|
|
129
|
+
chart: {
|
|
130
|
+
sparkline: {
|
|
131
|
+
enabled: true,
|
|
132
|
+
},
|
|
133
|
+
defaultLocale: 'en',
|
|
134
|
+
redrawOnParentResize: true,
|
|
135
|
+
redrawOnWindowResize: true,
|
|
136
|
+
},
|
|
137
|
+
stroke: {
|
|
138
|
+
width: 5
|
|
139
|
+
},
|
|
140
|
+
noData: {
|
|
141
|
+
text: "No data found",
|
|
142
|
+
align: 'left',
|
|
143
|
+
verticalAlign: 'top',
|
|
144
|
+
offsetX: 0,
|
|
145
|
+
offsetY: 0
|
|
146
|
+
},
|
|
147
|
+
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
},
|
|
151
|
+
mounted() {
|
|
152
|
+
this.updateTrend();
|
|
153
|
+
},
|
|
154
|
+
updated() {
|
|
155
|
+
this.updateTrend();
|
|
156
|
+
},
|
|
157
|
+
computed: {
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Defines the badge class from the trending impact
|
|
161
|
+
* @return String
|
|
162
|
+
*/
|
|
163
|
+
trendImpactClass() {
|
|
164
|
+
return this.getTrendImpact() === 1 ? 'confirm'
|
|
165
|
+
: this.getTrendImpact() === -1 ? 'abort'
|
|
166
|
+
: 'warning'
|
|
167
|
+
},
|
|
168
|
+
/**
|
|
169
|
+
* Defines the badge title from the trending impact
|
|
170
|
+
* @return String
|
|
171
|
+
*/
|
|
172
|
+
trendImpactLabel() {
|
|
173
|
+
return this.getTrendImpact() === 1 ? 'Trending up'
|
|
174
|
+
: this.getTrendImpact() === -1 ? 'Going down'
|
|
175
|
+
: 'Keeping steady'
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
methods: {
|
|
179
|
+
/**
|
|
180
|
+
* Gets the trend impact from mixing method
|
|
181
|
+
* @return Integer
|
|
182
|
+
*/
|
|
183
|
+
getTrendImpact() {
|
|
184
|
+
|
|
185
|
+
// if the value is an object, map to array
|
|
186
|
+
|
|
187
|
+
const trendImpactVals = this.sparkLineVal[0].data[0].y ? this.sparkLineVal[0].data.map(data => data.y) : this.sparkLineVal[0].data;
|
|
188
|
+
|
|
189
|
+
let result = this.calcTrendImpact(trendImpactVals, this.trend_impact_percentage);
|
|
190
|
+
return this.inverse_trend_impact === true ? result = result *-1 : result;
|
|
191
|
+
},
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Gets trend impact and udpates the chart with respective color
|
|
195
|
+
* @return Void
|
|
196
|
+
*/
|
|
197
|
+
updateTrend() {
|
|
198
|
+
this.trendImpact = this.getTrendImpact();
|
|
199
|
+
|
|
200
|
+
switch (this.trendImpact) {
|
|
201
|
+
case 1:
|
|
202
|
+
this.updateChart([this.getColor('green')]);
|
|
203
|
+
break;
|
|
204
|
+
case 0:
|
|
205
|
+
this.updateChart([this.getColor('amber')]);
|
|
206
|
+
break;
|
|
207
|
+
case -1:
|
|
208
|
+
this.updateChart([this.getColor('red')]);
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Updates the spark line chart component colors
|
|
215
|
+
* @return Void
|
|
216
|
+
*/
|
|
217
|
+
updateChart(colors) {
|
|
218
|
+
this.$refs.sparkLineRef.updateOptions({ colors: colors });
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
</script>
|