• eCharts画图


    1. 方式1
       if ($('#runExport').length) {
            $.ajax({
            url: '/report/reportInfo/',
            method: 'get',
            }).success(function (data, textStatus, jqXHR) {
                // 每次运行报表
                var ctx = document.getElementById("runExport");
                var ctx1 = document.getElementById("bug_qushi");
                var labels = [];
                var datasetsPass = [];
                var datasetsFaild = [];
                var datasetsSum= [];
                for (var i=0; i<data.length; i++) {
                    labels.push(data[i].case_date);
                    datasetsPass.push(data[i].case_pass_sum);
                    datasetsFaild.push(data[i].case_fail_sum);
                    datasetsSum.push(data[i].case_sum);
                }
                var runExport = new Chart(ctx, {
                    type: 'bar',
                    data: {
                        labels: labels,
                        datasets: [{
                            label: '# 总数',
                            backgroundColor: "#6a4a38",
                            data: datasetsSum
                        }, {
                            label: '# 成功',
                            backgroundColor: "#26B99A",
                            data: datasetsPass
                        }, {
                            label: '# 失败',
                            backgroundColor: "#f33333",
                            data: datasetsFaild
                        }]
                    },
    
                    options: {
                        scales: {
                            yAxes: [{
                                ticks: {
                                    beginAtZero: true
                                }
                            }]
                        }
                    }
                });
    
            var bug_qushi = new Chart(ctx1, {
                type: 'line',
                data: {
                    labels: labels,
                    datasets: [
                    // {
                    //     label: "pass",
                    //     backgroundColor: "rgba(38, 185, 154, 0.31)",
                    //     borderColor: "rgba(38, 185, 154, 0.7)",
                    //     pointBorderColor: "rgba(38, 185, 154, 0.7)",
                    //     pointBackgroundColor: "rgba(38, 185, 154, 0.7)",
                    //     pointHoverBackgroundColor: "#fff",
                    //     pointHoverBorderColor: "rgba(220,220,220,1)",
                    //     pointBorderWidth: 1,
                    //     data: datasetsPass
                    // },
                        {
                        label: "fail",
                        backgroundColor: "rgba(3, 88, 106, 0.3)",
                        borderColor: "rgba(3, 88, 106, 0.70)",
                        pointBorderColor: "rgba(3, 88, 106, 0.70)",
                        pointBackgroundColor: "rgba(3, 88, 106, 0.70)",
                        pointHoverBackgroundColor: "#fff",
                        pointHoverBorderColor: "rgba(151,187,205,1)",
                        pointBorderWidth: 1,
                        data: datasetsFaild
                    }]
                },
            });
    
    
            }).error(function (jqXHR, textStatus, errorThrown) {
                console.log(jqXHR)
            });
    
    
        }
    
    1. 方式2
       if ($('#bug_qushi').length) {
    
            var ctx = document.getElementById("bug_qushi");
            var bug_qushi = new Chart(ctx, {
                type: 'line',
                data: {
                    labels: ["January", "February", "March", "April", "May", "June", "July"],
                    datasets: [{
                        label: "My First dataset",
                        backgroundColor: "rgba(38, 185, 154, 0.31)",
                        borderColor: "rgba(38, 185, 154, 0.7)",
                        pointBorderColor: "rgba(38, 185, 154, 0.7)",
                        pointBackgroundColor: "rgba(38, 185, 154, 0.7)",
                        pointHoverBackgroundColor: "#fff",
                        pointHoverBorderColor: "rgba(220,220,220,1)",
                        pointBorderWidth: 1,
                        data: [31, 74, 6, 39, 20, 85, 7]
                    }, {
                        label: "My Second dataset",
                        backgroundColor: "rgba(3, 88, 106, 0.3)",
                        borderColor: "rgba(3, 88, 106, 0.70)",
                        pointBorderColor: "rgba(3, 88, 106, 0.70)",
                        pointBackgroundColor: "rgba(3, 88, 106, 0.70)",
                        pointHoverBackgroundColor: "#fff",
                        pointHoverBorderColor: "rgba(151,187,205,1)",
                        pointBorderWidth: 1,
                        data: [82, 23, 66, 9, 99, 4, 2]
                    }]
                },
            });
    
        }
    
  • 相关阅读:
    PHP 实现 一致性哈希 算法(转的)
    一致性 hash 算法
    分布式设计与开发---宏观概述
    Lvs+keepalived+nginx+php的session 保持的算法
    从零搭建Web网站
    Java动态代理机制详解(JDK 和CGLIB,Javassist,ASM)
    哪个线程执行 CompletableFuture’s tasks 和 callbacks?
    HTTP 用户认证
    java 发送 HTTP 请求
    Http basic Auth 认证方式帮助类
  • 原文地址:https://www.cnblogs.com/amize/p/14103530.html
Copyright © 2020-2023  润新知