Hey im new to Canvas JS and was just wondering that whether for my data points' Y axis, can I collect the content from a text file in php, store the variable in JavaScript and print of this value as the Y axis for my data point. So in the example below, how would I use the content in this text file as the Y axis co-ordinates?(The content inside of the text file is the number "7")
<!DOCTYPE HTML>
<html>
<head>
<?php
$DaveLogins = file_get_contents("NoLoginsDave.txt");
?>
<script type="text/javascript">
var val = "<?php echo $DaveLogins ?>";
//alert(val);
window.onload = function () {
var chart = new CanvasJS.Chart("chartContainer", {
theme: "light1",
animationEnabled: true,
title:{
text: "The Number of Logins Per User"
},
data: [
{
type: "column",
dataPoints: [
{ label: "Lucy", y: 10 },
{ label: "Dave", y: val },
{ label: "Mike", y: 25 },
]
}
]
});
chart.render();
}
</script>
</head>
<body>
<div id="chartContainer" style="height: 370px; width: 100%;"></div>
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"> </script>
</body>
</html>
The problem is that I am trying to represent the value inside of the text file as one of the co-ordinates for my data points. By calling this value in PHP and transferring this value over to JavaScript, I am not able to do this. When I run the code, the column for Dave isn't represented as a bar chart. I was thinking whether there was an alternative solution? Or am I doing something wrong?