-
Notifications
You must be signed in to change notification settings - Fork 1
/
graph_generator.php
52 lines (48 loc) · 1.36 KB
/
graph_generator.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
<?php
/**
* Created by PhpStorm.
* User: Hitesh
* Date: 06-Jan-18
* Time: 12:43 PM
*/
?>
<!DOCTYPE HTML>
<html>
<head>
<title>Graph Generator using Canvas JS</title>
<script>
window.onload = function () {
var chart = new CanvasJS.Chart("chartContainer", {
animationEnabled: true,
theme: "light2",
title:{
text: "<?php echo $_POST['title']?>"
},
axisY: {
title: "<?php echo $_POST['yaxis']?>"
},
data: [{
type: "column",
showInLegend: true,
legendMarkerColor: "grey",
legendText: "<?php echo $_POST['unit']?>",
dataPoints: [
<?php
$label = $_POST['label'];
$value = $_POST['value'];
foreach( $label as $key => $n ) {
echo "{ y:$value[$key], label: \"$n\" },";
}
?>
]
}]
});
chart.render();
}
</script>
</head>
<body>
<div id="chartContainer" style="height: 300px; width: 50%; margin-left: 25%"></div>
<script src="js/canvasjs.min.js"></script>
</body>
</html>