有没有一种方法可以在.js文件扩展名内运行PHP代码?

时间:2019-03-01 12:32:23

标签: javascript php html phpmyadmin

我有一个javascript文件,上面有一些图形信息,在这里您可以看到标记“数据”,这是我要在其中编写一些php代码的位置,因此该图形的值取自phpMyAdmin中的表。我是新手,所以任何建议都很好。

piechart.js代码:

sys2.table2

您看到的6、4、2、0、3、1 <-是我想在其中添加如下内容的地方,因此这些值直接取自我表中的值:

    var ctx = document.getElementById("myChart");

var myDoughnutChart = new Chart(ctx, {
    type: 'doughnut',
    data: {
        labels: ["Time Management", "Career Coach", "Stress & Wellbeing", "Note Taking", "Exam Prep", "Presentations"],
        datasets: [{
            label: 'Module Tracker',
            data: [6, 4, 2, 0, 3, 1],
            backgroundColor: [
                'rgba(255, 99, 132, 0.2)',
                'rgba(54, 162, 235, 0.2)',
                'rgba(255, 206, 86, 0.2)',
                'rgba(75, 192, 192, 0.2)',
                'rgba(153, 102, 255, 0.2)',
                'rgba(255, 159, 64, 0.2)'
            ],
            borderColor: [
                'rgba(255,99,132,1)',
                'rgba(54, 162, 235, 1)',
                'rgba(255, 206, 86, 1)',
                'rgba(75, 192, 192, 1)',
                'rgba(153, 102, 255, 1)',
                'rgba(255, 159, 64, 1)'
            ],
            borderWidth: 1
        }]
    },
    options: {
        scales: {
            yAxes: [{
                ticks: {
                    beginAtZero:true
                }
            }]
        }
    }
});

enter image description here

0 个答案:

没有答案
相关问题