日日操夜夜添-日日操影院-日日草夜夜操-日日干干-精品一区二区三区波多野结衣-精品一区二区三区高清免费不卡

公告:魔扣目錄網(wǎng)為廣大站長提供免費(fèi)收錄網(wǎng)站服務(wù),提交前請做好本站友鏈:【 網(wǎng)站目錄:http://www.ylptlb.cn 】, 免友鏈快審服務(wù)(50元/站),

點(diǎn)擊這里在線咨詢客服
新站提交
  • 網(wǎng)站:51998
  • 待審:31
  • 小程序:12
  • 文章:1030137
  • 會員:747

echarts統(tǒng)計(jì),簡單示例,先看下效果圖


5f964ca359499.jpg

看下代碼

HTML頁面 為ECharts準(zhǔn)備一個Dom,寬高自定義

<div class="panel panel-info">
  <div class="panel-body">
    <div id="echart_show" style="height:500px"></div>
  </div>
</div>

js文件可以參考官網(wǎng),或者在這里下載,引入

<script type="text/javascript" src="路徑/lib/jquery/nowdatachars/echarts-all.js"></script>

下面是具體方法

<script type="text/javascript">
var date = [],num = [];
$(document).ready(function () {
    // 繪制反饋量圖形
    var init_echarts = function () {
        var refreshChart = function (show_data) {
            my_demo_chart = echarts.init(document.getElementById('echart_show'));
            my_demo_chart.showLoading({
                text: '加載中...',
                effect: 'whirling'
            });
            var echarts_all_option = {
                title: {
                    text: '',
                    subtext: '用戶走勢'
                },
                tooltip: {
                    trigger: 'axis'
                },
                legend: {
                    data: ['用戶數(shù)', '用戶消耗']
                },
                toolbox: {
                    show: true,
                    feature: {
                        mark: {show: true},
                        dataView: {show: true, readOnly: false},
                        magicType: {show: true, type: ['line', 'bar']},
                        restore: {show: true},
                        saveAsImage: {show: true}
                        // myTool2: {
                        //     show: true,
                        //     title: '自定義擴(kuò)展方法',
                        //     icon: 'image://http://echarts.baidu.com/images/favicon.png',
                        //     onclick: function (){
                        //         alert('自定義')
                        //     }
                        // }
                    }
                },
                dataZoom: {
                    show: false,
                    start: 0,
                    end: 100
                },
                xAxis: [
                    {
                        type: 'category',
                        boundaryGap: true,
                        data: show_data[1]
                    },
                    {
                        type: 'category',
                        boundaryGap: true,
                        data: show_data[1]
                    }
                ],
                yAxis: [
                    {
                        type: 'value',
                        scale: true,
                        name: '用戶數(shù)',
                        boundaryGap: [0, 0.5]
                        // boundaryGap: [0.2, 0.2]
                    },
                    {
                        type: 'value',
                        scale: true,
                        name: '用戶數(shù)',
                        boundaryGap: [0, 0.5]
                    }
                ],
                series: [
                    {
                        name: '用戶消耗',
                        type: 'bar',
                        xAxisIndex: 1,
                        data: show_data[0]
                    },
                    {
                        name: '用戶數(shù)',
                        type: 'line',
                        xAxisIndex: 1,
                        data:show_data[0]
                    }
                ]
            };
            my_demo_chart.hideLoading();
            my_demo_chart.setOption(echarts_all_option);
        }; 
        // 獲取原始數(shù)據(jù)
        $.ajax({
            url:"__CONTROLLER__/getRes",
            async:false,
            dataType:'json',
            type:'post',
            success:function(msg){
                var result = msg.result;
                if(msg.code == 200){
                    for(var i = 0 ; i < result.length; i++){
                        date.push(result[i].date);
                        num.push(result[i].count);
                        msg[0] = num;
                        msg[1] = date;
                        refreshChart(msg);
                    }
                }
            }
        });
    };
    // 默認(rèn)加載
    var default_load = (function () {
        init_echarts();
    })();
});
</script>

控制器中查詢自己需要的數(shù)據(jù) (這里查詢的日期和對應(yīng)的數(shù)量)

//折線統(tǒng)計(jì)
public function getRes(){
    $user = M('account');
    $sql = "SELECT date(createTime) AS date,count(*) as count FROM t_account  GROUP BY date ";
    $result = $user->query($sql);
    $this->ajaxReturn(array('code'=>200,'result'=>$result));
}

至此,一個簡單的echarts的統(tǒng)計(jì)圖就出來了

對echarts中一些參數(shù)不太理解的,大家可以參考官網(wǎng) https://www.echartsjs.com/option.html#title




分享到:
標(biāo)簽:PHP如何使用 Echarts 數(shù)據(jù)統(tǒng)計(jì)報(bào)表
用戶無頭像

網(wǎng)友整理

注冊時間:

網(wǎng)站:5 個   小程序:0 個  文章:12 篇

  • 51998

    網(wǎng)站

  • 12

    小程序

  • 1030137

    文章

  • 747

    會員

趕快注冊賬號,推廣您的網(wǎng)站吧!
最新入駐小程序

數(shù)獨(dú)大挑戰(zhàn)2018-06-03

數(shù)獨(dú)一種數(shù)學(xué)游戲,玩家需要根據(jù)9

答題星2018-06-03

您可以通過答題星輕松地創(chuàng)建試卷

全階人生考試2018-06-03

各種考試題,題庫,初中,高中,大學(xué)四六

運(yùn)動步數(shù)有氧達(dá)人2018-06-03

記錄運(yùn)動步數(shù),積累氧氣值。還可偷

每日養(yǎng)生app2018-06-03

每日養(yǎng)生,天天健康

體育訓(xùn)練成績評定2018-06-03

通用課目體育訓(xùn)練成績評定