我需要创建一个带有外部JSON数据的图表js,这里我尝试使用Aungularjs中的chartjs
<script>
var barChartData = {
labels: ["January", "February", "March", "April", "May", "June", "July"],
datasets: [{
label: 'Dataset 1',
backgroundColor: "#09a",
data: ["100", "150", "50", "120", "75", "250", "31"],
}]
};
window.onload = function() {
var ctx = document.getElementById("canvas").getContext("2d");
window.myBar = new Chart(ctx, {
type: 'bar',
data: barChartData,
});
};
</script>
此处JSON在内部使用变量 barChartData 处理并分配给数据:barChartData ,如何对外部JSON执行相同操作?