-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtable_test.html
executable file
·59 lines (48 loc) · 1.14 KB
/
table_test.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
<!DOCTYPE HTML>
<html>
<head>
<script>
window.onload = function() {
var dataPoints = [];
var chart = new CanvasJS.Chart("chartContainer", {
animationEnabled: true,
theme: "light2",
title: {
text: "Daily Sales Data"
},
axisY: {
title: "Units",
titleFontSize: 24
},
data: [{
type: "column",
yValueFormatString: "#,### Units",
dataPoints: dataPoints
}]
});
var date_diff = function(date1, date2) {
var dt1 = new Date(date1);
var dt2 = new Date(date2);
var timeDiff = Math.abs(dt2.getTime() - dt1.getTime());
var diffDays = Math.ceil(timeDiff / (1000 * 3600 * 24));
return diffDays;
}
function addData(data) {
for (var i = 0; i < data.length; i++) {
dataPoints.push({
y: date_diff( '11/15/2018', data[i].rdate) ,
label: " " + data[i].pname
});
}
chart.render();
}
$.getJSON("data.json", addData);
}
</script>
</head>
<body>
<div id="chartContainer" style="height: 300px; width: 100%;"></div>
<script src="https://canvasjs.com/assets/script/jquery-1.11.1.min.js"></script>
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
</body>
</html>