forked from mattermost/mattermost-webapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
format.jsx
85 lines (75 loc) · 2.61 KB
/
format.jsx
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
import * as Utils from 'utils/utils.jsx';
export function formatChannelDoughtnutData(totalPublic, totalPrivate) {
const channelTypeData = {
labels: [
Utils.localizeMessage('analytics.system.publicChannels', 'Public Channels'),
Utils.localizeMessage('analytics.system.privateGroups', 'Private Channels'),
],
datasets: [{
data: [totalPublic, totalPrivate],
backgroundColor: ['#46BFBD', '#FDB45C'],
hoverBackgroundColor: ['#5AD3D1', '#FFC870'],
}],
};
return channelTypeData;
}
export function formatPostDoughtnutData(filePosts, hashtagPosts, totalPosts) {
const postTypeData = {
labels: [
Utils.localizeMessage('analytics.system.totalFilePosts', 'Posts with Files'),
Utils.localizeMessage('analytics.system.totalHashtagPosts', 'Posts with Hashtags'),
Utils.localizeMessage('analytics.system.textPosts', 'Posts with Text-only'),
],
datasets: [{
data: [filePosts, hashtagPosts, (totalPosts - filePosts - hashtagPosts)],
backgroundColor: ['#46BFBD', '#F7464A', '#FDB45C'],
hoverBackgroundColor: ['#5AD3D1', '#FF5A5E', '#FFC870'],
}],
};
return postTypeData;
}
export function formatPostsPerDayData(data) {
var chartData = {
labels: [],
datasets: [{
fillColor: 'rgba(151,187,205,0.2)',
borderColor: 'rgba(151,187,205,1)',
pointBackgroundColor: 'rgba(151,187,205,1)',
pointBorderColor: '#fff',
pointHoverBackgroundColor: '#fff',
pointHoverBorderColor: 'rgba(151,187,205,1)',
data: [],
}],
};
for (var index in data) {
if (data[index]) {
var row = data[index];
chartData.labels.push(row.name);
chartData.datasets[0].data.push(row.value);
}
}
return chartData;
}
export function formatUsersWithPostsPerDayData(data) {
var chartData = {
labels: [],
datasets: [{
label: '',
fillColor: 'rgba(151,187,205,0.2)',
borderColor: 'rgba(151,187,205,1)',
pointBackgroundColor: 'rgba(151,187,205,1)',
pointBorderColor: '#fff',
pointHoverBackgroundColor: '#fff',
pointHoverBorderColor: 'rgba(151,187,205,1)',
data: [],
}],
};
for (var index in data) {
if (data[index]) {
var row = data[index];
chartData.labels.push(row.name);
chartData.datasets[0].data.push(row.value);
}
}
return chartData;
}