-
Notifications
You must be signed in to change notification settings - Fork 0
/
chart.php
74 lines (64 loc) · 2.31 KB
/
chart.php
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
<?php
$con = mysqli_connect("localhost","root","","agris");
if (!$con) {
# code...
echo "Problem in database connection! Contact administrator!" . mysqli_error();
}else{
$sql ="SELECT * FROM farminfo";
$result = mysqli_query($con,$sql);
$chart_data="";
while ($row = mysqli_fetch_array($result)) {
$ctype[] = $row['crabtype'] ;
$csex[] = $row['crabsex'];
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Graph</title>
</head>
<body>
<div style="width:60%;hieght:20%;text-align:center">
<h2 class="page-header" >Analytics Reports </h2>
<div>Product </div>
<canvas id="chartjs_bar"></canvas>
</div>
</body>
<script src="//code.jquery.com/jquery-1.9.1.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/Chart.js/2.4.0/Chart.min.js"></script>
<script type="text/javascript">
var ctx = document.getElementById("chartjs_bar").getContext('2d');
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels:<?php echo json_encode($productname); ?>,
datasets: [{
backgroundColor: [
"#5969ff",
"#ff407b",
"#25d5f2",
"#ffc750",
"#2ec551",
"#7040fa",
"#ff004e"
],
data:<?php echo json_encode($sales); ?>,
}]
},
options: {
legend: {
display: true,
position: 'bottom',
labels: {
fontColor: '#71748d',
fontFamily: 'Circular Std Book',
fontSize: 14,
}
},
}
});
</script>
</html>