echarts柱状图重叠

export function capBar(data) {
    return {
        grid: {
            top: '10',
            bottom: '20',
            left: '30',
            right: '5'
        },
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                type: 'cross',
                crossStyle: {
                    color: '#999'
                },
            },
            // textStyle: {
            //     color: '#fff',
            //     fontSize: 20
            // },
        },
        legend: {
            show: false,
            data: ['产出', '投入', '标准产出'],
            right: 50,
            top: 70,
            itemHeight: 50,
            itemWidth: 100,
            itemGap: 100, //这个值是⽤来调图例之间的间距
            textStyle: {
                color: '#fff',
                fontSize: 40
            }
        },
        xAxis: [
            {
                type: 'category',
                data: data.map(e => e.lineName),
                axisPointer: {
                    type: 'shadow'
                },
                axisLine: {
                    show: true,
                    lineStyle: {
                        color: '#122d67',
                        width: 1
                    }
                },
                axisLabel: {
                    color: '#8ec0ff',
                    fontSize: 9
                }
            },
            {
                type: 'category',
            },
            {
                type: 'category',
            }
        ],
        yAxis: [
            {
                type: 'value',
                name: '',
                axisLine: {
                    show: true,
                    lineStyle: {
                        color: '#285aaf',
                        width: 1
                    }
                },
                axisLabel: {
                    formatter: function (value, index) {
                        if (value >= 1000) {
                            value = value / 1000 + "k";
                        } else if (value < 1000) {
                            value;
                        }
                        return value;
                    },
                    color: '#8ec0ff',
                    fontSize: 10
                },
                splitLine: {
                    show: true,
                    lineStyle: {
                        color: '#091f56'
                    }
                }
            }
        ],
        series: [
            {
                name: '标准产出',
                type: 'bar',
                // stack: 'all',
                barGap:'-92%',
                barWidth: '60%',
                showBackground: true,
                backgroundStyle: {
                    color: 'rgba( 40, 90, 175, 0)',
                },
                data: data.map(e => e.standardOutput),
                itemStyle: {
                    normal: {
                        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                            offset: 0,
                            color: 'rgba( 255, 255, 255, 0.5)'
                        }, {
                            offset: 1,
                            color: 'rgba( 255, 255, 255, 0.5)'
                        }]),
                        barBorderRadius: [0, 0, 0, 0],
                    }
                },
                label: {
                    normal: {
                        show: false,  //柱状图上方显示数据
                        lineHeight: 46,
                        width: 90,
                        height: 43,
                        // backgroundColor: 'rgba(0,160,221,0.2)',
                        // borderColor: '#50f2ff',
                        borderWidth: 2,
                        borderRadius: 100,
                        position: 'top',
                        distance: 1,
                        color: '#fff',
                        fontSize: 10,
                        fontWeight: 800,
                        formatter: function (p) {
                            // 超过10000加"k"
                            return p.value > 10000 ? (p.value / 1000).toFixed(1) + 'k' : p.value
                        },
                        rich: {
                            d: {
                                color: '#50f2ff',
                            },
                            a: {
                                color: '#fedf19',
                                align: 'center',
                                fontSize: 10
                            },
                            b: {
                                width: 1,
                                height: 48,
                                borderWidth: 1,
                                borderColor: '#fedf19',
                                align: 'left'
                            },
                        }
                    }
                }
            },
            {
                name: '实际投入',
                type: 'bar',
                // stack: 'all',
                // barGap: '-100%',
                // barWidth: '60%',
                barWidth: "51%",
                showBackground: true,
                backgroundStyle: {
                    color: 'rgba( 40, 90, 175, 0)',
                },
                data: data.map(e => e.inputNum),
                itemStyle: {
                    normal: {
                        color: function (params) {
                            let { value, dataIndex } = params
                            let {standardOutput, standardRate} = data[dataIndex]
                            if (accMul(standardOutput, standardRate) <= value) {
                                return '#0091FF'
                            } else {
                                return '#feaa19'
                            }
                        },
                        barBorderRadius: [0, 0, 0, 0],
                    }
                },
                label: {
                    normal: {
                        show: false,  //柱状图上方显示数据
                        lineHeight: 46,
                        width: 90,
                        height: 43,
                        borderWidth: 2,
                        borderRadius: 100,
                        position: 'top',
                        distance: 1,
                        color: '#fff',
                        fontSize: 10,
                        fontWeight: 800,
                        formatter: function (p) {
                            // 超过10000加"k"
                            return p.value > 10000 ? (p.value / 1000).toFixed(1) + 'k' : p.value
                        },
                        rich: {
                            d: {
                                color: '#50f2ff',
                            },
                            a: {
                                color: '#fedf19',
                                align: 'center',
                                fontSize: 10
                            },
                            b: {
                                width: 1,
                                height: 48,
                                borderWidth: 1,
                                borderColor: '#fedf19',
                                align: 'left'
                            },
                        }
                    }
                }
            },
            {
                name: '实际产出',
                type: 'bar',
                // stack: 'all',
                // barGap: '-100%',
                // barWidth: '30%',
                // xAxisIndex: 2,
                barWidth: "43%",
                showBackground: true,
                backgroundStyle: {
                    color: 'rgba( 40, 90, 175, 0)',
                },
                data: data.map(e => e.outputNum),
                itemStyle: {
                    normal: {
                        color: function (params) {
                            let { value, dataIndex } = params
                            let {standardOutput, standardRate} = data[dataIndex]
                            if (accMul(standardOutput, standardRate) <= value) {
                                return '#50f2ff'
                            } else {
                                return '#FFF45C'
                            }
                        },
                        barBorderRadius: [0, 0, 0, 0],
                    }
                },
                label: {
                    normal: {
                        show: false, //柱状图上方显示数据
                        lineHeight: 46,
                        width: 90,
                        height: 43,
                        borderWidth: 2,
                        borderRadius: 100,
                        position: 'top',
                        distance: 1,
                        color: '#fff',
                        fontSize: 10,
                        fontWeight: 800,
                        formatter: function (p) {
                            return p.value > 10000 ? (p.value / 1000).toFixed(1) + 'k' : p.value
                        },
                        rich: {
                            d: {
                                color: '#50f2ff',
                            },
                            a: {
                                color: '#fedf19',
                                align: 'center',
                                fontSize: 10
                            },
                            b: {
                                width: 1,
                                height: 48,
                                borderWidth: 1,
                                borderColor: '#fedf19',
                                align: 'left'
                            },
                        }
                    }
                }
            },
        ]
    }
}

let outputDetail = [
    {
        "inputNum": 40492,
        "outputNum": 37294,
        "lineName": "D5",
        "standardOutput": -3262,
        "standardRate": 0.8
    },
    {
        "inputNum": 23288,
        "outputNum": 21862,
        "lineName": "CT1",
        "standardOutput": 44514,
        "standardRate": 0.8
    }
]

// 产能总况
let capChart = this.$refs.capChart;
let myChart = this.$echarts.init(capChart);
myChart.setOption(charts.capBar(this.outputDetail));


<div class="barCharts" ref="capChart"></div>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值