echarts柱形图遇到的问题,连续补充中......

在这里插入图片描述

let params = [{name:'小明',value:"1"},{name:'数量',value:"2"}]
        let params1 = [{name:'小白',value:"0.5"},{name:'数量',value:"5"}]

        var mapBoxOption = {

          //改变绘图的位置
          grid:{
            left:'5%',
            top:'5%',
            right:'5%',
            bottom:'20%'
          },
          //提示工具配置
          tooltip: {
            //设置选中背景高亮
            axisPointer: {
              // 默认为直线,可选为:'line' | 'shadow'
              type: 'shadow',
              shadowStyle: {
                color: '#2F596F',
                opacity: .5
              },
            },
            trigger: 'axis',
            //是否永远显示提示框内容,默认情况下在移出可触发提示框区域后 一定时间 后隐藏,设置为 true 可以保证一直显示提示框内容。
            alwaysShowContent: false,
            
            formatter: function(params){
              return params[0].value + "-----" +params[1].value
            }
          },
          //x轴配置
          xAxis: {
            type: 'category',
            //解决x轴的label隔一个显示一个的问题
            interval:0,
            data: ["1月","2月"],
            //设置轴线的属性
            axisLine:{
              lineStyle:{
                color:'#00FFD5',
              }
            },
            axisLabel:{
              color:"red"
            }
          },
          //y轴配置
          yAxis: {
            type: 'value',
            splitLine:{
              show:false,
              lineStyle:{
                color:'#00FFD5'
              }
            },
            axisLine:{
              lineStyle:{
                color:'#00FFD5',
              }
            },
            axisLabel:{
              color:"blue"
            }
          },
          series: [{
            data: params,
            type: 'bar',
            // barWidth:'40%',
            barWidth: 5, //柱子宽度
            barGap: 0, //柱子之间间距
            itemStyle: {
              normal: {
                color: new this.$echarts.graphic.LinearGradient(0, 1, 0, 0, [{
                  offset: 0,
                  color: "#089FFF"
                }, {
                  offset: 1,
                  color: "#166BB9"
                }], false)
              }
            }
          },
            // 一个值对应多个柱状图
          {
              data: params1,
              type: 'bar',
              // barWidth:'40%',
              barWidth: 5, //柱子宽度
              barGap: 0, //柱子之间间距
              itemStyle: {
                normal: {
                  color:"red"
                }
              }
            }
          ]

        }

在这里插入图片描述

 let data = [
          {stack:true,
            name:'大米',
            data:["1","2"],
            color:new this.$echarts.graphic.LinearGradient(0, 1, 0, 0, [{
              offset: 0,
              color: "#089FFF"
            },
            {
              offset: 1,
              color: "#166BB9"
            }], false),
            type:"bar"},
          {stack:true,name:'小米',data:[3,4],color:"red",type:"bar"}]


var mapBoxOption = {

          //改变绘图的位置
          grid:{
            left:'5%',
            top:'5%',
            right:'5%',
            bottom:'20%'
          },
          //提示工具配置
          tooltip: {

            //设置选中背景高亮
            axisPointer: {
              // 默认为直线,可选为:'line' | 'shadow'
              type: 'shadow',
              shadowStyle: {
                color: '#2F596F',
                opacity: .5
              },
            },
            trigger: 'axis',
            //是否永远显示提示框内容,默认情况下在移出可触发提示框区域后 一定时间 后隐藏,设置为 true 可以保证一直显示提示框内容。
            alwaysShowContent: false,
            // formatter: function(params){
            //   return params[0].value + "-----" +params[1].value
            // }
          },
          //x轴配置
          xAxis: {
            type: 'category',
            //解决x轴的label隔一个显示一个的问题
            // interval:0,
            data: ["1月","2月"],
            //设置轴线的属性
            axisLine:{
              lineStyle:{
                color:'#00FFD5',
              }
            },
            axisLabel:{
              color:"red"
            }
          },
          //y轴配置
          yAxis: {
            type: 'value',
            splitLine:{
              show:false,
              lineStyle:{
                color:'#00FFD5'
              }
            },
            axisLine:{
              lineStyle:{
                color:'#00FFD5',
              }
            },
            axisLabel:{
              color:"blue",
              formatter: '{value}',
            }
          },
          series: data

        }

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值