I have 2 arrays;
x = 800,1650,2450,3200,4150,5250,6200,7150,8000
y = 800,850,800,750,950,1100,950,950,850
I want to show them in one line chart. 'Array x' will be my X-Axis and 'Array y' will be my Y-Axis.
Also I combined those 2 arrays in one array,
$arrgraph = array_combine($y, $x);
If I can show it in my chart, it's OK too.
I'm a rookie on php, I searched but couldn't find how to do it. All examples are about only one array. Is there anyone help me about it ? Or can I create that chart with HTML ?
Thank you !
Yoc can do it with the support of CanvasJS library
<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript">
window.onload = function () {
var chart = new CanvasJS.Chart("chartContainer",
{
title:{
text: "Multi-Series Line Chart"
},
data: [
{
type: "line", //you can echo php array here as dataPoints variable
dataPoints: [
{ x: 10, y: 21 },
{ x: 20, y: 25},
{ x: 30, y: 20 },
{ x: 40, y: 25 },
{ x: 50, y: 27 },
{ x: 60, y: 28 },
{ x: 70, y: 28 },
{ x: 80, y: 24 },
{ x: 90, y: 26}
]
}
]
});
chart.render();
}
</script>
<script type="text/javascript" src="https://canvasjs.com/assets/script/canvasjs.min.js"></script></head>
<body>
<div id="chartContainer" style="height: 300px; width: 100%;">
</div>
</body>
</html>
For more details visit Basic Multi-Series Chart
</div>