如何在Chart.Js中使用Node.js中的动态数据

时间:2017-09-05 15:37:33

标签: node.js express dynamic mongoose handlebars.js

我尝试使用Node.js,mongoose和Handlebars在Chart.Js中显示动态数据,我也安装了chartjs-node。问题是我不知道该怎么做。

var schema = new Schema({
    author: String,
    post: String,
    choice: String
}, {
    timestamps: true
});

Chart.js的功能示例(public / javascripts / style.js)

new Chart($("#answerChart"), {
    type: 'pie',
    data: {
      labels: ["Africa", "Asia", "Europe", "Latin America", "North America"],
      datasets: [{
        label: "Population (millions)",
        backgroundColor: ["#3e95cd", "#8e5ea2","#3cba9f","#e8c3b9","#c45850"],
        data: [2478,5267,734,784,433]
      }]
    },
    options: {
      title: {
        display: true,
        text: 'Predicted world population (millions) in 2050'
      }
    }
});

我需要在Handlebars文件中显示图表

0 个答案:

没有答案