echarts 3D柱状+折线图 + 自滚动

<template>
  <div class="commercial-container">
    <div class="commercial-top-box">
      <itemTitle title="测试标题1133" />
    </div>
      <div class="commercial-center-box">
        <div class="Echarts">
          <div id="commercial-main" style="width: 27rem;height: 17rem;"></div>
        </div>
      </div>
  </div>
</template>

<script>
import itemTitle from '@/components/Title/itemTitle.vue'
export default {
  components: {
    itemTitle
  },
  data() {
    return {
    }
  },
  mounted() {
    this.myEcharts();
  },
  methods: {
    myEcharts() {
      var myChart = this.$echarts.init(document.getElementById('commercial-main'));
      //配置图表
      const industryData = [22, 35, 30, 22];
      const lineData = [22, 35, 30, 22];
      // 配置立体图
      const colors = ['#31D5C7', '#2EC6BD', '#1D2773'];
      const barColor = {
        type: 'linear',
        x: 0,
        x2: 0,
        y: 0,
        y2: 1,
        colorStops: [
          {
            offset: 0,
            color: colors[0]
          },
          {
            offset: 0.5,
            color: colors[1]
          },
          {
            offset: 1,
            color: colors[2]
          }
        ]
      };
      // 配置流线
      const liuxian = lineData.map((item,index)=>{
        return [index,lineData[index]]
      })
      var option = {
        legend: {
          data: [{
            name:"商业库存(万支)",
          },{
            name:"可销天数",
            textStyle:{
            }
          }],
          itemHeight:5,
          itemWidth:15,
          x: 'right',
          textStyle: {
            fontSize: 12,
            color: '#ffffff'
          },
        },
        animation: false,
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'shadow'
          },
        },
        grid: {
          left: '0%',
          right: '4%',
          bottom: '0%',
          top: '40px',
          containLabel: true
        },
        xAxis: {
          type: 'category',
          data: ['山东', '湖北', '四川', '安徽'],
          axisLabel: {
            color: '#E6F7FF'
          },
          axisLine: {
            show: true,
            lineStyle: {
              color: 'rgba(255, 255, 2555, 0.1)'
            }
          }
        },
        yAxis: [
          {
            type: 'value',
            axisLabel: {
              color: '#E6F7FF'
            },
            splitLine: {
              show: true,
              lineStyle: {
                color: 'rgba(255,255,255,0.2)'
              }
            }
          },
          {
            type: 'value',
            min: 0,
            max: 50,
            interval: 10,
            axisLabel: {
              color: '#fff'
            },
            splitLine: {
              show: false,
              lineStyle: {
                color: 'rgba(255,255,255,0.2)'
              }
            }
          }
        ],
        series: [
          // 线图
          {
            name: '可销天数',
            type: 'line',
            yAxisIndex: 1,
            data: lineData,
            emphasis:{
              scale:2.5
            },
            z:10,
            itemStyle: {
              normal: {
                color: '#6AF9F2', //圈圈的颜色
                lineStyle: {
                  color: '#32CDC3' //线的颜色
                }
              }
            }
          },
          //折线图流光配置
          {
            name: '可销天数',
            type: 'lines',
            coordinateSystem: 'cartesian2d',
            polyline: true,
            yAxisIndex:1,
            z:12,
            effect: {
              show: true,//是否展示
              period:4,//时间
              trailLength:0.3,//尾部长度
              symbolSize: 8,//点大小
              symbol: 'circle',//点的类型
              color: '#2EC6BD',//颜色
            },
            data: [{
              coords: liuxian
            }]
          },
          // 柱子
          {
            itemStyle: {
              normal: {
                // 这里是用一个柱子,从左到右的渐变。也可以用两个柱子做从上往下的渐变,和上面的透明渐变一样用法
                color:barColor
              },
              decal:{
                rotation:2,
              }
            },
            label: {
              show: true,
              position: 'top',
              color:'#fff',
            },
            data: industryData,
            symbol: 'diamond',
            symbolPosition: 'end',
            type: 'bar',
            barWidth: 18,
            symbolSize: [8, 19],
            z: 2,
            name: '商业库存(万支)',
          },
          {
            z: 3,
            name: '商业库存(万支)',
            type: 'pictorialBar',
            // 柱子顶部
            symbolPosition: 'end',
            data: industryData,
            symbol: 'diamond',
            symbolOffset: [0, -11],
            symbolRotate: 90,
            symbolSize: [8, 19],
            itemStyle: {
              normal: {
                borderWidth: 2,
                color: colors[1]
              }
            },
            tooltip: {
              show: false
            }
          },
        ]
      };
      myChart.setOption(option);
      var index = 0; //播放所在下标
      setInterval(function () {
        myChart.dispatchAction({
          type: 'showTip',
          seriesIndex: 0,
          dataIndex: index
        });
        index++;
        if (index > industryData.length) {
          index = 0;
        }
        myChart.setOption(option)
      }, 1500);
    }
  }
}
</script>

<style lang="scss" scope>
.commercial-container {
  padding: 0;
  margin: 0;
  width: 100%;

  .commercial-top-box {
    width: 100%;
  }

  .commercial-center-box {
    padding: 1rem 0;
    border: 2px solid #015169;
    width: 100%;
    height: 17rem;
    margin-top: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 2px 2px 10px #13A8BC;
  }
}
</style>

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在echarts中移动柱状图的位置,可以使用grid属性来调整图表的位置。在grid属性中,通过设置top、right、bottom和left属性来控制图表的位置。例如,可以将top属性设置为'15%',right属性设置为'5%',bottom属性设置为'10%',left属性设置为'10%'来调整柱状图的位置。具体代码如下所示: grid: { show: false, top: '15%', right: '5%', bottom: '10%', left: '10%' } 这样设置后,柱状图将会相对于整个图表区域进行位置调整。你可以根据需要调整这些属性的值来实现柱状图的位置移动。\[2\] #### 引用[.reference_title] - *1* [Echarts 偏移,柱状图偏移,散点图偏移,折线图偏移](https://blog.csdn.net/qq_53810245/article/details/130641880)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [Echarts图表位置调整](https://blog.csdn.net/qq_49046696/article/details/125562619)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [echarts 柱状滚动](https://blog.csdn.net/qq_41954585/article/details/127999805)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值