漏刻有時echarts柱圖堆疊方案備選案例(1)

在這裏插入圖片描述

/*工資項目趨勢分析堆積圖*/
function wagesStr(dataName, dataList1, dataList2, dataList3, dataList4) {
    var myChart = echarts.init(document.getElementById('wages'));
    var option = {
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                lineStyle: {
                    color: '#57617B'
                }
            }
        },
        legend: {
            data: [
                {"name": "工資"},
                {"name": "提成"},
                {"name": "其他"},
                {"name": "總收入"}
            ],
            icon: "circle",
            "bottom": "2%",
            textStyle: {
                "color": "rgba(255,255,255,0.9)"
            }
        },
        "xAxis": [
            {
                type: "category",
                data: dataName,
                axisLine: {show: false},
                axisLabel: {
                    textStyle: {color: "rgba(255,255,255,.6)", fontSize: '14',},
                }
            }
        ],
        "yAxis": [
            {
                type: "value",
                name: "",
                axisLabel: {show: false},
                axisLine: {show: false},
                splitLine: {show: false}
            }
        ],
        "grid": {
            "top": "0%",
            "right": "5%",
            "bottom": "15%",
            "left": "0%",
            containLabel: true
        },
        series: [
            {
                "name": "工資",
                "type": "bar",
                stack: '總量',
                barWidth: "30%",
                barGap: "40%",
                "data": dataList1,
                itemStyle: {
                    barBorderRadius: 20,
                    color: "#2e4e6d"
                },
                emphasis: {
                    itemStyle: {
                        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                                {offset: 0, color: '#fba145'},
                                {offset: 0.7, color: '#fed53f'},
                                {offset: 1, color: '#fbe247'}
                            ]
                        )
                    }
                },
            },
            {
                "name": "提成",
                "type": "bar",
                "data": dataList2,
                stack: '總量',
                barWidth: "30%",
                barGap: "40%",
                itemStyle: {
                    barBorderRadius: 20,
                    color: "#38636f"
                },
                emphasis: {
                    itemStyle: {
                        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                                {offset: 0, color: '#fba145'},
                                {offset: 0.7, color: '#fed53f'},
                                {offset: 1, color: '#fbe247'}
                            ]
                        )
                    }
                }
            },
            {
                "name": "其他",
                "type": "bar",
                stack: '總量',
                "data": dataList3,
                barWidth: "30%",
                barGap: "40%",
                itemStyle: {
                    barBorderRadius: 20,
                    color: "#293d42"
                },
                emphasis: {
                    itemStyle: {
                        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                                {offset: 0, color: '#fba145'},
                                {offset: 0.7, color: '#fed53f'},
                                {offset: 1, color: '#fbe247'}
                            ]
                        )
                    }
                },
                "barGap": "0"
            },
            {
                "name": "總收入",
                "type": "line",
                "yAxisIndex": 0,
                "data": dataList4,
                lineStyle: {
                    normal: {
                        width: 3
                    },
                },
                itemStyle: {
                    "color": {
                        "type": "linear",
                        "x": 0,
                        "y": 0,
                        "x2": 0,
                        "y2": 1,
                        "colorStops": [
                            {
                                "offset": 0,
                                "color": "#2c86e1"
                            },
                            {
                                "offset": 0.5,
                                "color": "#d4f170"
                            },
                            {
                                "offset": 1,
                                "color": "#ff943c"
                            }
                        ],
                        "globalCoord": false
                    }
                },
                "smooth": true
            }
        ]
    };

    myChart.setOption(option);
    window.addEventListener("resize", function () {
        myChart.resize();
    });
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章