【发布时间】:2017-09-07 03:11:41
【问题描述】:
我正在尝试使用 chartjs 在 pug 模板中呈现图表,但由于某种原因它无法正常工作,谁能看到我做错了什么?哈巴狗文件加载得很好,但上面没有图表。这是我的哈巴狗模板:
div(class="main container-fluid text-center")
div(class="choices")
h2
p I'm voting for:
select(class="form-control")
option 1
option 2
option 3
option 4
option 5
div(class="chart")
canvas(id="chartPic" width="400" height="400")
script(src="chart.js")
script.
-window.onload(
-var ctx = document.getElementById("chartPic").getContext('2d');
-var chart = new Chart(ctx, {
-type: 'pie',
-data: {
-labels: ["red", "green", "blue"],
-datasets: [{
-label: 'Number of votes',
-data: [1, 1, 1],
-backgroundColor: ['red', 'green', 'blue'],
-borderColor: ['green', 'blue', 'red'],
-borderWidth: 1
}],
},
-options: {
-title: {
-display: true,
-text: "chart",
},
-legend: {
-position: 'bottom'
},
}
});
);
【问题讨论】:
标签: node.js express pug chart.js