柱子样式变化pictorialBar图

1、示例

2、源码

var warningcolorValue=400;//根据预警值变化柱子的颜色,值设置
option = {
    tooltip: {
            trigger: 'axis',
            formatter: '{b}:{c}人',//悬停显示数据单位
            backgroundColor:'gray',
            borderWidth: 2,
            extraCssText: 'box-shadow: 0 0 13px yellow;',
            axisPointer: {
                type: 'line',
                lineStyle:{
                   type:'dotted',
                }
            }
    },
    grid: [{
        top: 50,
        width: '50%',
        bottom: '45%',
        left: 400,
        containLabel: false,
        // backgroundColor: 'red',
    },],
    xAxis: [{
        type: 'value',
        axisLine: {show: false},
        splitLine: {show: false},
        axisTick: {show: false},
        offset: 10,
        axisLabel: {
            margin:10,
            textStyle: {
            color: function (value) {//x轴颜色的设定
                 return value >= warningcolorValue ? 'red' : 'blue';//横坐标预警值
            },
        }
    }
    }],
    yAxis: [{
        type: 'category',
        data: ['巴西','印尼','美国','中国'],
        splitLine: {
            show: true,
            lineStyle:{
                width:1,
                type:'dotted',
            }
        },
        axisTick: {show: false},
        axisLine: {show: false},
        axisLabel: {
            formatter: function (value) {
                return '{value|' + value + '}';
            },
            margin: 10,
            rich: {
                value: {
                    height: 50,
                    align: 'center',
                    backgroundColor: '#dfeefd',
                    width:100,
                    color: '#000',
                    fontSize: 16,
                    borderWidth:1,
                    borderColor:'#bddaf7',
                },
            }
        },
        splitArea : {
					show : true,
					areaStyle : {
						color : [ '#dfeefd', '#fff', ]
					}
				},
    }],
    series: [{
        type: 'pictorialBar',//指定类型
        symbol: 'roundRect',//柱子显示的样式,'circle', 'rect', 'roundRect', 'triangle', 'diamond', 'pin', 'arrow'
        symbolRepeat: true,//每个小symbol是否重复
        symbolSize: [10, 30],//图形的宽和高
        symbolMargin: 1,//图形之间的间距
        itemStyle : {  
                  color: function (params){
                        if(params.data>warningcolorValue){//系列预警值,根据预警值变化柱子的颜色
                            var warningColor= new echarts.graphic.LinearGradient( 0, 0, 1, 0,[{offset: 0, color: '#ff995b'},{offset: 1, color: '#eb3838'}]);
                            return warningColor;
                        }
                        else{
                            var normalColor= new echarts.graphic.LinearGradient( 0, 0, 1, 0,[{offset: 0, color: '#6fb7ff'},{offset: 1, color: '#1f81e2'}]);
                            return normalColor;
                        }
                    },
                    
        },
        emphasis: { 
            itemStyle : { 
                shadowColor: 'gray',
                shadowBlur: 10,
                shadowOffsetX:10,
                shadowOffsetY:-4,
            }
        },
        label: {
                position: 'right',//标签数据显示的位置
                show: true,
                formatter: '{c}人'//加单位
        },
        data: [103, 401, 234, 170],
    }]

}

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

佛佛ง

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

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

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

打赏作者

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

抵扣说明:

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

余额充值