我有2个阵列;
x = 800,1650,2450,3200,4150,5250,6200,7150,8000
y = 800,850,800,750,950,1100,950,950,850
我想在一个折线图中显示它们。 'Array x'将是我的X轴,'Array y'将是我的Y轴。
我还将这两个数组合并在一个数组中,
$arrgraph = array_combine($y, $x);
如果我可以在我的图表中显示它,也可以。
我是php的新手,我搜索但是找不到怎么做。所有示例都只有一个数组。有人帮我吗?或者我可以用HTML创建该图表吗?
谢谢 !
Yoc可以在CanvasJS库的支持下完成
<!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>