如何在图表脚本中集成php值?

时间:2018-05-30 07:51:40

标签: javascript php charts

这是我使用php用于图表的代码。如何制作“数据:[28,48,40,19,86,27,90,20,80,81,56,55,]”这是php的脚本。我想将数据作为php变量发送。

<script>
     $(document).ready(function() {

         var lineData = {
             labels: ["January", "February", "March", "April", "May", "June", "July", "AUG", "SEP", "OCT", "NOV", "DEC"],
             datasets: [
                 {
                     label: "Sale",
                     backgroundColor: "rgba(26,179,148,0.5)",
                     borderColor: "rgba(26,179,148,0.7)",
                     pointBackgroundColor: "rgba(26,179,148,1)",
                     pointBorderColor: "#fff",
                     data: [28, 48, 40, 19, 86, 27, 90, 20, 80, 81, 56, 55,]
                 },

             ]
         };

         var lineOptions = {
             responsive: true
         };


         var ctx = document.getElementById("lineChart").getContext("2d");
         new Chart(ctx, {type: 'line', data: lineData, options:lineOptions});

     });
  </script>

0 个答案:

没有答案