-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreport.jsx
More file actions
47 lines (39 loc) · 1.27 KB
/
Copy pathreport.jsx
File metadata and controls
47 lines (39 loc) · 1.27 KB
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
var React = require('react');
var ReactPivot = require('react-pivot');
var createReactClass = require('create-react-class');
var rows = require('./data.json');
var defaultCol = ['date', 'host'];
function reduce (row, memo) {
memo.displays = row.type == 'display' ? (memo.displays || 0) + 1 : memo.displays;
memo.loads = row.type == 'load' ? (memo.loads || 0) + 1 : memo.loads;
memo.impressions = row.type == 'impression' ? (memo.impressions || 0) + 1 : memo.impressions;
memo.loadRate = (memo.loads / memo.impressions * 100).toFixed(1);
memo.displayRate = (memo.displays / memo.loads * 100).toFixed(1);
return memo
}
var dimensions = [
{value: 'host', title: 'host'},
{value: 'date', title: 'date'}
]
var calculations = [
{ title: 'Displays', value: 'displays' },
{ title: 'Impressions', value: 'impressions' },
{ title: 'Loads', value: 'loads' },
{ title: 'Load Rate', value: 'loadRate',
template: (val) => `${val}%`
}, {
title: 'Display Rate', value: 'displayRate',
template: (val) => `${val}%`
}
]
module.exports = createReactClass({
render () {
return <div>
<ReactPivot rows={rows}
dimensions={dimensions}
reduce={reduce}
calculations={calculations}
activeDimensions={defaultCol}/>,
</div>
}
})