Echarts实战案例代码(2):柱图堆叠方案备选案例

在这里插入图片描述


option = {
        tooltip: {
        trigger: 'axis'
    },
    title:[{
        text:"70%",
        left:"2%",
        right: '85%'
    },{
        text:"15%",
        left:"32%",
        right: '51%'
    },{
        text:"-1.46%",
        left:"17%",
        right: '68%'
    },{
        text:"6.2%",
         left:"47%",
        right: '34%'
    },{
        text:"5.3%",
         left:"62%",
        right: '17%'
    }],
        grid: [{
        left:"1%",
        right: '86%'
    }, {
        left:"17%",
        right: '68%'
    }, {
        left:"34%",
        right: '51%'
    }, {
        left:"51%",
        right: '34%'
    }, {
        left:"68%",
        right: '17%'
    }],
    xAxis: [{
        type: 'category',
        inverse: true,
        data: ['营业收入\n 30,482万元'],
        axisTick: {show: false},
        axisLine: {show: false},
        splitLine: {show: false},
        axisLabel: {
            formatter: function (value) {
                return value;
            }
        }
    },{
        type: 'category',
        inverse: true,
        data: ['净利润\n4,307万元'],
        gridIndex: 1,
        axisTick: {show: false},
        axisLine: {show: false},
        splitLine: {show: false},
        axisLabel: {
            formatter: function (value) {
                return value;
            }
        }
    },{
        type: 'category',
        inverse: true,
        data: ['净资产收益率\n1.8%'],
        gridIndex: 2,
        axisTick: {show: false},
        axisLine: {show: false},
        splitLine: {show: false},
        axisLabel: {
            formatter: function (value) {
                return value;
            }
        }
    },{
        type: 'category',
        inverse: true,
        data: ['净利率\n36%'],
        gridIndex: 3,
        axisTick: {show: false},
        axisLine: {show: false},
        splitLine: {show: false},
        axisLabel: {
            formatter: function (value) {
                return value;
            }
        }
    },{
        type: 'category',
        inverse: true,
        data: ['人均净利率\n32%'],
        gridIndex: 4,
        axisTick: {show: false},
        axisLine: {show: false},
        splitLine: {show: false},
        axisLabel: {
            formatter: function (value) {
                return value;
            }
        }
    }],
    yAxis: [{
        type: 'value',
        axisTick: {show: false},
        axisLine: {show: false},
        splitLine: {show: false},
        axisLabel: {show: false}
    },{
        type: 'value',
        gridIndex: 1,
        axisTick: {show: false},
        axisLine: {show: false},
        splitLine: {show: false},
        axisLabel: {show: false}
    },{
        type: 'value',
        gridIndex: 2,
        axisTick: {show: false},
        axisLine: {show: false},
        splitLine: {show: false},
        axisLabel: {show: false}
    },{
        type: 'value',
        gridIndex: 3,
        axisTick: {show: false},
        axisLine: {show: false},
        splitLine: {show: false},
        axisLabel: {show: false}
    },{
        type: 'value',
        gridIndex: 4,
        axisTick: {show: false},
        axisLine: {show: false},
        splitLine: {show: false},
        axisLabel: {show: false}
    }],
   series: [{
            name: 'A',
            type: 'bar',
              barWidth: "40%",
                itemStyle: {
                    barBorderRadius: 5,
                    color: "rgba(59,80,91,.6)"
                },
                emphasis: {
                    itemStyle: {
                        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                                {offset: 0, color: '#fba145'},
                                {offset: 0.7, color: '#fed53f'},
                                {offset: 1, color: '#fbe247'}
                            ]
                        )
                    }
                },
            data: [165],
        },
        {
            name: 'B',
            type: 'bar',
             barWidth: "40%",
                itemStyle: {
                    barBorderRadius: 5,
                    color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                                {offset: 0, color: '#fd633f'},
                                {offset: 1, color: '#fbe247'}
                            ]
                        )
                },
                emphasis: {
                    itemStyle: {
                        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                                {offset: 0, color: '#fba145'},
                                {offset: 0.7, color: '#fed53f'},
                                {offset: 1, color: '#fbe247'}
                            ]
                        )
                    }
                },
            data: [150]
        }, {
            name: 'A',
            type: 'bar',
            barWidth: "40%",
                itemStyle: {
                    barBorderRadius: 5,
                    color: "rgba(59,80,91,.6)"
                },
                emphasis: {
                    itemStyle: {
                        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                                {offset: 0, color: '#fba145'},
                                {offset: 0.7, color: '#fed53f'},
                                {offset: 1, color: '#fbe247'}
                            ]
                        )
                    }
                },
            data: [165],
            xAxisIndex: 1,
            yAxisIndex: 1
        },
        {
            name: 'B',
            type: 'bar',
            barWidth: "40%",
                itemStyle: {
                    barBorderRadius: 5,
                    color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                                {offset: 0, color: '#fd633f'},
                                {offset: 1, color: '#fbe247'}
                            ]
                        )
                },
                emphasis: {
                    itemStyle: {
                        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                                {offset: 0, color: '#fba145'},
                                {offset: 1, color: '#fbe247'}
                            ]
                        )
                    }
                },
            data: [150],
            xAxisIndex: 1,
            yAxisIndex: 1
        }, {
            name: 'A',
             barWidth: "40%",
                itemStyle: {
                    barBorderRadius: 5,
                    color: "rgba(59,80,91,.6)"
                },
                emphasis: {
                    itemStyle: {
                        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                                {offset: 0, color: '#fba145'},
                                {offset: 0.7, color: '#fed53f'},
                                {offset: 1, color: '#fbe247'}
                            ]
                        )
                    }
                },
            type: 'bar',
            data: [165],
            xAxisIndex: 2,
            yAxisIndex: 2
        },
        {
            name: 'B',
            type: 'bar',
             barWidth: "40%",
                itemStyle: {
                    barBorderRadius: 5,
                    color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                                {offset: 0, color: '#56f9b8'},
                                {offset: 1, color: '#74f853'}
                            ]
                        )
                },
                emphasis: {
                    itemStyle: {
                        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                                {offset: 0, color: '#fba145'},
                                {offset: 0.7, color: '#fed53f'},
                                {offset: 1, color: '#fbe247'}
                            ]
                        )
                    }
                },
            data: [150],
            xAxisIndex: 2,
            yAxisIndex: 2
        }, {
            name: 'A',
            type: 'bar',
             barWidth: "40%",
                itemStyle: {
                    barBorderRadius: 5,
                    color: "rgba(59,80,91,.6)"
                },
                emphasis: {
                    itemStyle: {
                        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                                {offset: 0, color: '#fba145'},
                                {offset: 0.7, color: '#fed53f'},
                                {offset: 1, color: '#fbe247'}
                            ]
                        )
                    }
                },
            data: [165],
            xAxisIndex: 3,
            yAxisIndex: 3
        },
        {
            name: 'B',
            type: 'bar',
             barWidth: "40%",
                itemStyle: {
                    barBorderRadius: 5,
                    color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                                {offset: 0, color: '#fd633f'},
                                {offset: 1, color: '#fbe247'}
                            ]
                        )
                },
                emphasis: {
                    itemStyle: {
                        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                                {offset: 0, color: '#fba145'},
                                {offset: 0.7, color: '#fed53f'},
                                {offset: 1, color: '#fbe247'}
                            ]
                        )
                    }
                },
            data: [150],
            xAxisIndex: 3,
            yAxisIndex: 3
        }, {
            name: 'A',
            type: 'bar',
             barWidth: "40%",
                itemStyle: {
                    barBorderRadius: 5,
                    color: "rgba(59,80,91,.6)"
                },
                emphasis: {
                    itemStyle: {
                        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                                {offset: 0, color: '#fba145'},
                                {offset: 0.7, color: '#fed53f'},
                                {offset: 1, color: '#fbe247'}
                            ]
                        )
                    }
                },
            data: [165],
            xAxisIndex: 4,
            yAxisIndex: 4
        },
        {
            name: 'B',
            type: 'bar',
             barWidth: "40%",
                itemStyle: {
                    barBorderRadius: 5,
                    color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                                {offset: 0, color: '#fd633f'},
                                {offset: 1, color: '#fbe247'}
                            ]
                        )
                },
                emphasis: {
                    itemStyle: {
                        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                                {offset: 0, color: '#fba145'},
                                {offset: 0.7, color: '#fed53f'},
                                {offset: 1, color: '#fbe247'}
                            ]
                        )
                    }
                },
            data: [150],
            xAxisIndex: 4,
            yAxisIndex: 4
        }
    ]
};

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

漏刻有时

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值