将数据从mysql检索到我的谷歌堆积图表脚本

时间:2016-02-27 07:46:21

标签: mysql google-visualization stacked

我有" projecttask"表及其数据如下

 mysql> select projecttaskid,projecttaskname,projecttask_no,projecttaskstatus from vtiger_projecttask;
+---------------+------------------------+----------------+-------------------+
| projecttaskid | projecttaskname        | projecttask_no | projecttaskstatus |
+---------------+------------------------+----------------+-------------------+
|             3 | A BLOCK BASEMENT FLOOR | PT1            | Completed         |
|             5 | A BLOCK GROUND FLOOR   | PT2            | Completed         |
|             6 | A BLOCK FIRST FLOOR    | PT3            |                   |
|             7 | A BLOCK SECOND FLOOR   | PT4            | Completed         |
|             8 | A BLOCK THIRD FLOOR    | PT5            | Completed         |
|             9 | A BLOCK FOURTH FLOOR   | PT6            | In Progress       |
|            10 | A BLOCK FIFTH FLOOR    | PT7            | In Progress       |
|            11 | A BLOCK SIXTH FLOOR    | PT8            | Open              |
|            12 | A BLOCK SEVENTH FLOOR  | PT9            | Open              |
|            13 | A BLOCK TARRACE FLOOR  | PT10           | Completed         |
|            19 | A BLOCK STRUCTURE      | PT11           |                   |

+ --------------- + ------------------------ + ----- ----------- + ------------------- +

项目完成后,我们应该将数据作为' 1'对于谷歌图表。如果有任何其他状态,则应将其设置为' 0'在我的图表脚本中。图表脚本如下所示:

    <script type="text/javascript" src="https://www.google.com/jsapi">                 </script>
    <script type="text/javascript">
    google.load("visualization", "1", {packages:["corechart"]});

    var dataSet = [
    ['Date','1st Floor', '2nd Floor', '3rd Floor', '4th Floor', '5th Floor', '6th Floor', '7th Floor', 'Tarrace Floor'],
    ['A Block', 1, 1, 1, 0, 0, 0, 0, 0],
    ['B Block', 1, 1, 1, 1, 1, 1, 1, 1],
    ['C Block', 1, 1, 1, 1, 1, 1, 1, 1],
    ['D Block', 1, 1, 1, 1, 1, 1, 1, 1],
    ['E Block', 1, 1, 0, 0, 0, 0, 0, 0],
    ['F Block', 1, 1, 0, 0, 0, 0, 0, 0],
    ];

    // The first chart

    google.setOnLoadCallback(drawChart1);
    function drawChart1() {
var data = google.visualization.arrayToDataTable( dataSet );

var options = {
  title: 'Stacked histogram\nTotals',
  vAxis: {title: 'Total Floors', maxValue: 8},  // sets the maximum value
  backgroundColor: {strokeWidth: 2 },  // to draw a nice box all around the chart
  isStacked: 'true'                    //  = rowstacked in gnuplot
};

var chart = new google.visualization.ColumnChart(document.getElementById('chart_div1'));
chart.draw(data, options);

}

                 

这是数据应该从我的脚本中从数据库中注入的地方。我需要这里的数据应该自动来自数据库。请帮帮我。

  var dataSet = [
    ['Date','1st Floor', '2nd Floor', '3rd Floor', '4th Floor', '5th Floor', '6th Floor', '7th Floor', 'Tarrace Floor'],
    ['A Block', 1, 1, 1, 0, 0, 0, 0, 0],
    ['B Block', 1, 1, 1, 1, 1, 1, 1, 1],
    ['C Block', 1, 1, 1, 1, 1, 1, 1, 1],
    ['D Block', 1, 1, 1, 1, 1, 1, 1, 1],
    ['E Block', 1, 1, 0, 0, 0, 0, 0, 0],
    ['F Block', 1, 1, 0, 0, 0, 0, 0, 0],
    ];

一楼完成后,图表自动上升1.输出您可以在网址http://www.onnetsourcing.com/vivera/chart.html中看到

0 个答案:

没有答案