Basically i am trying to add two canvasJS charts on a single page. However, when i include them both in the mainpage the first one doesnt show and the second overrides it.
<?php include("top_airlines.php"); ?>
<?php include("genderrange.php"); ?>
'
<;?php
$dataPoints1 = array(
array("label"=>"Male", "y"=>5),
array("label"=>"Female", "y"=>1),
);
?>
<!DOCTYPE HTML>
<html>
<head>
<script>
window.onload = function() {
var chart = new CanvasJS.Chart("chartContainer1", {
animationEnabled: true,
title: {
text: "Gender Ratio of Applicants"
},
subtitles: [{
// text: "November 2017"
}],
data: [{
type: "pie",
yValueFormatString: "#,##0.00\"\"",
indexLabel: "{label} ({y})",
dataPoints: <?php echo json_encode($dataPoints1, JSON_NUMERIC_CHECK); ?>
}]
});
chart.render();
}
</script>
</head>
<body>
<div id="chartContainer1" style="height: 300px; width: 100%;"></div>
<script src="https://cdn.canvasjs.com/canvasjs.min.js"></script>
</body>
</html>
<?php
$malecount=5;
$femalecount=1;
$dataPoints2 = array(
array("label"=>"Male", "y"=>$malecount),
array("label"=>"Female", "y"=>$femalecount),
);
?>
<!DOCTYPE HTML>
<html>
<head>
<script>
window.onload = function() {
var chart2 = new CanvasJS.Chart("chartContainer2", {
animationEnabled: true,
title: {
text: "Gender Ratio of Applicants"
},
subtitles: [{
// text: "November 2017"
}],
data: [{
type: "pie",
yValueFormatString: "#,##0.00\"\"",
indexLabel: "{label} ({y})",
dataPoints: <?php echo json_encode($dataPoints2, JSON_NUMERIC_CHECK); ?>
}]
});
chart2.render();
}
</script>
</head>
<body>
<div id="chartContainer2" style="height: 300px; width: 100%;"></div>
<script src="https://cdn.canvasjs.com/canvasjs.min.js"></script>
</body>
</html>
<br>