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'));
            var data = [
                [5000, 10000, 6785.71],
                [4000, 10000, 6825],
                [3000, 6500, 4463.33],
                [2500, 5600, 3793.83],
                [2000, 4000, 3060],
                [2000, 4000, 3222.33],
                [2500, 4000, 3133.33],
                [1800, 4000, 3100],
                [1500, 1800, 1650]
            ];
            var cities = ['甘孜县', '泸定县', '炉霍县', '色达县', '白玉县', '得荣县', '雅江县', '九龙县', '康定市'];
            var barHeight = 50;
            var option = {
                color: ['#7ecef4'],
                backgroundColor: 'rgba(1,202,217,.2)',
                grid: {
                    left: 60,
                    right: 60,
                    top: 60,
                    bottom: 40
                },
                legend: {
                    show: true,
                    data: ['价格范围', '均值']
                },
                //径向轴的属性
                angleAxis: {
                    type: 'category',
                    axisLine: {
                        lineStyle: {
                            color: 'rgba(255,255,255,.2)'
                        }
                    },
                    splitLine: {
                        lineStyle: {
                            color: 'rgba(255,255,255,.1)'
                        }
                    },
                    axisLabel: {
                        color: "rgba(255,255,255,.7)"
                    },
                    data: cities
                },
                //极坐标系堆叠柱状
                radiusAxis: {
                    axisLine: {
                        lineStyle: {
                            color: 'rgba(255,255,255,.2)'
                        }
                    },
                    splitLine: {
                        lineStyle: {
                            color: 'rgba(255,255,255,.1)'
                        }
                    },
                    axisLabel: {
                        color: "rgba(255,255,255,.5)"
                    }
                },
                //数据可视化polar极坐标系
                polar: {},
                series: [{
                    type: 'bar',
                    itemStyle: {
                        normal: {
                            color: 'transparent'
                        }
                    },
                    data: data.map(function(d) {
                        return d[0];
                    }),
                    //引入其他要素图层
                    coordinateSystem: 'polar',
                    stack: '最大最小值',
                    //坐标轴的标签是否响应和触发鼠标事件,默认不响应 
                    silent: true
                }, {
                    type: 'bar',
                    data: data.map(function(d) {
                        return d[1] - d[0];
                    }),
                    coordinateSystem: 'polar',
                    name: '价格范围',
                    stack: '最大最小值'
                }, {
                    type: 'bar',
                    itemStyle: {
                        normal: {
                            color: 'transparent'
                        }
                    },
                    data: data.map(function(d) {
                        return d[2] - barHeight;
                    }),
                    coordinateSystem: 'polar',
                    stack: '均值',
                    silent: true,
                    z: 10
                }, {
                    type: 'bar',
                    data: data.map(function(d) {
                        return barHeight * 2
                    }),
                    coordinateSystem: 'polar',
                    name: '均值',
                    stack: '均值',
                    barGap: '-100%',

                    z: 10
                }],
                legend: {
                    show: true,
                    data: ['A', 'B', 'C']
                }
            };
            myChart.setOption(option);
        </script>
    </body>
</html>

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值