-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
45 lines (43 loc) · 1.76 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
<!doctype html>
<html>
<head>
<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>
<div id="eventSelect" style="float: left;"></div>
<div id="by" class="mp-label" style="margin-left: 10px; display: none;">by</div>
<div id="propSelect" style="float: left;"></div>
<div id="dateSelect" style="float: right"></div>
<div style="clear: both;"></div>
<div id="graph" style="margin-bottom: 10px;"></div>
<div id="table"></div>
<script>
MP.api.ready(function() {
var eventSelect = $('#eventSelect').MPEventSelect();
var propSelect = $('#propSelect').MPPropertySelect();
var dateSelect = $('#dateSelect').MPDatepicker();
var eventGraph = $('#graph').MPChart({chartType: 'line'});
var eventTable = $('#table').MPTable();
var runQuery = function() {
var eventName = eventSelect.MPEventSelect('value'),
propName = propSelect.MPPropertySelect('value'),
dateRange = dateSelect.MPDatepicker('value');
if (eventName) {
MP.api.segment(eventName, propName, dateRange).done(function(results) {
eventGraph.MPChart('setData', results);
eventTable.MPTable('setData', results);
});
}
};
eventSelect.on('change', function(e, eventName) {
propSelect.MPPropertySelect('setEvent', eventName);
$("#by").show();
runQuery();
});
propSelect.on('change', runQuery);
dateSelect.on('change', runQuery);
});
</script>
</body>
</html>