如何使用echarts实现3d的柱形图

1、首先去官网上下载依赖文件,也可以在我分享的资源中直接下载

options设置如下:

var xData = ["可研数据", "测试2", "测试3", "测试4", "测试5", "测试6"]
var line = ["1030", "205", "84","568","689","4587"];
var attr ={
    'name':'月平均单价',
    'unit':'元/单'
}
var colors = []
option = {
    
   tooltip: {
       textStyle: {
					fontSize: 50
				},
           trigger: '',
        padding: 1,
        
        formatter: function(param) {
            
            var resultTooltip =
                "<div style='background:rgba(13,5,30,.6);border:1px solid rgba(255,255,255,.2);padding:5px;border-radius:3px;'>" +
                "<div style='text-align:center;'>" +  param.name + "</div>" +
                "<div style='padding-top:5px;'>"+
                "<span style=''> " +attr.name + ": </span>" +
                "<span style=''>" + param.value + "</span><span>" + attr.unit + "</span>"+
                "</div>" +
                "</div>";
            return resultTooltip
        }
        },
   
    grid: {
       
         left:"2%",
				 right:'2%',
				 top:'20%',
				 bottom:"13%"
    },
    legend: {
        show: true,
        icon: 'circle',
        orient: 'horizontal',
        top: '90.5%',
        right: 'center',
        itemWidth: 16.5,
        itemHeight: 6,
        // itemGap: 30,
        textStyle: {
            // color: '#FFFFFF'
            color: '#C9C8CD',
            fontSize: 14
        }
    },
    xAxis: [{
        data: xData,
        axisLabel: {
            show:true,
            textStyle: {
                color: '#aaaaaa',
                fontSize:12
            },
            margin: 30, //刻度标签与轴线之间的距离。
        },

        axisLine: {
            show: false //不显示x轴
        },
        axisTick: {
            show: false //不显示刻度
        },
        boundaryGap: true,
        splitLine: {
            show: false,
            width: 0.08,
            lineStyle: {
                type: "solid",
                color: "#03202E"
            }
        }
    }],
    yAxis: [{
        show: false,
        splitLine: {
            show: false,
            lineStyle: {
                color: '#eee',
                type: 'solid'
            }
        },
        axisTick: {
            show: false
        },
        axisLine: {
            show: false
        },
        axisLabel: {
            textStyle: {
                color: '#888'
            },
        }
    }],
    series: [
        {//柱底圆片
            name: "",
            type: "pictorialBar",
            symbolSize: [60, 22],//调整截面形状
            symbolOffset: [0, 10],
            z: 12,
            itemStyle: {
                    'normal':{
                        color: function(params){
                            var colorArr = [ '#C1232B','#B5C334',
                            '#FCCE10','#E87C25','#27727B',
                            '#FE8463','#9BCA63'];
                            return colorArr[params.dataIndex]
                        },
                    }
                },
            data: line
        }, 
        
        //柱体
        {
            name: '',
            type: 'bar',
            barWidth: 60,
            barGap: '0%',
            itemStyle: {
                    normal: {
			                color: function(params) {

			                            // build a color map as your need.

			                            var colorList = [

			                              '#C1232B','#B5C334','#FCCE10','#E87C25','#27727B',

			                               '#FE8463','#9BCA63','#FAD860'
			                               

			                            ];

			                            return colorList[params.dataIndex]

			                        },
			                opacity: .7
			            }
                },
           
            data: line
        }, 
        
        //柱顶圆片
        {
            name: "",
            type: "pictorialBar",
            symbolSize: [60, 22],//调整截面形状
            symbolOffset: [0, -10],
            z: 12,
            symbolPosition: "end",
                "itemStyle": {
                    'normal':{
                        color: function(params){
                            var colorArr = [ '#C1232B','#B5C334',
                            '#FCCE10','#E87C25','#27727B',
                            '#FE8463','#9BCA63'];
                            return colorArr[params.dataIndex]
                        },
                    }
                },
            data: line
        }
    ]
};

效果图:

 

 

  • 4
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值