是否可以使用EJS標籤將數據添加到圖形中?這裏是我當前圖的數據:使用ChartJS的EJS標籤?
var canvas = document.getElementById('myChart');
var data = {
labels: ["One", "February", "March", "April", "May", "June", "July"],
datasets: [
{
label: "My First dataset",
backgroundColor: "rgba(255,99,132,0.2)",
borderColor: "rgba(255,99,132,1)",
borderWidth: 2,
hoverBackgroundColor: "rgba(255,99,132,0.4)",
hoverBorderColor: "rgba(255,99,132,1)",
data: [10, 20, 81, 56, 55, 40],
}
]
};
我想要做這樣的事情:
labels: ["<%= currentUser.datapoint1 %>", "<%= currentUser.datapoint2 %>", "<%= currentUser.datapoint3 %>"]
data: [<%= currentUser.datapoint10 %>, <%= currentUser.datapoint11 %>]
我將如何做到使用EJS標籤來生成圖表的數據? (注意:在生成圖表之前EJS標記信息已經保存到用戶)