1
我很新的ajax和在Java中繪製圖表。我非常感興趣的是使用ChartJS創建用於網絡報告的動態儀表板。我想問一下如何使用ajax和來自servlet響應的數據填充「圖表標籤」和「數據集」。填充chartjs ajax servlet
我嘗試了一些研究和測試了一些教程關於Ajax和ChartJS,但我似乎無法使它工作..
<html>
<head>
<title>Bar Chart</title>
<script src="../Chart.js"></script>
<meta name = "viewport" content = "initial-scale = 1, user-scalable = no">
<style>
canvas{
}
</style>
</head>
<body>
<canvas id="canvas" height="450" width="600"></canvas>
<script>
var barChartData = {
labels : [,"January","February","March","April","May","June","July"],
datasets : [
{
fillColor : "rgba(220,220,220,0.5)",
strokeColor : "rgba(220,220,220,1)",
data : [65,59,90,81,56,55,40]
},
{
fillColor : "rgba(151,187,205,0.5)",
strokeColor : "rgba(151,187,205,1)",
data : [28,48,40,19,96,27,100]
}
]
}
var myLine = new Chart(document.getElementById("canvas").getContext("2d")).Bar(barChartData);
</script>
</body>
</html>