如何在莫里斯地区图表上输入数据? bootstrap 3

时间:2015-09-14 13:33:36

标签: php twitter-bootstrap morris.js

我正在尝试显示数据来自3个表的morris图表,我的代码是这样的:

<script type="text/javascript">
             // 


    $(function() {                       


     Morris.Area({
    element: 'morris-area-chart',
    data: [
     <?php
    $query1 = mysql_query("select * from medicine_transaction");
    while ($row1 = mysql_fetch_array($query1))
    $medprice = $row1['med_price'];
    $medquantity = $row1['med_quantity'];
    $med_sales = $medprice*$medquantity;
    {
    $query2 = mysql_query("select * from service_transaction");
    while ($row2 = mysql_fetch_array($query2))
    $svc_sales = $row2['services_sales'];
    {
    $query3 = mysql_query("select * from product_transaction");
    while ($row3 = mysql_fetch_array($query3))
    $pdtprice = $row3['product_price'];
    $pdtquantity = $row3['product_quantity'];
    $pdt_sales = $pdtprice*$pdtquantity;
    {
    $query4 = mysql_query("select trans_date from product_transaction,medicine_transaction,service_transaction");
    while ($row4 = mysql_fetch_array($query4))
    $td = $row4['trans_date'];

    {
    ?>
        {
        period: "'<?php echo $td; ?>'",
        services: "<?php echo $svc_sales; ?>",
        medicines: "<?php echo $med_sales; ?>",
        products: "<?php echo $pdt_sales; ?>"
        } ,
    <?php
    }}}}
    ?>

    ],
    xkey: 'period',
    ykeys: ['services', 'medicines', 'products'],
    labels: ['Services', 'Medicines', 'Products'],
    pointSize: 2,
    hideHover: 'auto',
    resize: true
});
});

    </script>
在morris地区的样本上,它的编码如下:

  // Area Chart
Morris.Area({
    element: 'morris-area-chart',
    data: [{
        period: '2010 Q1',
        iphone: 2666,
        ipad: null,
        itouch: 2647
    }, {
        period: '2010 Q2',
        iphone: 2778,
        ipad: 2294,
        itouch: 2441
    }, {
        period: '2010 Q3',
        iphone: 4912,
        ipad: 1969,
        itouch: 2501
    }, {
        period: '2010 Q4',
        iphone: 3767,
        ipad: 3597,
        itouch: 5689
    }, {
        period: '2011 Q1',
        iphone: 6810,
        ipad: 1914,
        itouch: 2293
    }, {
        period: '2011 Q2',
        iphone: 5670,
        ipad: 4293,
        itouch: 1881
    }, {
        period: '2011 Q3',
        iphone: 4820,
        ipad: 3795,
        itouch: 1588
    }, {
        period: '2011 Q4',
        iphone: 15073,
        ipad: 5967,
        itouch: 5175
    }, {
        period: '2012 Q1',
        iphone: 10687,
        ipad: 4460,
        itouch: 2028
    }, {
        period: '2012 Q2',
        iphone: 8432,
        ipad: 5713,
        itouch: 1791
    }],
    xkey: 'period',
    ykeys: ['iphone', 'ipad', 'itouch'],
    labels: ['iPhone', 'iPad', 'iPod Touch'],
    pointSize: 2,
    hideHover: 'auto',
    resize: true
});

我应该怎么编码?,数据没有显示任何,我的查询错了吗?

0 个答案:

没有答案