-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
53 lines (48 loc) · 1.87 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="https://cdn.mxpnl.com/libs/mixpanel-platform/css/reset.css">
<link rel="stylesheet" type="text/css" href="https://cdn.mxpnl.com/libs/mixpanel-platform/build/mixpanel-platform.v0.latest.min.css">
<script src="https://cdn.mxpnl.com/libs/mixpanel-platform/build/mixpanel-platform.v0.latest.min.js"></script>
</head>
<body class="mixpanel-platform-body">
<div class="mixpanel-platform-section">
<div id="eventName" style="float: left;"></div>
<div style="clear: left"></div>
<div style="clear: both;"></div>
<div id="graph"></div>
</div>
<script>
MP.api.ready(function() {
// replace with event name of your choice
var eventName = $('#eventName').MPEventSelect();
var runQuery = function() {
var $dau = MP.api.segment(eventName.val(), {
from: moment().subtract(30, 'days'),
to: moment().subtract(1, 'days'),
unit: 'day',
type: 'unique'
});
var $mau = MP.api.segment(eventName.val(), {
from: moment().subtract(30, 'days'),
to: moment().subtract(1, 'days'),
unit: 'month',
type: 'unique'
});
$.when($dau, $mau).done(function(dau, mau) {
// average the DAU values and divide them by the MAU ones
// (we sum the MAU in the case where the 30 days spans over two months)
var dauMau = dau.divide(mau.sum()).values();
console.log (dauMau)
$('<div></div>').appendTo('body').MPChart({ // create chart
chartType: 'line',
data: dauMau // set its data
});
});
};
eventName.on('change', runQuery);
});
</script>
</body>
</html>