zoukankan      html  css  js  c++  java
  • 网页 echarts 做图

    1.折线图实例

    jsp:

    <div id="speedInfoMap" style=" 750px; height: 500px; margin:5px auto;">
    </div>

    js:

                $.ajax({
                    url: window.PATH + "/xxx/xxx/xxxxInfo.ajax",
                    dataType: "json",
                    async: true,
                    data: {
                        device : idList
                    },
                    type: "GET",
                    success: function (res) {
                        if (!res || !res.data) {
                            return;
                        }
                        let data = res.data;
                        let option = {
                            title: {
                                text: '设备测速信息'
                            },
                            tooltip: {
                                trigger: 'axis',
                                // formatter:'{b}<br/>{a0}:{c0}MB,<br/>{a1}:{c1}KB/s,<br/>{a2}:{c2}MB,<br/>{a3}:{c3}KB/s,<br/>'  //添加单位
                                formatter: function(a) {
                                    let list = []
                                    let listItem = ''
                                    for (var i = 0; i < a.length; i++) {
                                        if (i%2==0){
                                            list.push(
                                                '<i style="display: inline-block; 10px;height: 10px;background: ' +
                                                a[i].color +
                                                ';margin-right: 5px;border-radius: 50%;}"></i><span style="70px; display:inline-block;">' +
                                                a[i].seriesName +
                                                '</span>&nbsp&nbsp:' +
                                                a[i].value +
                                                'MB'
                                            )
                                        } else {
                                            list.push(
                                                '<i style="display: inline-block; 10px;height: 10px;background: ' +
                                                a[i].color +
                                                ';margin-right: 5px;border-radius: 50%;}"></i><span style="70px; display:inline-block;">' +
                                                a[i].seriesName +
                                                '</span>&nbsp&nbsp:' +
                                                a[i].value +
                                                'KB/S'
                                            )
                                        }
    
                                    }
                                    listItem = list.join('<br>')
                                    return '<div class="showBox">' + listItem + '</div>'
                                }
                            },
                            legend: {
                                data: ['上行流量','上传速度', '下行流量', '下载速度']
                            },
                            grid: {
                                left: '3%',
                                right: '4%',
                                bottom: '3%',
                                containLabel: true
                            },
                            toolbox: {
                                feature: {
                                    saveAsImage: {}
                                }
                            },
                            xAxis: {
                                type: 'category',
                                boundaryGap: false,
                                data: data.time
                            },
                            yAxis: {
                                type: 'value'
                              /*  ,
                                axisLabel: {
                                    formatter:'{value} (KB/S)' //y轴单位
                                }*/
    
                            },
                            series: [
                                {
                                    name: '上行流量',
                                    type: 'line',
                                    data: data.upFlow
                                },
                                {
                                    name: '上传速度',
                                    type: 'line',
                                    data: data.upSpeed
                                },
                                {
                                    name: '下行流量',
                                    type: 'line',
                                    data: data.downFlow
                                },
                                {
                                    name: '下载速度',
                                    type: 'line',
                                    data: data.downSpeed
                                }
                            ]
                        };
                        let speedTestMap = echarts.init(document.getElementById('speedInfoMap'));
                        speedTestMap.setOption(option);
                    }
                });

    官网连接

  • 相关阅读:
    Angular与PHP之间的不同的请求方式(post/get)导致的传参问题
    项目当中会使用到的---获取主机名
    JavaScript eval() 函数
    PHP 数组排序
    PHP Switch 语句
    PHP strlen()函数和strpos()函数
    Array.prototype.map()和Array.prototypefilter()
    25.参考链接
    24.ArrayBuffer
    23.读懂 ECMAScript 规格
  • 原文地址:https://www.cnblogs.com/dztHome/p/12660347.html
Copyright © 2011-2022 走看看