-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
101 lines (92 loc) · 3.18 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.4.0/Chart.bundle.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="hammer.min.js"></script>
<script src="chartjs-plugin-zoom.min.js"></script>
</head>
<body>
<canvas id="myChart" width="200" height="95vh"></canvas>
<script>
$(document).ready(function(){
getDataSet(0, 0, 40, 25);
});
function getDataSet(x1, y1, x2, y2){
$.post('http://oblong-onslaught.herokuapp.com/', {x1:x1, y1:y1, x2:x2, y2:y2, personIdx:22}, function(response){
var rcvd = $.parseJSON(response);
var data = rcvd;
console.log(rcvd);
var options = {
onClick: clickHandler,
layout:{
padding:20
},
tooltips:{
titleFontSize:24,
bodyFontSize:24,
callbacks:{
label:function(e, d){
//console.log(e.datasetIndex);
//console.log(d.datasets[e.datasetIndex]);
return d.datasets[e.datasetIndex].label;
}
},
intersect:false
},
legend:{
display:false
},
scales: {
xAxes: [{
display:false
/*ticks: {
min: 1,
max: 100
}*/
}],
yAxes: [{
display:false
}]
},
pan: {
enabled: true,
mode: 'xy'
},
zoom: {
enabled: true,
mode: 'xy'
}
};
var ctx = document.getElementById("myChart");
var myBubbleChart = new Chart(ctx,{
type: 'bubble',
data: data,
options: options
});
function clickHandler(e, da){
/*myBubbleChart.clear();
myBubbleChart.destroy();
$('canvas').html('');
if (e.clientX > 1000 && e.clientY > 500) {
console.log('br');
getDataSet((x1 + x2) / 2, y1, x2, (y1 + y2) / 2);
} else if (e.clientX > 1000 && e.clientY < 500) {
console.log('ur');
getDataSet((x1 + x2) / 2, (y1 + y2) / 2, x2, y2);
} else if (e.clientY < 500) {
console.log('ul');
getDataSet(x1, (y1 + y2) / 2, (x1 + x2) / 2, y2);
} else {
console.log('bl');
getDataSet(x1, y1, (x1 + x2) / 2, (y1 + y2) / 2);
}
console.log(e);*/
console.log(da[0]._datasetIndex);
}
});
}
</script>
</body>
</html>