-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathUsersByDeviceLite.vue
118 lines (108 loc) · 2.38 KB
/
UsersByDeviceLite.vue
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
<template>
<div class="card card-small h-100">
<!-- Card Header -->
<div class="card-header border-bottom">
<h6 class="m-0">{{title}}</h6>
</div>
<!-- Chart -->
<div class="card-body d-flex py-0">
<canvas height="220" ref="canvas" class="blog-users-by-device m-auto"></canvas>
</div>
<d-card-footer class="border-top">
<d-row>
<!-- Time Frame -->
<d-col>
<d-select size="sm" value="last-week" style="max-width: 130px;">
<option value="last-week">Last Week</option>
<option value="today">Today</option>
<option value="last-month">Last Month</option>
<option value="last-year">Last Year</option>
</d-select>
</d-col>
<!-- View Full Report -->
<d-col class="text-right view-report">
<a href="#">View full report →</a>
</d-col>
</d-row>
</d-card-footer>
</div>
</template>
<script>
import Chart from '../../utils/chart';
const defaultChartData = {
datasets: [{
hoverBorderColor: '#ffffff',
data: [68.3, 24.2, 7.5],
backgroundColor: [
'rgba(0,123,255,0.9)',
'rgba(0,123,255,0.5)',
'rgba(0,123,255,0.3)',
],
}],
labels: ['Desktop', 'Tablet', 'Mobile'],
};
export default {
name: 'users-by-device',
props: {
/**
* The chart config.
*/
chartConfig: {
type: Object,
default() {
return {};
},
},
/**
* The chart options.
*/
chartOptions: {
type: Object,
default() {
return {};
},
},
/**
* The chart data.
*/
chartData: {
type: Object,
default() {
return defaultChartData;
},
},
/**
* The chart title.
*/
title: {
type: String,
default: 'Users by device',
},
},
mounted() {
const chartConfig = {
type: 'pie',
data: this.chartData,
options: {
...{
legend: {
position: 'bottom',
labels: {
padding: 25,
boxWidth: 20,
},
},
cutoutPercentage: 0,
tooltips: {
custom: false,
mode: 'index',
position: 'nearest',
},
},
...this.chartOptions,
},
};
new Chart(this.$refs.canvas, chartConfig);
},
};
</script>