• 网页 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);
                    }
                });

    官网连接

  • 相关阅读:
    【SpringCloud构建微服务系列】分布式链路跟踪Spring Cloud Sleuth
    【算法】LRU算法
    细说分布式锁
    【Python】Python3.4+Matplotlib详细安装教程
    LoRaWAN协议(二)--LoRaWAN MAC数据包格式
    LoRaWAN移植笔记(一)__RTC闹钟链表的实现
    cJSON_json包的C语言解析库
    LoRaWAN协议(一)--架构解析
    STM32L051 PVD的调试
    以帧为存储单位的循环stack
  • 原文地址:https://www.cnblogs.com/dztHome/p/12660347.html
Copyright © 2020-2023  润新知