Echarts图表之条形进度条(二)

 <!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>Echarts图表</title>
        <!-- 引入echarts.min.js -->
        <script src="https://cdn.staticfile.org/echarts/4.3.0/echarts.min.js"></script>
    </head>
    <body>
        <div id="main" style="width: 600px;height:400px;"></div>
        <script type="text/javascript">
            var myChart = echarts.init(document.getElementById('main'));
            let myColor = ['#0f89e7', '#f57674', '#54d2e6', '#f9b348']
            // 指定图表的配置项和数据
            var option = {
                backgroundColor: '#000',
                grid: {
                    left: "50",
                    top: "40",
                    right: "0",
                    bottom: "10",
                    containLabel: true
                },
                xAxis: {
                    // 数值轴
                    type: 'value',
                    splitLine: {
                        show: false
                    },
                    axisLabel: {
                        show: false
                    },
                    axisTick: {
                        show: false
                    },
                    axisLine: {
                        show: false
                    }
                },
                yAxis: [{
                        // 类目轴
                        type: 'category',
                        axisTick: {
                            show: false
                        },
                        axisLine: {
                            show: false
                        },
                        // 标签文字样式
                        axisLabel: {
                            color: "black",
                            fontSize: 14,
                            textStyle: {
                                color: '#fff'
                            }
                        },
                        data: ["厦门第一医院", "厦门中山医院", "厦门中医院", "厦门第五医院"],
                        max: 4, // 关键:设置y刻度最大值,相当于设置总体行高
                        inverse: true
                    },
                    {
                        type: 'category',
                        axisTick: {
                            show: false
                        },
                        axisLine: {
                            show: false
                        },
                        axisLabel: {
                            color: "black",
                            fontSize: 14,
                            textStyle: {
                                color: '#fff'
                            }
                        },
                        data: [4000, 3000, 2000, 1000],
                        max: 4, // 关键:设置y刻度最大值,相当于设置总体行高
                        inverse: true
                    }
                ],
                series: [{
                    name: "%",
                    type: "bar",
                    barWidth: 13,
                    data: [40, 30, 20, 10],
                    barCategoryGap: 20,
                    label: {
                        show: true,
                        position: 'inside',
                        formatter: '{c}{a}',
                        color: '#fff',
                        fontSize: 12
                    },
                    // 颜色设置
                    itemStyle: {
                        normal: {
                            barBorderRadius: 10,
                            color: function(params) {
                                let num = myColor.length;
                                return myColor[params.dataIndex % num];
                            }
                        }
                    },
                    zlevel: 1
                }, {
                    name: "进度条背景",
                    type: "bar",
                    barGap: "-100%",
                    barWidth: 15,
                    data: [100, 100, 100, 100],
                    color: "rgba(255,255,255,0)",
                    itemStyle: {
                        normal: {
                            barBorderRadius: 10,
                            barBorderColor: '#01a4bf',
                            barBorderWidth: 3,
                        }
                    },
                }]
            };
            // 使用刚指定的配置项和数据显示图表。
            myChart.setOption(option);
        </script>
    </body>
</html>

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值